Skip to content

Commit 83d6e54

Browse files
committed
animated cards
1 parent 80941cc commit 83d6e54

File tree

3 files changed

+44
-34
lines changed

3 files changed

+44
-34
lines changed

src/projects/authentication/AuthenticationLayout.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Templates from './Templates'
1111
const AuthenticationLayout = ({ match, location }) => {
1212
return (
1313
<Fragment>
14+
{match.url === location.pathname && <Redirect to={`${match.url}/users`} />}
1415
<PageHeader title="Authentication" useMaxWidth={false}>
1516
<PageHeaderTabs>
1617
<Tab to={`${match.url}/users`}>Users</Tab>
@@ -19,13 +20,13 @@ const AuthenticationLayout = ({ match, location }) => {
1920
</PageHeaderTabs>
2021
</PageHeader>
2122
<Panel>
22-
<TransitionGroup>
23-
<CSSTransition key={location.key} timeout={3000} classNames="page-transition">
23+
<TransitionGroup className="animated-cards">
24+
<CSSTransition key={location.key} timeout={600} classNames="animated-card">
2425
<Switch location={location}>
2526
<Route path={`${match.path}/users`} component={Users} />
2627
<Route path={`${match.path}/signin-method`} component={SigninMethods} />
2728
<Route path={`${match.path}/templates`} component={Templates} />
28-
<Redirect to={`${match.url}/users`} />
29+
<Route component={() => null} />
2930
</Switch>
3031
</CSSTransition>
3132
</TransitionGroup>

src/projects/database/DatabaseLayout.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import React, { Fragment } from 'react'
22
import { Switch, Route, Redirect } from 'react-router-dom'
3+
import { TransitionGroup, CSSTransition } from 'react-transition-group'
34
import Panel from '../../ui/Panel'
45
import PageHeader from '../../ui/PageHeader'
56
import { PageHeaderTabs, Tab } from '../../ui/PageHeaderTabs'
67
import Data from './Data'
78
import Rules from './Rules'
89
import DataIndexes from './DataIndexes'
910

10-
const DatabaseLayout = ({ match }) => {
11+
const DatabaseLayout = ({ match, location }) => {
1112
return (
1213
<Fragment>
14+
{match.url === location.pathname && <Redirect to={`${match.url}/data`} />}
1315
<PageHeader title="Database" useMaxWidth={false}>
1416
<PageHeaderTabs>
1517
<Tab to={`${match.url}/data`}>Data</Tab>
@@ -18,12 +20,16 @@ const DatabaseLayout = ({ match }) => {
1820
</PageHeaderTabs>
1921
</PageHeader>
2022
<Panel>
21-
<Switch>
22-
<Route path={`${match.path}/data`} component={Data} />
23-
<Route path={`${match.path}/rules`} component={Rules} />
24-
<Route path={`${match.path}/indexes`} component={DataIndexes} />
25-
<Redirect to={`${match.url}/data`} />
26-
</Switch>
23+
<TransitionGroup className="animated-cards">
24+
<CSSTransition key={location.key} timeout={600} classNames="animated-card">
25+
<Switch>
26+
<Route path={`${match.path}/data`} component={Data} />
27+
<Route path={`${match.path}/rules`} component={Rules} />
28+
<Route path={`${match.path}/indexes`} component={DataIndexes} />
29+
<Route component={() => null} />
30+
</Switch>
31+
</CSSTransition>
32+
</TransitionGroup>
2733
</Panel>
2834
</Fragment>
2935
)

src/styles/ui/card.scss

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,32 @@
66
min-height: 3em;
77
}
88

9-
// .card {
10-
// position: absolute;
11-
// background-color: red;
12-
// }
9+
.animated-cards {
10+
position: relative;
1311

14-
// .page-transition {
15-
// &-enter {
16-
// opacity: 0;
17-
// transform: translateX(-10em);
18-
// transition: all 1s;
19-
// }
20-
// &-enter-active {
21-
// opacity: 1;
22-
// transform: translateX(0);
23-
// }
12+
> * {
13+
position: absolute;
14+
width: 100%;
15+
}
16+
}
17+
18+
.animated-card {
19+
&-exit {
20+
opacity: 1;
21+
transition: all 0.6s;
22+
}
23+
&-exit-active {
24+
opacity: 0;
25+
transform: translateY(3em);
26+
}
2427

25-
// &-exit {
26-
// opacity: 1;
27-
// transform: translateX(10em);
28-
// transition: all 1s;
29-
// }
30-
// &-exit-active {
31-
// opacity: 0;
32-
// transform: translateX(0);
33-
// }
34-
// }
28+
&-enter {
29+
opacity: 0;
30+
transition: all 0.6s;
31+
transform: translateY(-1em);
32+
}
33+
&-enter-active {
34+
opacity: 1;
35+
transform: translateY(0);
36+
}
37+
}

0 commit comments

Comments
 (0)