bigbuffet-rw/app/soapbox/features/ui/components/modals/landing-page-modal.tsx

72 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-02-06 10:01:03 -08:00
import clsx from 'clsx';
2022-03-21 11:09:01 -07:00
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import SiteLogo from 'soapbox/components/site-logo';
2022-05-20 08:15:47 -07:00
import { Text, Button, Icon, Modal } from 'soapbox/components/ui';
2023-01-13 17:13:15 -08:00
import { useRegistrationStatus, useSoapboxConfig } from 'soapbox/hooks';
2022-03-21 11:09:01 -07:00
const messages = defineMessages({
download: { id: 'landing_page_modal.download', defaultMessage: 'Download' },
helpCenter: { id: 'landing_page_modal.helpCenter', defaultMessage: 'Help Center' },
login: { id: 'header.login.label', defaultMessage: 'Log in' },
register: { id: 'header.register.label', defaultMessage: 'Register' },
});
2022-05-02 14:26:27 -07:00
interface ILandingPageModal {
onClose: (type: string) => void,
}
2022-05-20 08:15:47 -07:00
/** Login and links to display from the hamburger menu of the homepage. */
2022-05-02 14:26:27 -07:00
const LandingPageModal: React.FC<ILandingPageModal> = ({ onClose }) => {
2022-03-21 11:09:01 -07:00
const intl = useIntl();
const soapboxConfig = useSoapboxConfig();
2023-01-13 17:13:15 -08:00
const { isOpen } = useRegistrationStatus();
2022-05-12 12:15:22 -07:00
const { links } = soapboxConfig;
2022-03-21 11:09:01 -07:00
return (
<Modal
2022-05-12 12:15:22 -07:00
title={<SiteLogo alt='Logo' className='h-6 w-auto cursor-pointer' />}
2022-03-21 11:09:01 -07:00
onClose={() => onClose('LANDING_PAGE')}
>
<div className='mt-4 divide-y divide-solid divide-gray-200 dark:divide-gray-800'>
2022-05-12 12:15:22 -07:00
{links.get('help') && (
2023-02-01 14:13:42 -08:00
<nav className='mb-6 grid gap-y-8'>
2022-05-12 12:15:22 -07:00
<a
href={links.get('help')}
target='_blank'
2023-02-01 14:13:42 -08:00
className='flex items-center space-x-3 rounded-md p-3 hover:bg-gray-50 dark:hover:bg-gray-900/50'
2022-05-12 12:15:22 -07:00
>
2023-02-01 14:13:42 -08:00
<Icon src={require('@tabler/icons/lifebuoy.svg')} className='h-6 w-6 shrink-0 text-gray-600 dark:text-gray-700' />
2022-05-12 12:15:22 -07:00
2022-05-20 08:15:47 -07:00
<Text weight='medium'>
2022-05-12 12:15:22 -07:00
{intl.formatMessage(messages.helpCenter)}
2022-05-20 08:15:47 -07:00
</Text>
2022-05-12 12:15:22 -07:00
</a>
</nav>
)}
2022-03-21 11:09:01 -07:00
<div
2023-02-06 10:06:44 -08:00
className={clsx('grid gap-4 pt-6', {
2022-03-21 11:09:01 -07:00
'grid-cols-2': isOpen,
'grid-cols-1': !isOpen,
})}
>
<Button to='/login' theme='tertiary' block>
2022-03-21 11:09:01 -07:00
{intl.formatMessage(messages.login)}
</Button>
2023-01-13 17:13:15 -08:00
{isOpen && (
2022-05-11 12:50:53 -07:00
<Button to='/signup' theme='primary' block>
2022-03-21 11:09:01 -07:00
{intl.formatMessage(messages.register)}
</Button>
)}
</div>
</div>
</Modal>
);
};
export default LandingPageModal;