Skip to content

Commit

Permalink
Merge pull request #231 from DnD-Montreal/229-create-resizable-steppe…
Browse files Browse the repository at this point in the history
…r-atom-component

Add re-usable stepper form component
  • Loading branch information
willyyhuang authored Jan 6, 2022
2 parents 98f0d4f + 6e08289 commit a157cfc
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 232 deletions.
47 changes: 47 additions & 0 deletions resources/js/Components/Atom/StepperForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {Box, Step, StepLabel, Stepper} from '@mui/material'
import React, {ReactNode} from 'react'
import styled from 'styled-components'

type StepperFormPropType = {
stepTitles: string[]
stepContent: ReactNode[]
stepFooter: ReactNode[]
activeStep: number
isDrawer: boolean
}

const StyledBox = styled(Box)`
padding: 32px 0px 16px 0px;
width: 100%;
`

const FormBox = styled(Box)`
@media only screen and (max-width: 768px) {
width: 100vw;
}
margin-top: 16px;
width: ${(props) => (props.className === 'DrawerForm' ? '100%' : '65vw')};
`

const StepperForm = ({
activeStep,
stepTitles,
stepContent,
stepFooter,
isDrawer,
}: StepperFormPropType) => (
<FormBox className={isDrawer ? 'DrawerForm' : 'FormBox'}>
<Stepper activeStep={activeStep}>
{stepTitles.map((label: string) => (
<Step completed={activeStep > 0}>
<StepLabel>{label}</StepLabel>
</Step>
))}
</Stepper>
<StyledBox>{stepContent[activeStep]}</StyledBox>
{stepFooter[activeStep]}
</FormBox>
)

StepperForm.displayName = 'StepperForm'
export default StepperForm
1 change: 1 addition & 0 deletions resources/js/Components/Atom/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export {default as DataTable} from './DataTable'
export {default as Drawer} from './Drawer'
export {default as Link} from './Link'
export {default as StepperForm} from './StepperForm'
Loading

0 comments on commit a157cfc

Please sign in to comment.