aboutsummaryrefslogtreecommitdiff
path: root/components/fadethrough.tsx
blob: e3af4d37aa9d530c3597e50064efa3b1c9d25001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Grow from '@material-ui/core/Grow';
import { ReactNode, useEffect, useState } from 'react';

export default function FadeThroughTransition(props: {
	from: ReactNode;
	to: ReactNode;
	show: boolean;
}) {
	var [firstRender, setFirstRender] = useState(true);
	useEffect(() => {
		setTimeout(() => setFirstRender(false), 0);
	}, []);

	return <div className='posabs a0 fadethrough'>
		<div className={'fadeout ' + (firstRender ? 'first' : '')}>
			<div className='posabs a0 from'>{props.from}</div>
		</div>
		<Grow in={props.show} timeout={300}>
			<div className='posabs a0 to'>{props.to}</div>
		</Grow>
	</div>;
}