Skip to content

Commit

Permalink
Merge 3f6627c into dc80aa6
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Sep 20, 2024
2 parents dc80aa6 + 3f6627c commit 3bd6f99
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 26 additions & 5 deletions packages/react/src/ProgressBar/ProgressBar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react'
import type {Meta, StoryFn} from '@storybook/react'
import {ProgressBar} from '..'
import type {Meta} from '@storybook/react'
import {ProgressBar, type ProgressBarProps} from '..'

const sectionColors = ['success.emphasis', 'done.emphasis', 'severe.emphasis', 'danger.emphasis', 'attention.emphasis']

export default {
title: 'Components/ProgressBar',
Expand All @@ -9,15 +11,26 @@ export default {

export const Default = () => <ProgressBar aria-label="Upload test.png" />

export const Playground: StoryFn<typeof ProgressBar> = args => (
<ProgressBar {...args} sx={args.inline ? {width: '100px'} : {}} aria-label="Upload test.png" />
)
export const Playground = ({sections, ...args}: ProgressBarProps & {sections: number}) => {
if (sections === 1) {
return <ProgressBar {...args} sx={args.inline ? {width: '100px'} : {}} aria-label="Upload test.png" />
} else {
return (
<ProgressBar aria-label="Upload test.png">
{[...Array(sections).keys()].map(i => (
<ProgressBar.Item key={i} progress={100 / sections} sx={{bg: sectionColors[i]}} />
))}
</ProgressBar>
)
}
}

Playground.args = {
progress: 66,
barSize: 'default',
inline: false,
bg: 'success.emphasis',
sections: 1,
}

Playground.argTypes = {
Expand All @@ -37,4 +50,12 @@ Playground.argTypes = {
type: 'boolean',
},
},
sections: {
control: {
type: 'number',
min: 1,
max: 5,
step: 1,
},
},
}
2 changes: 1 addition & 1 deletion packages/react/src/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ProgressContainer = styled.span<StyledProgressContainerProps>`
background-color: ${get('colors.border.default')};
border-radius: ${get('radii.1')};
height: ${props => sizeMap[props.barSize || 'default']};
gap: ${props => (props.children ? '2px' : '0')};
${width}
${sx};
`
Expand Down

0 comments on commit 3bd6f99

Please sign in to comment.