|
| 1 | +import { Box, type ButtonProps, createPolymorphicComponent, Modal, Stack, Text, Title } from '@mantine/core' |
| 2 | +import { useDisclosure } from '@mantine/hooks' |
| 3 | +import { useTranslation } from 'next-i18next' |
| 4 | +import { forwardRef } from 'react' |
| 5 | + |
| 6 | +import { Button } from '~ui/components/core/Button' |
| 7 | +import { useCustomVariant, useScreenSize } from '~ui/hooks' |
| 8 | + |
| 9 | +import { ModalTitle } from './ModalTitle' |
| 10 | + |
| 11 | +const RecommendedLinksModalBody = forwardRef<HTMLButtonElement, RecommendedLinksModalProps>((props, ref) => { |
| 12 | + const { t } = useTranslation() |
| 13 | + const variants = useCustomVariant() |
| 14 | + const [opened, handler] = useDisclosure(false) |
| 15 | + const { isMobile } = useScreenSize() |
| 16 | + |
| 17 | + const modalTitle = <ModalTitle breadcrumb={{ option: 'close', onClick: handler.close }} /> |
| 18 | + |
| 19 | + const buttons = Object.entries(t('recommended-links.buttons', { returnObjects: true }) || {}) |
| 20 | + |
| 21 | + return ( |
| 22 | + <> |
| 23 | + <Modal title={modalTitle} opened={opened} onClose={handler.close} fullScreen={isMobile} zIndex={999999}> |
| 24 | + <Stack align='center' spacing={16}> |
| 25 | + <Text align='center' fz={40}> |
| 26 | + {t('recommended-links.emoji')} |
| 27 | + </Text> |
| 28 | + <Title order={2} align='center'> |
| 29 | + {t('recommended-links.title')} |
| 30 | + </Title> |
| 31 | + <Text align='center' variant={variants.Text.darkGray}> |
| 32 | + {t('recommended-links.body')} |
| 33 | + </Text> |
| 34 | + <Stack spacing={16} style={{ maxWidth: '100%' }}> |
| 35 | + {buttons.map(([key, btn]) => ( |
| 36 | + <Button |
| 37 | + key={key} |
| 38 | + variant='secondary-icon' |
| 39 | + sx={{ |
| 40 | + paddingLeft: isMobile ? '1rem' : undefined, |
| 41 | + paddingRight: isMobile ? '1rem' : undefined, |
| 42 | + textDecoration: 'none', |
| 43 | + }} |
| 44 | + onClick={() => window.open(btn.link, '_blank')} |
| 45 | + > |
| 46 | + <Text ta='center' variant={variants.Text.utility1} fz={isMobile ? '.75rem' : undefined}> |
| 47 | + {btn.text} |
| 48 | + </Text> |
| 49 | + </Button> |
| 50 | + ))} |
| 51 | + </Stack> |
| 52 | + </Stack> |
| 53 | + </Modal> |
| 54 | + <Box component='button' ref={ref} onClick={handler.open} {...props} /> |
| 55 | + </> |
| 56 | + ) |
| 57 | +}) |
| 58 | +RecommendedLinksModalBody.displayName = 'RecommendedLinksModal' |
| 59 | + |
| 60 | +export const RecommendedLinksModal = createPolymorphicComponent<'button', RecommendedLinksModalProps>( |
| 61 | + RecommendedLinksModalBody |
| 62 | +) |
| 63 | + |
| 64 | +export type RecommendedLinksModalProps = ButtonProps |
0 commit comments