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(Labeled progress): allow consumers to pass additional label for progressbar #822

Merged
merged 1 commit into from
Oct 24, 2018

Conversation

karelhala
Copy link
Contributor

#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.

@coveralls
Copy link

coveralls commented Oct 20, 2018

Pull Request Test Coverage Report for Build 2796

  • 3 of 3 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 81.154%

Totals Coverage Status
Change from base Build 2792: 0.007%
Covered Lines: 3420
Relevant Lines: 3973

💛 - 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>
)}
Copy link
Member

@dlabrecq dlabrecq Oct 21, 2018

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?

screen shot 2018-10-16 at 12 49 51 pm

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.

Copy link
Contributor Author

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).

Copy link
Member

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.

Copy link
Contributor Author

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} />;

Copy link
Contributor

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.

Copy link
Contributor Author

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).

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://822-pr-patternfly-react-patternfly.surge.sh

dlabrecq
dlabrecq previously approved these changes Oct 22, 2018
<span className={css(styles.progressMeasure)}>{value}%</span>
<span className={css(progressMeasure, measureLocation === ProgressMeasureLocation.top && progressLabel)}>
{value}%
</span>
Copy link
Member

@dlabrecq dlabrecq Oct 22, 2018

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.

@patternfly-build
Copy link
Contributor

Deploy preview for patternfly-react-gone ready!

Built with commit 531592b

https://deploy-preview-822--patternfly-react-gone.netlify.com

dlabrecq
dlabrecq previously approved these changes Oct 23, 2018
Copy link
Member

@dlabrecq dlabrecq left a 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]),
Copy link
Collaborator

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

Suggested change
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. */
Copy link
Collaborator

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]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comments as above

Suggested change
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.number]),
label: PropTypes.node,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants