2021-01-01 17:21:13 +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`};
|
2021-07-09 18:58:06 +00:00
|
|
|
|
2020-07-04 16:46:26 +00:00
|
|
|
& section {
|
|
|
|
${tw`absolute w-full top-0 left-0`};
|
|
|
|
}
|
|
|
|
`;
|
2019-06-23 00:45:32 +00:00
|
|
|
|
2020-08-20 04:30:45 +00:00
|
|
|
const TransitionRouter: React.FC = ({ children }) => {
|
|
|
|
return (
|
|
|
|
<Route
|
|
|
|
render={({ location }) => (
|
|
|
|
<StyledSwitchTransition>
|
2021-01-01 17:21:13 +00:00
|
|
|
<Fade timeout={150} key={location.pathname + location.search} in appear unmountOnExit>
|
2020-08-20 04:30:45 +00:00
|
|
|
<section>
|
|
|
|
{children}
|
|
|
|
</section>
|
|
|
|
</Fade>
|
|
|
|
</StyledSwitchTransition>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2020-07-03 21:19:05 +00:00
|
|
|
|
|
|
|
export default TransitionRouter;
|