Skip to content

Commit 9263ca9

Browse files
author
Ayaan Farooqui
committed
added transition and images to user onboarding card
1 parent 21c7691 commit 9263ca9

File tree

9 files changed

+107
-70
lines changed

9 files changed

+107
-70
lines changed

public/res/onBoardingImage1.png

429 KB
Loading

src/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getCookie } from "./helperFunctions";
44
import OnBoardingScreen from "./onBoardingScreen/OnBoardingScreen";
55
import { theme } from "./Theme";
66
import { ThemeProvider } from '@mui/material/styles';
7+
import './onBoardingScreen/transitionStyles.css';
78

89
const stepColors = {
910
0: "#4abdac",

src/onBoardingScreen/OnBoardingScreen.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import Button from '@mui/material/Button';
44
import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft';
55
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
66
import styled from '@emotion/styled';
7-
import OnBoardingScreen0 from './OnBoardingScreen0';
8-
import OnBoardingScreen1 from './OnBoardingScreen1';
9-
import OnBoardingScreen2 from './OnBoardingScreen2';
7+
import { CSSTransition } from 'react-transition-group';
8+
import OnBoardingScreenHandler from './OnBoardingScreenHandler';
109

1110
const StyledMobileStepper = styled(MobileStepper)({
1211
"& .MuiMobileStepper-dotActive": {
@@ -28,21 +27,17 @@ export default function OnBoardingScreen(props) {
2827
return (
2928
<div style={{ display: "flex", flexDirection: "column", justifyContent: "space-between", alignItems: "center", height: "100vh" }}>
3029
<div></div>
31-
{
32-
props.activeStep === 0 &&
33-
<OnBoardingScreen0 />
34-
}
35-
{
36-
props.activeStep === 1 &&
37-
<OnBoardingScreen1 />
38-
}
39-
{
40-
props.activeStep === 2 &&
41-
<OnBoardingScreen2 handleSkip={props.handleSkip} />
42-
}
30+
<CSSTransition
31+
in={true}
32+
appear={true}
33+
timeout={1000}
34+
classNames="fade"
35+
>
36+
<OnBoardingScreenHandler activeStep={props.activeStep} handleSkip={props.handleSkip} />
37+
</CSSTransition>
4338
<div style={{ width: "100%", display: "flex", justifyContent: "center" }}>
4439
{props.activeStep < 2
45-
&&
40+
?
4641
<StyledMobileStepper
4742
variant="dots"
4843
steps={3}
@@ -65,6 +60,8 @@ export default function OnBoardingScreen(props) {
6560
</Button>
6661
}
6762
/>
63+
:
64+
<span></span>
6865
}
6966
</div>
7067
</div>

src/onBoardingScreen/OnBoardingScreen0.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/onBoardingScreen/OnBoardingScreen1.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/onBoardingScreen/OnBoardingScreen2.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Button } from "@mui/material";
2+
3+
export default function OnBoardingScreenCard(props) {
4+
return (
5+
<div style={{ width: "100%", display: "grid", gridTemplateColumns: "100%", gridTemplateRows: "60% 40%", height: "100%" }}>
6+
<div>
7+
<img src={props.imgURL} alt="onboarding user" width="100%" height="auto" />
8+
</div>
9+
<div style={{ display: "flex", flexDirection: "column", justifyContent: "space-evenly", alignItems: "center" }}>
10+
<h1 style={{ color: "white", marginBottom: "0px" }}>{props.header}</h1>
11+
<p style={{ textAlign: "center", color: "white", fontSize: "0.9rem", width: "85%", opacity: "0.7" }}>{props.content}</p>
12+
{
13+
props.showButton &&
14+
<Button style={{ backgroundColor: "white", width: "90%", borderRadius: "40px", height: "60px", color: "black", fontWeight: "bold", fontSize: "1.1rem" }} onClick={props.handleSkip}>
15+
Get started
16+
</Button>
17+
}
18+
</div>
19+
</div>
20+
);
21+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import OnBoardingScreenCard from './OnBoardingScreenCard';
2+
import { CSSTransition, TransitionGroup } from 'react-transition-group';
3+
4+
const cardContent = [{
5+
id: "01",
6+
header: "Lorem ipsum dolor",
7+
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
8+
showButton: false,
9+
imgURL:"/res/onBoardingImage1.png"
10+
},
11+
{
12+
id: "02",
13+
header: "Lorem ipsum dolor",
14+
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
15+
showButton: false,
16+
imgURL:"/res/onBoardingImage1.png"
17+
},
18+
{
19+
id: "03",
20+
header: "Lorem ipsum dolor",
21+
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
22+
showButton: true,
23+
imgURL:"/res/onBoardingImage1.png"
24+
}]
25+
26+
export default function OnBoardingScreenHandler(props) {
27+
return (
28+
<TransitionGroup style={{ height: "100%" }}>
29+
<CSSTransition
30+
timeout={1000}
31+
classNames="fade"
32+
key={cardContent[props.activeStep].id}
33+
>
34+
<OnBoardingScreenCard
35+
header={cardContent[props.activeStep].header}
36+
content={cardContent[props.activeStep].content}
37+
showButton={cardContent[props.activeStep].showButton}
38+
handleSkip={props.handleSkip}
39+
imgURL={cardContent[props.activeStep].imgURL}
40+
/>
41+
</CSSTransition>
42+
</TransitionGroup>
43+
)
44+
};
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
.alert-enter {
2-
opacity: 0;
3-
transform: scale(0.9);
1+
/* appear - on page load */
2+
.fade-appear {
3+
opacity: 0;
4+
z-index: 1;
45
}
56

6-
.alert-enter-active {
7-
opacity: 1;
8-
transform: translateX(0);
9-
transition: opacity 300ms, transform 300ms;
7+
.fade-appear.fade-appear-active {
8+
opacity: 1;
9+
transition: opacity 1000ms linear;
1010
}
1111

12-
.alert-exit {
13-
opacity: 1;
12+
/* enter */
13+
.fade-enter {
14+
opacity: 0;
15+
z-index: 1;
1416
}
1517

16-
.alert-exit-active {
17-
opacity: 0;
18-
transform: scale(0.9);
19-
transition: opacity 300ms, transform 300ms;
18+
.fade-enter.fade-enter-active {
19+
opacity: 1;
20+
transition: opacity 1000ms linear 0ms;
21+
}
22+
23+
/* exit */
24+
.fade-exit {
25+
opacity: 1;
26+
}
27+
28+
.fade-exit.fade-exit-active {
29+
opacity: 0;
30+
transition: opacity 0ms linear;
31+
}
32+
33+
.fade-exit-done {
34+
opacity: 0;
2035
}

0 commit comments

Comments
 (0)