Allow theme customizing Login Page (#940)
This commit is contained in:
+62
-54
@@ -13,58 +13,62 @@ import Logo from '../icons/android-icon-72x72.png'
|
|||||||
import { useLogin, useNotify, useTranslate } from 'react-admin'
|
import { useLogin, useNotify, useTranslate } from 'react-admin'
|
||||||
|
|
||||||
import Notification from './Notification'
|
import Notification from './Notification'
|
||||||
import LightTheme from '../themes/light'
|
import useCurrentTheme from '../themes/useCurrentTheme'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
import { clearQueue } from '../actions'
|
import { clearQueue } from '../actions'
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles(
|
||||||
main: {
|
(theme) => ({
|
||||||
display: 'flex',
|
main: {
|
||||||
flexDirection: 'column',
|
display: 'flex',
|
||||||
minHeight: '100vh',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
minHeight: '100vh',
|
||||||
justifyContent: 'flex-start',
|
alignItems: 'center',
|
||||||
background: `url(${config.loginBackgroundURL})`,
|
justifyContent: 'flex-start',
|
||||||
backgroundRepeat: 'no-repeat',
|
background: `url(${config.loginBackgroundURL})`,
|
||||||
backgroundSize: 'cover',
|
backgroundRepeat: 'no-repeat',
|
||||||
backgroundPosition: 'center',
|
backgroundSize: 'cover',
|
||||||
},
|
backgroundPosition: 'center',
|
||||||
card: {
|
},
|
||||||
minWidth: 300,
|
card: {
|
||||||
marginTop: '6em',
|
minWidth: 300,
|
||||||
},
|
marginTop: '6em',
|
||||||
avatar: {
|
},
|
||||||
margin: '1em',
|
avatar: {
|
||||||
display: 'flex',
|
margin: '1em',
|
||||||
justifyContent: 'center',
|
display: 'flex',
|
||||||
},
|
justifyContent: 'center',
|
||||||
icon: {
|
},
|
||||||
backgroundColor: 'white',
|
icon: {
|
||||||
width: '40px',
|
backgroundColor: 'white',
|
||||||
},
|
width: '40px',
|
||||||
systemName: {
|
},
|
||||||
marginTop: '1em',
|
systemName: {
|
||||||
display: 'flex',
|
marginTop: '1em',
|
||||||
justifyContent: 'center',
|
display: 'flex',
|
||||||
color: '#3f51b5', //theme.palette.grey[500]
|
justifyContent: 'center',
|
||||||
},
|
color: '#3f51b5', //theme.palette.grey[500]
|
||||||
welcome: {
|
},
|
||||||
marginTop: '1em',
|
welcome: {
|
||||||
padding: '0 1em 1em 1em',
|
marginTop: '1em',
|
||||||
display: 'flex',
|
padding: '0 1em 1em 1em',
|
||||||
justifyContent: 'center',
|
display: 'flex',
|
||||||
color: '#3f51b5', //theme.palette.grey[500]
|
justifyContent: 'center',
|
||||||
},
|
color: '#3f51b5', //theme.palette.grey[500]
|
||||||
form: {
|
},
|
||||||
padding: '0 1em 1em 1em',
|
form: {
|
||||||
},
|
padding: '0 1em 1em 1em',
|
||||||
input: {
|
},
|
||||||
marginTop: '1em',
|
input: {
|
||||||
},
|
marginTop: '1em',
|
||||||
actions: {
|
},
|
||||||
padding: '0 1em 1em 1em',
|
actions: {
|
||||||
},
|
padding: '0 1em 1em 1em',
|
||||||
}))
|
},
|
||||||
|
systemNameLink: {},
|
||||||
|
}),
|
||||||
|
{ name: 'NDLogin' }
|
||||||
|
)
|
||||||
|
|
||||||
const renderInput = ({
|
const renderInput = ({
|
||||||
meta: { touched, error } = {},
|
meta: { touched, error } = {},
|
||||||
@@ -100,6 +104,7 @@ const FormLogin = ({ loading, handleSubmit, validate }) => {
|
|||||||
href="https://www.navidrome.org"
|
href="https://www.navidrome.org"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
|
className={classes.systemNameLink}
|
||||||
>
|
>
|
||||||
Navidrome
|
Navidrome
|
||||||
</a>
|
</a>
|
||||||
@@ -309,10 +314,13 @@ Login.propTypes = {
|
|||||||
// We need to put the ThemeProvider decoration in another component
|
// We need to put the ThemeProvider decoration in another component
|
||||||
// Because otherwise the useStyles() hook used in Login won't get
|
// Because otherwise the useStyles() hook used in Login won't get
|
||||||
// the right theme
|
// the right theme
|
||||||
const LoginWithTheme = (props) => (
|
const LoginWithTheme = (props) => {
|
||||||
<ThemeProvider theme={createMuiTheme(LightTheme)}>
|
const theme = useCurrentTheme()
|
||||||
<Login {...props} />
|
return (
|
||||||
</ThemeProvider>
|
<ThemeProvider theme={createMuiTheme(theme)}>
|
||||||
)
|
<Login {...props} />
|
||||||
|
</ThemeProvider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default LoginWithTheme
|
export default LoginWithTheme
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ export default {
|
|||||||
color: 'white',
|
color: 'white',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
NDLogin: {
|
||||||
|
systemNameLink: {
|
||||||
|
color: '#fff',
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
backgroundColor: 'inherit',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
|
|||||||
Reference in New Issue
Block a user