Skip to content

Commit

Permalink
Created modal, which open after 5 second upon accessing the site.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry committed May 18, 2024
1 parent 4ec1641 commit f7f9d54
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ApplicationRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Modal } from '@ergolabs/ui-kit';
import { fireAnalyticsEvent, getBrowser, user } from '@spectrumlabs/analytics';
import { DateTime } from 'luxon';
import { FC, useEffect } from 'react';
Expand All @@ -6,6 +7,7 @@ import { Navigate, Outlet, useRoutes } from 'react-router-dom';
import { version } from '../package.json';
import { NetworkDomManager } from './common/services/NetworkDomManager/NetworkDomManager';
import { Layout } from './components/common/Layout/Layout';
import { PreSplashModal } from './components/PreSplashModal/PreSplashModal.tsx';
import { RouteConfigExtended } from './components/RouterTitle/RouteConfigExtended';
import { RouterTitle } from './components/RouterTitle/RouterTitle';
import { useApplicationSettings } from './context';
Expand Down Expand Up @@ -140,6 +142,9 @@ export const ApplicationRoutes: FC = () => {

const [settings] = useApplicationSettings();

const openPreSplashModal = () =>
Modal.open(({ close }) => <PreSplashModal close={close} />);

useEffect(() => {
fireAnalyticsEvent('App Loaded');

Expand All @@ -150,6 +155,14 @@ export const ApplicationRoutes: FC = () => {
user.set('locale_active', settings.lang);
}, []);

useEffect(() => {
const timer = setTimeout(() => {
openPreSplashModal();
}, 5000);

return () => clearTimeout(timer);
}, []);

return (
<>
<RouterTitle
Expand Down
37 changes: 37 additions & 0 deletions src/components/PreSplashModal/PreSplashModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Button, Flex, Modal, Typography, useDevice } from '@ergolabs/ui-kit';
import { Trans } from '@lingui/macro';
import { CSSProperties } from 'react';
import * as React from 'react';

export const PreSplashModal: React.FC<{ close: (result?: any) => void }> = ({
close,
}) => {
const { valBySize } = useDevice();

const handleClick = () => {
window.open('https://pre-splash-app.spectrum.fi/SPLASH-ADA', '_blank');
close();
};

return (
<>
<Modal.Title>
<Typography.Title level={3}>Try new interface</Typography.Title>
</Modal.Title>
<Modal.Content width={valBySize<CSSProperties['width']>('100%', 480)}>
<Flex col gap={4}>
<Typography.Body>
Spectrum DEX will become Splash soon. Try a new Pre-Splash Interface
and meet even faster trading experience.
</Typography.Body>
<Typography.Body strong>
To trade SPLASH token use the new Interface as well.
</Typography.Body>
<Button type="primary" size="large" width={100} onClick={handleClick}>
<Trans>Try now</Trans>
</Button>
</Flex>
</Modal.Content>
</>
);
};

0 comments on commit f7f9d54

Please sign in to comment.