mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
fix: responsive login page
This commit is contained in:
parent
2aeb897e6c
commit
c0b5c6766e
@ -1,4 +1,4 @@
|
||||
import {Button, Form, Input, message, Space} from 'antd'
|
||||
import {Button, Flex, Form, Input, message} from 'antd'
|
||||
import {t} from 'ttag'
|
||||
import React, {useContext, useEffect} from 'react'
|
||||
import {getUser, login} from '../utils/api'
|
||||
@ -60,18 +60,15 @@ export function LoginForm({ssoLogin}: { ssoLogin?: boolean }) {
|
||||
<Input.Password/>
|
||||
</Form.Item>
|
||||
|
||||
<Space>
|
||||
<Form.Item wrapperCol={{offset: 8, span: 16}}>
|
||||
<Flex wrap justify="center" gap="middle">
|
||||
<Button type='primary' htmlType='submit'>
|
||||
{t`Submit`}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
{ssoLogin && <Form.Item wrapperCol={{offset: 8, span: 16}}>
|
||||
{ssoLogin &&
|
||||
<Button type='dashed' htmlType='button' href='/login/oauth'>
|
||||
{t`Log in with SSO`}
|
||||
</Button>
|
||||
</Form.Item>}
|
||||
</Space>
|
||||
</Button>}
|
||||
</Flex>
|
||||
</Form>
|
||||
</>
|
||||
)
|
||||
|
||||
@ -6,6 +6,7 @@ import {LoginForm} from '../components/LoginForm'
|
||||
import type { InstanceConfig} from '../utils/api'
|
||||
import {getConfiguration} from '../utils/api'
|
||||
import {RegisterForm} from '../components/RegisterForm'
|
||||
import useBreakpoint from "../hooks/useBreakpoint";
|
||||
|
||||
export const AuthenticatedContext = createContext<
|
||||
{
|
||||
@ -22,6 +23,7 @@ export const AuthenticatedContext = createContext<
|
||||
export default function LoginPage() {
|
||||
const [wantRegister, setWantRegister] = useState<boolean>(false)
|
||||
const [configuration, setConfiguration] = useState<InstanceConfig>()
|
||||
const md = useBreakpoint('md')
|
||||
|
||||
const toggleWantRegister = () => {
|
||||
setWantRegister(!wantRegister)
|
||||
@ -31,9 +33,8 @@ export default function LoginPage() {
|
||||
getConfiguration().then(setConfiguration)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<Card title={wantRegister ? t`Register` : t`Log in`} style={{width: '100%'}}>
|
||||
<Card.Grid style={{width: '50%', textAlign: 'center'}} hoverable={false}>
|
||||
const grid = [
|
||||
<Card.Grid style={{width: md ? '100%' : '50%', textAlign: 'center'}} hoverable={false}>
|
||||
{wantRegister ? <RegisterForm/> : <LoginForm ssoLogin={configuration?.ssoLogin}/>}
|
||||
{
|
||||
configuration?.registerEnabled &&
|
||||
@ -45,10 +46,19 @@ export default function LoginPage() {
|
||||
>{wantRegister ? t`Log in` : t`Create an account`}
|
||||
</Button>
|
||||
}
|
||||
</Card.Grid>
|
||||
<Card.Grid style={{width: '50%'}} hoverable={false}>
|
||||
</Card.Grid>,
|
||||
<Card.Grid style={{width: md ? '100%' : '50%'}} hoverable={false}>
|
||||
<TextPage resource='ads.md'/>
|
||||
</Card.Grid>
|
||||
];
|
||||
|
||||
if (md) {
|
||||
grid.reverse();
|
||||
}
|
||||
|
||||
return (
|
||||
<Card title={wantRegister ? t`Register` : t`Log in`} style={{width: '100%'}}>
|
||||
{grid}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user