-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ProgressBarStepped): create component (#905)
* first POC * update hack * update component logic, story, accesibility and tests * use skin color for progress bar stories * fix margin in container * update logic for ProgressBarStepped and Stepper
- Loading branch information
1 parent
484dbc7
commit 25ed4eb
Showing
13 changed files
with
197 additions
and
44 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
Binary file added
BIN
+222 Bytes
...napshots__/progress-bar-screenshot-test-tsx-progress-bar-color-error-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-212 Bytes
..._snapshots__/progress-bar-screenshot-test-tsx-progress-bar-color-red-1-snap.png
Binary file not shown.
Binary file added
BIN
+278 Bytes
.../progress-bar-screenshot-test-tsx-progress-bar-stepped-color-default-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+275 Bytes
...__/progress-bar-screenshot-test-tsx-progress-bar-stepped-color-error-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 +1,23 @@ | ||
import {openStoryPage, screen} from '../test-utils'; | ||
|
||
const COLORS = ['default', 'red']; | ||
const COLORS = ['default', 'error']; | ||
|
||
test.each(COLORS)('ProgressBar - color={%s}', async (color) => { | ||
await openStoryPage({id: 'components-progressbar--default', args: {color}}); | ||
await openStoryPage({id: 'components-progress-bar--progress-bar-story', args: {color}}); | ||
|
||
const stepper = await screen.findByTestId('progress-bar'); | ||
|
||
const image = await stepper.screenshot(); | ||
|
||
expect(image).toMatchImageSnapshot(); | ||
}); | ||
|
||
test.each(COLORS)('ProgressBarStepped - color={%s}', async (color) => { | ||
await openStoryPage({id: 'components-progress-bar--progress-bar-stepped-story', args: {color}}); | ||
|
||
const stepper = await screen.findByTestId('progress-bar-stepped'); | ||
|
||
const image = await stepper.screenshot(); | ||
|
||
expect(image).toMatchImageSnapshot(); | ||
}); |
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,66 @@ | ||
import * as React from 'react'; | ||
import {ProgressBar} from '..'; | ||
import {ProgressBar, ProgressBarStepped} from '..'; | ||
import {vars} from '../skins/skin-contract.css'; | ||
|
||
export default { | ||
title: 'Components/ProgressBar', | ||
title: 'Components/Progress bar', | ||
argTypes: { | ||
color: { | ||
options: ['default', 'red'], | ||
options: ['default', 'error'], | ||
control: {type: 'select'}, | ||
}, | ||
}, | ||
}; | ||
|
||
type Args = { | ||
type ProgressBarStoryArgs = { | ||
reverse: boolean; | ||
progressPercent: number; | ||
color: 'default' | 'red'; | ||
color: 'default' | 'error'; | ||
}; | ||
|
||
export const Default: StoryComponent<Args> = ({reverse, progressPercent, color}) => ( | ||
<div data-testid="progress-bar"> | ||
<ProgressBar | ||
progressPercent={progressPercent} | ||
reverse={reverse} | ||
color={color === 'default' ? undefined : color} | ||
/> | ||
</div> | ||
export const ProgressBarStory: StoryComponent<ProgressBarStoryArgs> = ({reverse, progressPercent, color}) => ( | ||
<ProgressBar | ||
dataAttributes={{testid: 'progress-bar'}} | ||
progressPercent={progressPercent} | ||
reverse={reverse} | ||
color={color === 'error' ? vars.colors.error : undefined} | ||
/> | ||
); | ||
|
||
Default.storyName = 'ProgressBar'; | ||
Default.args = { | ||
ProgressBarStory.storyName = 'ProgressBar'; | ||
ProgressBarStory.args = { | ||
reverse: false, | ||
progressPercent: 30, | ||
color: 'default', | ||
}; | ||
|
||
type ProgressBarSteppedStoryArgs = { | ||
steps: number; | ||
currentStep: number; | ||
color: 'default' | 'error'; | ||
}; | ||
|
||
export const ProgressBarSteppedStory: StoryComponent<ProgressBarSteppedStoryArgs> = ({ | ||
steps, | ||
currentStep, | ||
color, | ||
}) => ( | ||
<ProgressBarStepped | ||
steps={steps} | ||
currentStep={currentStep} | ||
dataAttributes={{testid: 'progress-bar-stepped'}} | ||
color={color === 'error' ? vars.colors.error : undefined} | ||
/> | ||
); | ||
|
||
ProgressBarSteppedStory.storyName = 'ProgressBarStepped'; | ||
ProgressBarSteppedStory.args = { | ||
steps: 4, | ||
currentStep: 3, | ||
color: 'default', | ||
}; | ||
ProgressBarSteppedStory.argTypes = { | ||
steps: { | ||
control: {type: 'range', min: 1, max: 6, step: 1}, | ||
}, | ||
}; |
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
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
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
25ed4eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for mistica-web ready!
✅ Preview
https://mistica-2zn0ek1q4-tuentisre.vercel.app
Built with commit 25ed4eb.
This pull request is being automatically deployed with vercel-action