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

78 lines
2.7 KiB
TypeScript
Raw Normal View History

2022-03-21 11:09:01 -07:00
import classNames from 'classnames';
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';
import { useAppSelector, useFeatures, 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();
const pepeEnabled = soapboxConfig.getIn(['extensions', 'pepe', 'enabled']) === true;
2022-05-12 12:15:22 -07:00
const { links } = soapboxConfig;
2022-05-02 14:24:45 -07:00
const instance = useAppSelector((state) => state.instance);
const features = useFeatures();
2022-05-02 14:24:45 -07:00
2022-05-12 12:15:22 -07:00
const isOpen = features.accountCreation && instance.registrations;
const pepeOpen = useAppSelector(state => state.verification.instance.get('registrations') === true);
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') && (
<nav className='grid gap-y-8 mb-6'>
<a
href={links.get('help')}
target='_blank'
className='p-3 space-x-3 flex items-center rounded-md dark:hover:bg-gray-900/50 hover:bg-gray-50'
2022-05-12 12:15:22 -07:00
>
2022-08-09 08:50:10 -07:00
<Icon src={require('@tabler/icons/lifebuoy.svg')} className='flex-shrink-0 h-6 w-6 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
className={classNames('pt-6 grid gap-4', {
'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>
{(isOpen || pepeEnabled && pepeOpen) && (
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;