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(progress-bar): add "small" size variant #10708

Merged
merged 4 commits into from
Feb 18, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
background-color: $layer;
}

.#{$prefix}--progress-bar--big .#{$prefix}--progress-bar__track {
height: rem(8px);
}

.#{$prefix}--progress-bar--small .#{$prefix}--progress-bar__track {
height: rem(4px);
}

.#{$prefix}--progress-bar__bar {
display: block;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8456,6 +8456,15 @@ Map {
"max": Object {
"type": "number",
},
"size": Object {
"args": Array [
Array [
"small",
"big",
],
],
"type": "oneOf",
},
"value": Object {
"type": "number",
},
Expand Down
18 changes: 15 additions & 3 deletions packages/react/src/components/ProgressBar/ProgressBar-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@

import React, { useState, useEffect } from 'react';

import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';
import {
withKnobs,
text,
boolean,
number,
select,
} from '@storybook/addon-knobs';
import ProgressBar from '../ProgressBar';

const sizes = {
'Small (small)': 'small',
'Big (big) - default': 'big',
};

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

export default {
Expand Down
9 changes: 8 additions & 1 deletion packages/react/src/components/ProgressBar/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ const { prefix } = settings;

function ProgressBar({
className,
helperText,
hideLabel,
label,
max = 100,
size = 'big',
value,
helperText,
}) {
const labelId = useId('progress-bar');
const helperId = useId('progress-bar-helper');
Expand All @@ -38,6 +39,7 @@ function ProgressBar({

const wrapperClasses = classNames(
`${prefix}--progress-bar`,
`${prefix}--progress-bar--${size}`,
{
[`${prefix}--progress-bar--indeterminate`]: indeterminate,
},
Expand Down Expand Up @@ -101,6 +103,11 @@ ProgressBar.propTypes = {
*/
max: PropTypes.number,

/**
* Specify the size of the ProgressBar.
*/
size: PropTypes.oneOf(['small', 'big']),

/**
* The current value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
background-color: $layer;
}

.#{$prefix}--progress-bar--big .#{$prefix}--progress-bar__track {
height: rem(8px);
}

.#{$prefix}--progress-bar--small .#{$prefix}--progress-bar__track {
height: rem(4px);
}

.#{$prefix}--progress-bar__bar {
display: block;
width: 100%;
Expand Down