Enhance WizardView component by adding sideBar and submitText props for improved customization; refactor layout for better responsiveness and structure.

This commit is contained in:
Tom Butcher 2025-09-05 23:19:32 +01:00
parent c7ddcd36e3
commit 45d9aabb87

View File

@ -12,7 +12,9 @@ const WizardView = ({
title = 'Wizard View', title = 'Wizard View',
onSubmit, onSubmit,
formValid, formValid,
loading loading,
sideBar = null,
submitText = 'Done'
}) => { }) => {
const [currentStep, setCurrentStep] = useState(0) const [currentStep, setCurrentStep] = useState(0)
const isMobile = useMediaQuery({ maxWidth: 768 }) const isMobile = useMediaQuery({ maxWidth: 768 })
@ -20,6 +22,9 @@ const WizardView = ({
return ( return (
<Flex gap='middle'> <Flex gap='middle'>
{!isMobile && showSteps == true ? ( {!isMobile && showSteps == true ? (
sideBar != null ? (
sideBar
) : (
<div style={{ minWidth: '160px' }}> <div style={{ minWidth: '160px' }}>
<Steps <Steps
current={currentStep} current={currentStep}
@ -28,19 +33,22 @@ const WizardView = ({
style={{ width: 'fit-content' }} style={{ width: 'fit-content' }}
/> />
</div> </div>
)
) : null} ) : null}
{!isMobile && showSteps == true ? ( {!isMobile && showSteps == true ? (
<Divider type='vertical' style={{ height: 'unset' }} /> <Divider type='vertical' style={{ height: 'unset' }} />
) : null} ) : null}
<Flex vertical justify='space-between' gap={'middle'}>
<Flex vertical gap='middle' style={{ flexGrow: 1 }}> <Flex vertical gap='middle' style={{ flexGrow: 1 }}>
<Title level={2} style={{ margin: 0 }}> <Title level={2} style={{ margin: 0 }}>
{title} {title}
</Title> </Title>
<div style={{ minHeight: '260px', marginBottom: 8 }}> <div style={{ minHeight: '260px', marginBottom: 4 }}>
{steps[currentStep].content} {steps[currentStep].content}
</div> </div>
</Flex>
<NewObjectButtons <NewObjectButtons
currentStep={currentStep} currentStep={currentStep}
totalSteps={steps.length} totalSteps={steps.length}
@ -49,6 +57,7 @@ const WizardView = ({
onSubmit={onSubmit} onSubmit={onSubmit}
formValid={formValid} formValid={formValid}
submitLoading={loading} submitLoading={loading}
submitText={submitText}
/> />
</Flex> </Flex>
</Flex> </Flex>
@ -61,7 +70,9 @@ WizardView.propTypes = {
steps: PropTypes.array.isRequired, steps: PropTypes.array.isRequired,
showSteps: PropTypes.bool, showSteps: PropTypes.bool,
title: PropTypes.string, title: PropTypes.string,
loading: PropTypes.bool loading: PropTypes.bool,
sideBar: PropTypes.node,
submitText: PropTypes.string
} }
export default WizardView export default WizardView