Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WV-380 create controls that can show all of the display states for how it works wizard [MERGE READY] #3988

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"@mui/styled-engine-sc": "^5.10.1",
"@mui/styles": "^5.15.20",
"@openreplay/tracker": "^8.1.1",
"@storybook/addon-actions": "^7.6.20",
"@stripe/react-stripe-js": "^1.3.0",
"@stripe/stripe-js": "^1.13.0",
"classnames": "^2.3.1",
Expand Down
26 changes: 12 additions & 14 deletions src/js/common/stories/HowItWorksWizard.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { useEffect, useState } from 'react';
import { action } from '@storybook/addon-actions';
import styled from 'styled-components';
import HowItWorks from '../../components/CompleteYourProfile/HowItWorksWizard';
import { action } from '@storybook/addon-actions';

// WV-380: Created controls for the HowItWorks component allowing steps object to be modified,
// multi-check on activeSteps,
// and completed status to be toggled true/false.

const initialSteps = [
{
Expand Down Expand Up @@ -36,8 +40,6 @@ const initialSteps = [
},
];

// const activeStep = 1;

export default {
title: 'Design System/CompleteYourProfile',
component: HowItWorks,
Expand All @@ -47,13 +49,9 @@ export default {
argTypes: {
activeStep: {
control: { type: 'check' },
options: initialSteps.map(step => step.id),
options: initialSteps.map((step) => step.id),
description: 'Select which steps are active',
},
completed: {
control: { type: 'boolean' },
description: 'Toggle the completed status',
},
steps: {
control: 'object',
description: 'Modify the steps',
Expand All @@ -80,18 +78,18 @@ const Container = styled.div`
export const HowItWorksWizard = (args) => {
const [steps, setSteps] = useState(args.steps);
useEffect(() => {
setSteps(steps.map(step => ({
setSteps((prevSteps) => prevSteps.map((step) => ({
...step,
completed: args.completed && args.activeStep.includes(step.id),
completed: true && args.activeStep.includes(step.id),
})));
action(`Active Step Changed to: ${args.activeStep}`)();
}, [args.activeStep]);


const handleStepToggle = (index) => {
const updatedSteps = steps.map((step, i) =>
const updatedSteps = steps.map((step, i) => (
i === index ? { ...step, completed: !step.completed } : step
);
));
setSteps(updatedSteps);
action(`Step ${index + 1} Clicked - Completed: ${updatedSteps[index].completed}`)();
};
Expand All @@ -102,13 +100,13 @@ export const HowItWorksWizard = (args) => {
...step,
onClick: () => handleStepToggle(i),
}))}
activeStep={args.activeStep}/>
activeStep={args.activeStep}
/>
</Container>
);
};

HowItWorksWizard.args = {
steps: initialSteps,
activeStep: [1],
completed: false,
};
Loading