-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
e79e4fb
commit 00cf1bf
Showing
32 changed files
with
2,303 additions
and
141 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
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 |
---|---|---|
@@ -1,42 +0,0 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
a:nth-of-type(2) .logo { | ||
animation: logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} | ||
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,7 @@ | ||
import { Box, styled } from "@mui/material"; | ||
|
||
export const AppWrapper = styled(Box)(({ theme }) => ({ | ||
maxWidth: theme.breakpoints.values.sm, | ||
margin: "auto", | ||
padding: theme.spacing(5), | ||
})); |
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 |
---|---|---|
@@ -1,35 +1,18 @@ | ||
import { useState } from 'react' | ||
import reactLogo from './assets/react.svg' | ||
import viteLogo from '/vite.svg' | ||
import './App.css' | ||
import { Provider } from "react-redux"; | ||
import "./App.css"; | ||
import { AppWrapper } from "./App.styles"; | ||
import { Wizard } from "./components/Wizard/Wizard"; | ||
import { STEPS } from "./components/Wizard/Wizard.constant"; | ||
import store from "./redux/store"; | ||
|
||
function App() { | ||
const [count, setCount] = useState(0) | ||
|
||
return ( | ||
<> | ||
<div> | ||
<a href="https://vite.dev" target="_blank"> | ||
<img src={viteLogo} className="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://react.dev" target="_blank"> | ||
<img src={reactLogo} className="logo react" alt="React logo" /> | ||
</a> | ||
</div> | ||
<h1>Vite + React</h1> | ||
<div className="card"> | ||
<button onClick={() => setCount((count) => count + 1)}> | ||
count is {count} | ||
</button> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to test HMR | ||
</p> | ||
</div> | ||
<p className="read-the-docs"> | ||
Click on the Vite and React logos to learn more | ||
</p> | ||
</> | ||
) | ||
<Provider store={store}> | ||
<AppWrapper> | ||
<Wizard steps={STEPS} /> | ||
</AppWrapper> | ||
</Provider> | ||
); | ||
} | ||
|
||
export default App | ||
export default App; |
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,18 @@ | ||
import { NameForm, ReviewScreen } from "./components/Steps"; | ||
import { SelectForm } from "./components/Steps/SelectForm/SelectForm"; | ||
import { Step } from "./Wizard.types"; | ||
|
||
export const STEPS: Step[] = [ | ||
{ | ||
label: "Step 1", | ||
content: <NameForm />, | ||
}, | ||
{ | ||
label: "Step 2", | ||
content: <SelectForm />, | ||
}, | ||
{ | ||
label: "Step 3", | ||
content: <ReviewScreen />, | ||
}, | ||
]; |
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,7 @@ | ||
import { Box, styled } from "@mui/material"; | ||
|
||
export const ContentWrapper = styled(Box)(({ theme }) => ({ | ||
minHeight: "200px", | ||
margin: "auto", | ||
paddingTop: theme.spacing(7), | ||
})); |
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,26 @@ | ||
import { useState } from "react"; | ||
import { WizardProps } from "./Wizard.types"; | ||
import { WizardHeader } from "./components"; | ||
import { WizardButtons } from "./components/WizardButtons"; | ||
import { ContentWrapper } from "./Wizard.styles"; | ||
|
||
export const Wizard: React.FC<WizardProps> = ({ steps }) => { | ||
const [step, setStep] = useState(0); | ||
const { content } = steps[step]; | ||
const headerSteps: string[] = steps.map(({ label }) => { | ||
return label; | ||
}); | ||
|
||
return ( | ||
<section> | ||
<WizardHeader steps={headerSteps} setStep={setStep} currentStep={step} /> | ||
<ContentWrapper>{content}</ContentWrapper> | ||
<WizardButtons | ||
setStep={setStep} | ||
currentStep={step} | ||
isFirstStep={step === 0} | ||
isLastStep={step === steps.length - 1} | ||
/> | ||
</section> | ||
); | ||
}; |
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,8 @@ | ||
export type Step = { | ||
label: string; | ||
content: React.ReactNode; | ||
}; | ||
|
||
export type WizardProps = { | ||
steps: Step[]; | ||
}; |
43 changes: 43 additions & 0 deletions
43
src/components/Wizard/components/Steps/NameForm/NameForm.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,43 @@ | ||
import { FormEvent } from "react"; | ||
import { useUserName } from "../../../../../hooks/useUserName"; | ||
import { TextField, Button } from "@mui/material"; | ||
|
||
export const NameForm: React.FC = () => { | ||
const { name, updateUserName } = useUserName(); | ||
|
||
const onSubmit = (e: FormEvent) => { | ||
e.preventDefault(); | ||
// onFirstStepSubmit(); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={onSubmit}> | ||
{/* {hasError && ( | ||
<Typography color="error"> | ||
There was an error, please try again. | ||
</Typography> | ||
)} */} | ||
|
||
<TextField | ||
label="Your Name" | ||
value={name} | ||
onChange={(e) => updateUserName(e.target.value)} | ||
fullWidth | ||
variant="outlined" | ||
margin="normal" | ||
slotProps={{ htmlInput: { maxLength: 63 } }} | ||
autoFocus | ||
/> | ||
|
||
<Button | ||
type="submit" | ||
variant="contained" | ||
color="primary" | ||
role="submit" | ||
// disabled={isLoading} | ||
> | ||
Submit | ||
</Button> | ||
</form> | ||
); | ||
}; |
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 @@ | ||
export * from "./NameForm"; |
5 changes: 5 additions & 0 deletions
5
src/components/Wizard/components/Steps/ReviewScreen/ReviewScreen.styles.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,5 @@ | ||
import { styled, Typography } from "@mui/material"; | ||
|
||
export const CenteredTypography = styled(Typography)(() => ({ | ||
textAlign: 'center' | ||
})) |
26 changes: 26 additions & 0 deletions
26
src/components/Wizard/components/Steps/ReviewScreen/ReviewScreen.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,26 @@ | ||
import { Grid } from "@mui/material"; | ||
import { CenteredTypography } from "./ReviewScreen.styles"; | ||
import { useUserName } from "../../../../../hooks/useUserName"; | ||
|
||
export const ReviewScreen = () => { | ||
const { name } = useUserName(); | ||
|
||
return ( | ||
<Grid | ||
container | ||
spacing={2} | ||
flexDirection="column" | ||
justifyContent="center" | ||
alignItems="center" | ||
> | ||
<Grid item xs={8}> | ||
<CenteredTypography variant="h6">Name</CenteredTypography> | ||
<CenteredTypography>{name}</CenteredTypography> | ||
</Grid> | ||
<Grid item xs={4}> | ||
<CenteredTypography variant="h6">Age</CenteredTypography> | ||
<CenteredTypography>Name</CenteredTypography> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; |
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 @@ | ||
export * from "./ReviewScreen"; |
30 changes: 30 additions & 0 deletions
30
src/components/Wizard/components/Steps/SelectForm/SelectForm.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,30 @@ | ||
import { | ||
FormControl, | ||
InputLabel, | ||
Select, | ||
MenuItem, | ||
SelectChangeEvent, | ||
} from "@mui/material"; | ||
import { useState } from "react"; | ||
|
||
export const SelectForm = () => { | ||
const [age, setAge] = useState(""); | ||
|
||
const handleChange = (e: SelectChangeEvent<string>) => setAge(e.target.value); | ||
return ( | ||
<FormControl fullWidth> | ||
<InputLabel id="demo-simple-select-label">Age</InputLabel> | ||
<Select | ||
labelId="demo-simple-select-label" | ||
id="demo-simple-select" | ||
value={age} | ||
label="Age" | ||
onChange={handleChange} | ||
> | ||
<MenuItem value={10}>Ten</MenuItem> | ||
<MenuItem value={20}>Twenty</MenuItem> | ||
<MenuItem value={30}>Thirty</MenuItem> | ||
</Select> | ||
</FormControl> | ||
); | ||
}; |
Empty file.
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,3 @@ | ||
export * from "./NameForm"; | ||
export * from "./SelectForm"; | ||
export * from "./ReviewScreen"; |
7 changes: 7 additions & 0 deletions
7
src/components/Wizard/components/WizardButtons/WizardButtons.styles.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,7 @@ | ||
import { Box, styled } from "@mui/material"; | ||
|
||
export const ButtonWrapper = styled(Box)(({ theme }) => ({ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
paddingTop: theme.spacing(2), | ||
})); |
33 changes: 33 additions & 0 deletions
33
src/components/Wizard/components/WizardButtons/WizardButtons.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,33 @@ | ||
import { Box, Button } from "@mui/material"; | ||
import { WizardButtonsProps } from "./WizardButtons.types"; | ||
import { ButtonWrapper } from "./WizardButtons.styles"; | ||
|
||
export const WizardButtons: React.FC<WizardButtonsProps> = ({ | ||
currentStep, | ||
setStep, | ||
isFirstStep, | ||
isLastStep, | ||
}) => { | ||
const onPreviousStepChange = () => { | ||
setStep(currentStep - 1); | ||
}; | ||
|
||
const onNextStepChange = () => { | ||
if (isLastStep) { | ||
console.log("hello"); | ||
} else { | ||
setStep(currentStep + 1); | ||
} | ||
}; | ||
|
||
return ( | ||
<ButtonWrapper> | ||
<Button disabled={isFirstStep} onClick={onPreviousStepChange}> | ||
Previous | ||
</Button> | ||
<Button onClick={onNextStepChange}> | ||
{isLastStep ? "Submit" : "Next"} | ||
</Button> | ||
</ButtonWrapper> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
src/components/Wizard/components/WizardButtons/WizardButtons.types.ts
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 @@ | ||
export type WizardButtonsProps = { | ||
setStep: (step: number) => void; | ||
currentStep: number; | ||
isFirstStep: boolean; | ||
isLastStep: boolean; | ||
}; |
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 @@ | ||
export * from "./WizardButtons"; |
23 changes: 23 additions & 0 deletions
23
src/components/Wizard/components/WizardHeader/WizardHeader.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,23 @@ | ||
import { Stepper, Step, StepLabel } from "@mui/material"; | ||
import { WizardHeaderProps } from "./WizardHeader.types"; | ||
|
||
export const WizardHeader: React.FC<WizardHeaderProps> = ({ | ||
currentStep, | ||
steps, | ||
setStep, | ||
}) => { | ||
return ( | ||
// <div> | ||
// {steps.map((label, index) => { | ||
// return <button onClick={() => setStep(index)}>{label}</button>; | ||
// })} | ||
// </div> | ||
<Stepper activeStep={currentStep} alternativeLabel> | ||
{steps.map((label) => ( | ||
<Step key={label}> | ||
<StepLabel>{label}</StepLabel> | ||
</Step> | ||
))} | ||
</Stepper> | ||
); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/components/Wizard/components/WizardHeader/WizardHeader.types.ts
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,5 @@ | ||
export type WizardHeaderProps = { | ||
steps: string[]; | ||
setStep: (step: number) => void; | ||
currentStep: number; | ||
}; |
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 @@ | ||
export * from "./WizardHeader"; |
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,2 @@ | ||
export * from "./WizardButtons"; | ||
export * from "./WizardHeader"; |
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 @@ | ||
export * from "./Wizard"; |
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 @@ | ||
export * from "./Wizard"; |
Oops, something went wrong.