|
| 1 | +import { useDisclosure } from '@mantine/hooks'; |
| 2 | +import { |
| 3 | + Anchor, |
| 4 | + Checkbox, |
| 5 | + Paper, |
| 6 | + PasswordInput, |
| 7 | + Text, |
| 8 | + TextInput, |
| 9 | + Title, |
| 10 | + Box, |
| 11 | + rem, |
| 12 | + Modal, |
| 13 | + Button, |
| 14 | + Flex, |
| 15 | + Group, |
| 16 | +} from '@mantine/core'; |
| 17 | +import { useNavigate } from '@tanstack/react-router'; |
| 18 | + |
| 19 | +export function SignInModal() { |
| 20 | + const [opened, { open, close }] = useDisclosure(false); |
| 21 | + const navigate = useNavigate(); |
| 22 | + |
| 23 | + const modalContentHeight = rem(550); |
| 24 | + |
| 25 | + const mockLogin = () => { |
| 26 | + close(); |
| 27 | + navigate({ to: '/dashboard' }); |
| 28 | + }; |
| 29 | + |
| 30 | + return ( |
| 31 | + <> |
| 32 | + <Modal |
| 33 | + opened={opened} |
| 34 | + onClose={close} |
| 35 | + title="Authentication" |
| 36 | + centered |
| 37 | + size="xl" |
| 38 | + padding={0} |
| 39 | + overlayProps={{ |
| 40 | + backgroundOpacity: 0.55, |
| 41 | + blur: 3, |
| 42 | + }} |
| 43 | + styles={{ |
| 44 | + content: { |
| 45 | + height: modalContentHeight, |
| 46 | + padding: 0, |
| 47 | + display: 'flex', |
| 48 | + borderRadius: rem(8), |
| 49 | + overflow: 'hidden', |
| 50 | + }, |
| 51 | + body: { |
| 52 | + padding: 0, |
| 53 | + display: 'flex', |
| 54 | + flexGrow: 1, |
| 55 | + }, |
| 56 | + header: { |
| 57 | + display: 'none', |
| 58 | + }, |
| 59 | + }} |
| 60 | + > |
| 61 | + <Flex direction={{ base: 'column', sm: 'row' }} h="100%" w="100%"> |
| 62 | + <Paper |
| 63 | + p="xl" |
| 64 | + radius={0} |
| 65 | + style={(theme) => ({ |
| 66 | + flex: 1, |
| 67 | + minWidth: rem(300), |
| 68 | + height: '100%', |
| 69 | + display: 'flex', |
| 70 | + flexDirection: 'column', |
| 71 | + justifyContent: 'center', |
| 72 | + backgroundColor: theme.colors.dark[7], |
| 73 | + })} |
| 74 | + > |
| 75 | + <Title |
| 76 | + order={2} |
| 77 | + ta="center" |
| 78 | + mb={30} |
| 79 | + style={(theme) => ({ |
| 80 | + fontFamily: `Outfit, ${theme.fontFamily}`, |
| 81 | + fontWeight: 600, |
| 82 | + color: theme.white, |
| 83 | + })} |
| 84 | + > |
| 85 | + Get Started! |
| 86 | + </Title> |
| 87 | + |
| 88 | + <TextInput |
| 89 | + label="Email address" |
| 90 | + placeholder="hello@gmail.com" |
| 91 | + size="md" |
| 92 | + radius="md" |
| 93 | + required |
| 94 | + /> |
| 95 | + |
| 96 | + <PasswordInput |
| 97 | + label="Password" |
| 98 | + placeholder="Your password" |
| 99 | + mt="md" |
| 100 | + size="md" |
| 101 | + radius="md" |
| 102 | + required |
| 103 | + /> |
| 104 | + |
| 105 | + <Group justify="space-between" mt="lg"> |
| 106 | + <Checkbox label="Keep me logged in" size="sm" /> |
| 107 | + <Anchor component="button" size="sm"> |
| 108 | + Forgot password? |
| 109 | + </Anchor> |
| 110 | + </Group> |
| 111 | + |
| 112 | + <Button |
| 113 | + variant="filled" |
| 114 | + fullWidth |
| 115 | + mt="xl" |
| 116 | + size="md" |
| 117 | + radius="md" |
| 118 | + onClick={() => mockLogin()} |
| 119 | + > |
| 120 | + Login |
| 121 | + </Button> |
| 122 | + |
| 123 | + <Text ta="center" mt="md" size="sm"> |
| 124 | + Don't have an account?{' '} |
| 125 | + <Anchor |
| 126 | + href="#" |
| 127 | + fw={700} |
| 128 | + onClick={(event) => event.preventDefault()} |
| 129 | + > |
| 130 | + Register |
| 131 | + </Anchor> |
| 132 | + </Text> |
| 133 | + </Paper> |
| 134 | + |
| 135 | + <Box |
| 136 | + style={(theme) => ({ |
| 137 | + flex: 1.5, |
| 138 | + backgroundImage: |
| 139 | + 'url(https://images.unsplash.com/photo-1484242857719-4b9144542727?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1280&q=80)', |
| 140 | + backgroundSize: 'cover', |
| 141 | + backgroundPosition: 'center', |
| 142 | + height: '100%', |
| 143 | + display: theme.breakpoints.sm ? 'block' : 'none', |
| 144 | + })} |
| 145 | + /> |
| 146 | + </Flex> |
| 147 | + </Modal> |
| 148 | + |
| 149 | + <Button variant="default" onClick={open}> |
| 150 | + Sign In |
| 151 | + </Button> |
| 152 | + </> |
| 153 | + ); |
| 154 | +} |
0 commit comments