-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
215 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
packages/datatrak-web/src/features/WelcomeScreens/WelcomeScreens.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd | ||
*/ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { MobileStepper, Typography, Button as MuiButton } from '@material-ui/core'; | ||
import { KeyboardArrowLeft, KeyboardArrowRight } from '@material-ui/icons'; | ||
import SwipeableViews from 'react-swipeable-views'; | ||
|
||
const tutorialSteps = [ | ||
{ | ||
label: 'San Francisco – Oakland Bay Bridge, United States', | ||
imgPath: | ||
'https://images.unsplash.com/photo-1537944434965-cf4679d1a598?auto=format&fit=crop&w=400&h=250&q=60', | ||
}, | ||
{ | ||
label: 'Bird', | ||
imgPath: | ||
'https://images.unsplash.com/photo-1538032746644-0212e812a9e7?auto=format&fit=crop&w=400&h=250&q=60', | ||
}, | ||
{ | ||
label: 'Bali, Indonesia', | ||
imgPath: | ||
'https://images.unsplash.com/photo-1537996194471-e657df975ab4?auto=format&fit=crop&w=400&h=250&q=80', | ||
}, | ||
{ | ||
label: 'NeONBRAND Digital Marketing, Las Vegas, United States', | ||
imgPath: | ||
'https://images.unsplash.com/photo-1518732714860-b62714ce0c59?auto=format&fit=crop&w=400&h=250&q=60', | ||
}, | ||
{ | ||
label: 'Goč, Serbia', | ||
imgPath: | ||
'https://images.unsplash.com/photo-1512341689857-198e7e2f3ca8?auto=format&fit=crop&w=400&h=250&q=60', | ||
}, | ||
]; | ||
|
||
const Container = styled.div` | ||
padding: 2rem; | ||
`; | ||
|
||
const Title = styled(Typography).attrs({ | ||
variant: 'h1', | ||
})` | ||
font-size: 1rem; | ||
margin-bottom: 1rem; | ||
`; | ||
|
||
const Text = styled(Typography)` | ||
font-size: 0.875rem; | ||
`; | ||
|
||
const Image = styled.img` | ||
max-width: 100%; | ||
`; | ||
|
||
const Button = styled(MuiButton)` | ||
width: 100%; | ||
`; | ||
|
||
export const WelcomeScreens = () => { | ||
const [activeStep, setActiveStep] = useState(0); | ||
const maxSteps = tutorialSteps.length; | ||
|
||
const handleNext = () => { | ||
setActiveStep(prevActiveStep => prevActiveStep + 1); | ||
}; | ||
|
||
const handleBack = () => { | ||
setActiveStep(prevActiveStep => prevActiveStep - 1); | ||
}; | ||
|
||
const handleStepChange = step => { | ||
setActiveStep(step); | ||
}; | ||
return ( | ||
<Container> | ||
<Typography>{tutorialSteps[activeStep].label}</Typography> | ||
<SwipeableViews index={activeStep} onChangeIndex={handleStepChange} enableMouseEvents> | ||
{tutorialSteps.map((step, index) => ( | ||
<div key={step.label}> | ||
{Math.abs(activeStep - index) <= 2 ? ( | ||
<Image src={step.imgPath} alt={step.label} /> | ||
) : null} | ||
</div> | ||
))} | ||
</SwipeableViews> | ||
<MobileStepper | ||
steps={maxSteps} | ||
position="static" | ||
variant="text" | ||
activeStep={activeStep} | ||
nextButton={ | ||
<Button size="small" onClick={handleNext} disabled={activeStep === maxSteps - 1}> | ||
Next | ||
<KeyboardArrowLeft /> | ||
</Button> | ||
} | ||
backButton={ | ||
<Button size="small" onClick={handleBack} disabled={activeStep === 0}> | ||
<KeyboardArrowRight /> | ||
Back | ||
</Button> | ||
} | ||
/> | ||
</Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
export { WelcomeScreens } from './WelcomeScreens'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.