2019-06-23 00:45:32 +00:00
|
|
|
import React from 'react';
|
2019-06-29 05:49:08 +00:00
|
|
|
import { Route } from 'react-router';
|
2020-07-04 16:46:26 +00: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 00:45:32 +00:00
|
|
|
|
2020-07-03 21:19:05 +00:00
|
|
|
const TransitionRouter: React.FC = ({ children }) => (
|
2019-06-29 05:17:29 +00:00
|
|
|
<Route
|
|
|
|
render={({ location }) => (
|
2020-07-04 16:46:26 +00:00
|
|
|
<StyledSwitchTransition>
|
2020-07-05 20:56:04 +00:00
|
|
|
<Fade timeout={150} key={location.key} in appear unmountOnExit>
|
2019-06-29 05:17:29 +00:00
|
|
|
<section>
|
2020-04-17 18:17:01 +00:00
|
|
|
{children}
|
2019-06-29 05:17:29 +00:00
|
|
|
</section>
|
2020-07-04 16:46:26 +00:00
|
|
|
</Fade>
|
|
|
|
</StyledSwitchTransition>
|
2019-06-29 05:17:29 +00:00
|
|
|
)}
|
|
|
|
/>
|
2019-06-23 00:45:32 +00:00
|
|
|
);
|
2020-07-03 21:19:05 +00:00
|
|
|
|
|
|
|
export default TransitionRouter;
|