Skip to content

Commit

Permalink
Merge 8d916c6 into dc80aa6
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Sep 20, 2024
2 parents dc80aa6 + 8d916c6 commit 03ce3ff
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-pets-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Adding default gap between sections for progressbars with more than one section
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: '2px';
${width}
${sx};
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`ProgressBar respects the "progress" prop 1`] = `
background-color: var(--borderColor-default,var(--color-border-default,#d0d7de));
border-radius: 3px;
height: 8px;
gap: '2px';
}
@media (prefers-reduced-motion:no-preference) {
Expand Down

0 comments on commit 03ce3ff

Please sign in to comment.