import React, { Fragment, useState } from 'react'; import { Button, IconButton } from '@material-ui/core'; import { useStyles } from './Splash.styles'; import { CloseOutlined, FiberManualRecord, FiberManualRecordOutlined, } from '@material-ui/icons'; import ConditionallyRender from '../ConditionallyRender'; import { CLOSE_SPLASH } from '../../../testIds'; interface ISplashProps { components: React.ReactNode[]; onFinish: (status: boolean) => void; } const Splash: React.FC = ({ components, onFinish, }: ISplashProps) => { const styles = useStyles(); const [counter, setCounter] = useState(0); const onNext = () => { if (counter === components.length - 1) { onFinish(false); return; } setCounter(counter + 1); }; const onBack = () => { setCounter(counter - 1); }; const onClose = () => { onFinish(false); }; const calculatePosition = () => { if (counter === 0) { return '0'; } return counter * 24; }; const renderCircles = () => { return components.map((_, index) => { if (index === 0) { // Use index as key because the amount of pages will never dynamically change. return ( ); } return ; }); }; return (
{components[counter]}
{renderCircles()}
0} show={ } />
); }; export default Splash;