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

feat(react,styles): synced styles for progress bar and added thin variant #1309

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions docs/pages/components/ProgressBar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import { ProgressBar } from '@deque/cauldron-react'

## Examples

```jsx example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With multiple examples here, we probably want each example under a level 3 heading.

<ProgressBar
aria-label="Progress %"
progress={75}
thin
/>
```

```jsx example
<ProgressBar
aria-label="Progress %"
Expand Down Expand Up @@ -121,5 +129,11 @@ function ProgressExample() {
type: 'string',
description: 'A label for the ProgressBar is required. This means you must provide either an aria-label or aria-labelledby prop.'
},
{
name: 'thin',
type: 'boolean',
defaultValue: 'false',
description: 'Thinner visual style of icon button.'
}
]}
/>
11 changes: 9 additions & 2 deletions packages/react/src/components/ProgressBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ type ProgressBarProps = {
progress: number;
progressMax?: number;
progressMin?: number;
thin?: boolean;
} & Cauldron.LabelProps &
React.HTMLAttributes<HTMLDivElement>;

const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
({ progress = 0, progressMax = 100, progressMin = 0, ...props }, ref) => {
(
{ progress = 0, progressMax = 100, progressMin = 0, thin, ...props },
ref
) => {
const { className, ...otherProps } = props;
return (
<div
className={classnames('ProgressBar', className)}
className={classnames(className, {
ProgressBar: true,
'ProgressBar--thin': thin
})}
orest-s marked this conversation as resolved.
Show resolved Hide resolved
role="progressbar"
aria-valuemin={progressMin}
aria-valuemax={progressMax}
Expand Down
21 changes: 18 additions & 3 deletions packages/styles/progressbar.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
:root {
--progress-bar-background-color: var(--accent-dark);
--progress-bar-fill-color: var(--accent-info-light);
--progress-bar-background-color: var(--white);
--progress-bar-fill-color: var(--accent-primary);
--progress-bar-border-color: var(--gray-40);
--progress-bar-animation-timing: 150ms;
}

.ProgressBar {
background-color: var(--progress-bar-background-color);
padding: 2px;
padding: var(--space-half);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an instance where we don't really want spacing to scale with the global padding variable. The padding in this instance is acting like a border, which we do want to have a fixed size. Additionally, I think the padding is wrong here. The thin/normal variants have a 16px and 24px footprint respectively, so this appears to be 3px from the design.

border-radius: calc((var(--space-small) * 0.5) + 2px);
border: 1px solid var(--progress-bar-border-color);
margin-bottom: var(--space-smallest);
}

Expand All @@ -18,3 +20,16 @@
min-width: var(--space-small);
transition: width linear var(--progress-bar-animation-timing);
}

.ProgressBar--thin .ProgressBar--fill {
height: var(--space-smallest);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above comment. This should be a fixed size and not inheriting from --space-smallest.

}

.cauldron--theme-dark {
--progress-bar-background-color: var(--accent-dark);
--progress-bar-fill-color: var(--accent-info-light);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be immediately below :root.


.cauldron--theme-dark .ProgressBar {
border: none;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives the dark themed progress bar a different footprint. It would be better to update --progress-bar-border-color to match the background color for dark theme.

}