2019-06-23 02:45:32 +02:00
|
|
|
import React from 'react';
|
2019-06-29 07:49:08 +02:00
|
|
|
import { Route } from 'react-router';
|
2020-07-04 18:46:26 +02:00
|
|
|
import { SwitchTransition } from 'react-transition-group';
|
|
|
|
import Fade from '@/components/elements/Fade';
|
|
|
|
import styled from 'styled-components/macro';
|
|
|
|
import tw from 'twin.macro';
|
|
|
|
|
|
|
|
const StyledSwitchTransition = styled(SwitchTransition)`
|
|
|
|
${tw`relative`};
|
|
|
|
|
|
|
|
& section {
|
|
|
|
${tw`absolute w-full top-0 left-0`};
|
|
|
|
}
|
|
|
|
`;
|
2019-06-23 02:45:32 +02:00
|
|
|
|
2020-07-03 23:19:05 +02:00
|
|
|
const TransitionRouter: React.FC = ({ children }) => (
|
2019-06-29 07:17:29 +02:00
|
|
|
<Route
|
|
|
|
render={({ location }) => (
|
2020-07-04 18:46:26 +02:00
|
|
|
<StyledSwitchTransition>
|
2020-07-05 22:56:04 +02:00
|
|
|
<Fade timeout={150} key={location.key} in appear unmountOnExit>
|
2019-06-29 07:17:29 +02:00
|
|
|
<section>
|
2020-04-17 20:17:01 +02:00
|
|
|
{children}
|
2019-06-29 07:17:29 +02:00
|
|
|
</section>
|
2020-07-04 18:46:26 +02:00
|
|
|
</Fade>
|
|
|
|
</StyledSwitchTransition>
|
2019-06-29 07:17:29 +02:00
|
|
|
)}
|
|
|
|
/>
|
2019-06-23 02:45:32 +02:00
|
|
|
);
|
2020-07-03 23:19:05 +02:00
|
|
|
|
|
|
|
export default TransitionRouter;
|