Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/animated-progress-item.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

ProgressBar: Add `animated` prop to `ProgressBar.Item` and a `'stripes'` animation for in-progress segments.
20 changes: 20 additions & 0 deletions packages/react/src/ProgressBar/ProgressBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
}
}

@keyframes stripes {
to {
background-position: 22.63px 0;
}
}

.ProgressBarItem {
/* these are passed from the component */
--progress-width: ;
Expand Down Expand Up @@ -43,6 +49,20 @@
animation-iteration-count: infinite;
}
}

&[data-animated='stripes'] {
position: relative;
overflow: hidden;

&::before {
position: absolute;
inset: 0;
content: '';
background-image: repeating-linear-gradient(45deg, rgb(255 255 255 / 25%) 0 8px, transparent 8px 16px);
background-size: 22.63px 22.63px;
animation: stripes 1s linear infinite;
}
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions packages/react/src/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ type ProgressProp = {
bg?: string
}

type Animated = boolean | 'stripes'

type StyledProgressContainerProps = {
inline?: boolean
barSize?: 'small' | 'default' | 'large'
animated?: boolean
animated?: Animated
}

export type ProgressBarItemProps = React.HTMLAttributes<HTMLSpanElement> & {
'aria-label'?: string
className?: string
animated?: Animated
} & ProgressProp

export const Item = forwardRef<HTMLSpanElement, ProgressBarItemProps>(
Expand All @@ -29,6 +32,7 @@ export const Item = forwardRef<HTMLSpanElement, ProgressBarItemProps>(
className,
style,
bg,
animated,
...rest
},
forwardRef,
Expand All @@ -55,6 +59,7 @@ export const Item = forwardRef<HTMLSpanElement, ProgressBarItemProps>(
return (
<span
data-component="ProgressBar.Item"
data-animated={animated}
className={clsx(className, classes.ProgressBarItem)}
{...rest}
role="progressbar"
Expand Down Expand Up @@ -113,7 +118,7 @@ export const ProgressBar = forwardRef<HTMLSpanElement, ProgressBarProps>(
children
) : (
<Item
data-animated={animated}
animated={animated}
progress={progress}
aria-label={ariaLabel}
aria-valuenow={ariaValueNow}
Expand Down
Loading