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

58 lines
1.9 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 { Button } from 'soapbox/components/ui';
import { Modal } from 'soapbox/components/ui';
2022-05-02 14:24:45 -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,
}
const LandingPageModal: React.FC<ILandingPageModal> = ({ onClose }) => {
2022-03-21 11:09:01 -07:00
const intl = useIntl();
2022-05-02 14:24:45 -07:00
const { logo } = useSoapboxConfig();
const instance = useAppSelector((state) => state.instance);
const features = useFeatures();
const isOpen = instance.get('registrations', false) === true;
const pepeOpen = useAppSelector(state => state.verification.getIn(['instance', 'registrations'], false) === true);
2022-03-21 11:09:01 -07:00
return (
<Modal
title={<img alt='Logo' src={logo} className='h-4 w-auto' />}
onClose={() => onClose('LANDING_PAGE')}
>
<div className='mt-4 divide-y divide-solid divide-gray-200'>
<div
className={classNames('pt-6 grid gap-4', {
'grid-cols-2': isOpen,
'grid-cols-1': !isOpen,
})}
>
<Button to='/login' theme='secondary' block>
{intl.formatMessage(messages.login)}
</Button>
2022-05-02 14:24:45 -07:00
{(isOpen || features.pepe && pepeOpen) && (
<Button to={features.pepe ? '/verify' : '/signup'} theme='primary' block>
2022-03-21 11:09:01 -07:00
{intl.formatMessage(messages.register)}
</Button>
)}
</div>
</div>
</Modal>
);
};
export default LandingPageModal;