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

fix: expand progress component #405

Merged
merged 4 commits into from
Nov 25, 2021
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions src/components/Progress/Progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ import {
ProgressSeparatorTag,
ProgressTextTag,
ProgressLabelTag,
ProgressDescriptionTag,
} from './Progress.theme';

type ProgressProps = {
value: number,
label?: string,
label?: string | React$Node,
valueText?: React$Node,
description?: React$Node,
valueWidth?: number | string,
size?: 'sm' | 'md' | 'lg',
size?: 'xs' | 'sm' | 'md' | 'lg',
color?: string,
backgroundColor?: string,
showSeparator?: boolean,
Expand All @@ -28,6 +30,7 @@ const Progress = ({
label,
valueText,
valueWidth,
description,
...rest
}: ProgressProps) => {
value = value > 100 ? value % 100 : value;
Expand All @@ -46,6 +49,7 @@ const Progress = ({
{ valueText ? valueText : `${value} %` }
</ProgressTextTag>
</ProgressBodyTag>
{ description && <ProgressDescriptionTag> { description } </ProgressDescriptionTag> }
</ProgressTag>
);
};
Expand Down
23 changes: 23 additions & 0 deletions src/components/Progress/Progress.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ export const common = () => (
backgroundColor="GREEN_30"
/>
<br />
<Progress
size="xs"
valueWidth="25%"
label={ (
<div>
<span style={{ fontWeight: 600 }} >Developers and Administrator Accounts</span>
</div>
) }
description={ (
<div>
+$40/mo per additional member
</div>
) }
valueText={ (
<div>
8 / 6
</div>
) }
value={ (100 * 8) / 6 }
showSeparator
backgroundColor="RED_30"
/>
<br />
</Column>
);

Expand Down
11 changes: 11 additions & 0 deletions src/components/Progress/Progress.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ const [ProgressBodyTag, themeBody] = createThemeTag(`${name}Body`, {
});

const HEIGHT_BY_SIZE = {
xs: 4,
sm: 8,
md: 12,
lg: 16,
};

const HEIGHT_SEPARATOR_BY_SIZE = {
xs: 8,
sm: 12,
md: 18,
lg: 20,
};

const BORDER_RADIUS_BY_SIZE = {
xs: 4,
sm: 4,
md: 8,
lg: 12,
Expand Down Expand Up @@ -87,6 +90,12 @@ const [ProgressLabelTag, themeLabel] = createThemeTag(`${name}Label`, ({ FONTS }
},
}));

const [ProgressDescriptionTag, themeDescription] = createThemeTag(`${name}Description`, ({ FONTS }: *) => ({
root: {
...FONTS.BODY_3,
},
}));

const theme = {
...themeProgress,
...themeBody,
Expand All @@ -95,6 +104,7 @@ const theme = {
...themeSeparator,
...themeText,
...themeLabel,
...themeDescription,
};

export {
Expand All @@ -106,4 +116,5 @@ export {
ProgressSeparatorTag,
ProgressTextTag,
ProgressLabelTag,
ProgressDescriptionTag,
};