Skip to content

Commit

Permalink
feat(progress-bar): add alignment variants (#10769)
Browse files Browse the repository at this point in the history
Co-authored-by: Abbey Hart <abbeyhrt@gmail.com>
Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 15, 2022
1 parent ee251fd commit e3f7edc
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/components/src/components/progress-bar/_progress-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@
background-position-x: -105%;
}
}

.#{$prefix}--progress-bar--inline {
display: flex;
align-items: center;
}

.#{$prefix}--progress-bar--inline .#{$prefix}--progress-bar__label {
flex-shrink: 0;
margin-right: $spacing-05;
margin-bottom: 0;
}

.#{$prefix}--progress-bar--inline .#{$prefix}--progress-bar__helper-text {
@include hidden;
}

.#{$prefix}--progress-bar--indented .#{$prefix}--progress-bar__label,
.#{$prefix}--progress-bar--indented .#{$prefix}--progress-bar__helper-text {
padding-right: $spacing-05;
padding-left: $spacing-05;
}
}

@include exports('progress-bar') {
Expand Down
10 changes: 10 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8718,6 +8718,16 @@ Map {
],
"type": "oneOf",
},
"type": Object {
"args": Array [
Array [
"default",
"inline",
"indented",
],
],
"type": "oneOf",
},
"value": Object {
"type": "number",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ const sizes = {
'Big (big) - default': 'big',
};

const types = {
'Default (default)': 'default',
'Inline (inline)': 'inline',
'indented (indented)': 'indented',
};

const props = () => ({
helperText: text('Helper text (helperText)', 'Optional helper text'),
hideLabel: boolean('Hide the label (hideLabel)', false),
label: text('Label text (label)', 'Progress bar label'),
max: number('Maximum value (max)', 100),
size: select('Size (size)', sizes, 'big'),
type: select('Type (type)', types, 'default'),
value: number('Current value (value)', 75),
});

Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/ProgressBar/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function ProgressBar({
label,
max = 100,
size = 'big',
type = 'default',
value,
}) {
const labelId = useId('progress-bar');
Expand All @@ -40,6 +41,7 @@ function ProgressBar({
const wrapperClasses = classNames(
`${prefix}--progress-bar`,
`${prefix}--progress-bar--${size}`,
`${prefix}--progress-bar--${type}`,
{
[`${prefix}--progress-bar--indeterminate`]: indeterminate,
},
Expand Down Expand Up @@ -108,6 +110,11 @@ ProgressBar.propTypes = {
*/
size: PropTypes.oneOf(['small', 'big']),

/**
* Defines the alignment variant of the progress bar.
*/
type: PropTypes.oneOf(['default', 'inline', 'indented']),

/**
* The current value.
*/
Expand Down
21 changes: 21 additions & 0 deletions packages/styles/scss/components/progress-bar/_progress-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@use '../../theme' as *;
@use '../../type' as *;
@use '../../utilities/convert' as *;
@use '../../utilities/visually-hidden' as *;

/// Progress Bar styles
/// @access public
Expand Down Expand Up @@ -87,4 +88,24 @@
background-position-x: -105%;
}
}

.#{$prefix}--progress-bar--inline {
display: flex;
align-items: center;
}

.#{$prefix}--progress-bar--inline .#{$prefix}--progress-bar__label {
flex-shrink: 0;
margin-bottom: 0;
margin-inline-end: $spacing-05;
}

.#{$prefix}--progress-bar--inline .#{$prefix}--progress-bar__helper-text {
@include visually-hidden;
}

.#{$prefix}--progress-bar--indented .#{$prefix}--progress-bar__label,
.#{$prefix}--progress-bar--indented .#{$prefix}--progress-bar__helper-text {
padding-inline: $spacing-05;
}
}

0 comments on commit e3f7edc

Please sign in to comment.