-
Notifications
You must be signed in to change notification settings - Fork 356
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(Labeled progress): allow consumers to pass additional label for progressbar #822
Conversation
Pull Request Test Coverage Report for Build 2796
💛 - Coveralls |
const StatusIcon = variantToIcon.hasOwnProperty(variant) && variantToIcon[variant]; | ||
return ( | ||
<Fragment> | ||
<div className={css(styles.progressDescription)} id={`${parentId}-description`}> | ||
{title} | ||
</div> | ||
<div className={css(styles.progressStatus)}> | ||
{/* TODO: add padding to label */} | ||
{label} | ||
{(measureLocation === ProgressMeasureLocation.top || measureLocation === ProgressMeasureLocation.outside) && ( | ||
<span className={css(styles.progressMeasure)}>{value}%</span> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking to wrap the percentage in parentheses like the snapshot below. It looks like I can only add text before it?
I'd prefer if the label was wrapped in the span so we get the same text style provided by progressMeasure. Perhaps we can use the value
by default, if label
has not been provided? I'm already providing the value
, so I can easily handle my own label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your example fits this as well, you'll just use measureLocation={ProgressMeasureLocation.none}
and pass your own label which will be whatever you'll want (string, node, number). If we'd were to force parentheses we'll be targeting only this specific example. But what if someone would want to show Already donwloaded: 50 %
? We'd have to have another branching here.
But you are correct that I should add styles applied to progress number on top of those custom styles (so label has some padding).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not asking to force parentheses. I just want the ability to provide my own label. If measureLocation, will hide it, that's fine. Just need the styling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this approach you'll be able to pass your own label. I think we don't understand each other on here. Check the example where you can pass whatever you want
<Progress value={33} title="Descriptive text here" label={<div>$106.30 (82.49%)</div>} measureLocation={ProgressMeasureLocation.none} />;
Or just plain old string
<Progress value={33} title="Descriptive text here" label="$106.30 (82.49%)" measureLocation={ProgressMeasureLocation.none} />;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karelhala I think he is more speaking to line 56 here since in addition to the label passed the component is also adding in <span className={css(styles.progressMeasure)}>{value}%</span>
that would make this:
<Progress value={33} title="Descriptive text here" label="$106.30 (82.49%)" />;
Output something like $106.30 (82.49%) 33%
from the looks of it.
Is there a way that we can have them just override the actual measure label? like David mentioned, default to the {value}%
, but user the one provided if there is one. Someone might want to override the label no matter the possition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh, that makes sence, I was kinda confused as to what custom label meant (since one was already there).
d0a886e
to
353ea44
Compare
PatternFly-React preview: https://822-pr-patternfly-react-patternfly.surge.sh |
353ea44
to
f50624a
Compare
<span className={css(styles.progressMeasure)}>{value}%</span> | ||
<span className={css(progressMeasure, measureLocation === ProgressMeasureLocation.top && progressLabel)}> | ||
{value}% | ||
</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still feel that the label should override the value / measureLocation. Having to also set ProgressMeasureLocation.none doesn't feel clean, but don't feel strongly about it.
f50624a
to
531592b
Compare
Deploy preview for patternfly-react-gone ready! Built with commit 531592b https://deploy-preview-822--patternfly-react-gone.netlify.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Now I can add my own label and still use measureLocation to place it in a desired location. Much better! Thanks
@@ -21,6 +21,8 @@ const propTypes = { | |||
variant: PropTypes.oneOf(Object.values(ProgressVariant)), | |||
/** Title above progress. */ | |||
title: PropTypes.string, | |||
/** Label to indicate what progress is shwoing. */ | |||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.number]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node includes string and number
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.number]), | |
label: PropTypes.node, |
@@ -21,6 +21,8 @@ const propTypes = { | |||
variant: PropTypes.oneOf(Object.values(ProgressVariant)), | |||
/** Title above progress. */ | |||
title: PropTypes.string, | |||
/** Label to indicate what progress is shwoing. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spelling of 'showing'
@@ -23,6 +28,8 @@ const propTypes = { | |||
parentId: PropTypes.string.isRequired, | |||
/** Progress title. */ | |||
title: PropTypes.string, | |||
/** Label to indicate what progress is shwoing. */ | |||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.number]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comments as above
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.number]), | |
label: PropTypes.node, |
531592b
to
34c11f1
Compare
#784
What:
To make it possible for consumers to show what indicates current progress we have to allow them pass additional label. This PR addresses such issue by adding new prop
label
to progress component.