2022-08-31 02:35:06 -07:00
|
|
|
import classNames from 'clsx';
|
2022-03-21 11:09:01 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
|
2022-05-11 17:54:23 -07:00
|
|
|
import SiteLogo from 'soapbox/components/site-logo';
|
2022-05-20 08:15:47 -07:00
|
|
|
import { Text, Button, Icon, Modal } from 'soapbox/components/ui';
|
2022-05-10 17:04:29 -07:00
|
|
|
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();
|
|
|
|
|
2022-05-10 16:48:57 -07:00
|
|
|
const soapboxConfig = useSoapboxConfig();
|
|
|
|
const pepeEnabled = soapboxConfig.getIn(['extensions', 'pepe', 'enabled']) === true;
|
2022-05-12 12:15:22 -07:00
|
|
|
const { links } = soapboxConfig;
|
2022-05-10 16:48:57 -07:00
|
|
|
|
2022-05-02 14:24:45 -07:00
|
|
|
const instance = useAppSelector((state) => state.instance);
|
2022-05-10 17:04:29 -07:00
|
|
|
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;
|
2022-06-20 06:46:43 -07:00
|
|
|
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')}
|
|
|
|
>
|
2022-07-22 10:30:16 -07:00
|
|
|
<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'
|
2022-07-22 10:30:16 -07:00
|
|
|
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,
|
|
|
|
})}
|
|
|
|
>
|
2022-07-22 10:30:16 -07:00
|
|
|
<Button to='/login' theme='tertiary' block>
|
2022-03-21 11:09:01 -07:00
|
|
|
{intl.formatMessage(messages.login)}
|
|
|
|
</Button>
|
|
|
|
|
2022-05-10 16:48:57 -07:00
|
|
|
{(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;
|