-
Notifications
You must be signed in to change notification settings - Fork 358
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(CompoundLabel) Add CompoundLabel component #464
feat(CompoundLabel) Add CompoundLabel component #464
Conversation
30bc880
to
a6ea70f
Compare
Looks great! This is what I imagined, great job! 🎉🎉🎉 Interested in hearing what others think about it! |
@@ -0,0 +1,42 @@ | |||
@import 'patternfly/variables'; |
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.
It is assumed that this is already imported (for any of our less files to work).
@@ -0,0 +1,42 @@ | |||
@import 'patternfly/variables'; | |||
|
|||
.pf-remove-button { |
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.
These selectors should have a compound-label-pf
or similar prefix so as not to mistakenly override.
<Tooltip id="tooltip">{this.props.category.label}</Tooltip> | ||
); | ||
return ( | ||
<ul className="category list-inline"> |
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.
We should allow callers to add a className
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.
Do we want to pass along any other props?
|
||
.category.list-inline { | ||
background-color: $color-pf-blue-500; | ||
padding: 3px 10px 3px 15px !important; |
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.
Shouldn't need the !important
<ul className="category list-inline"> | ||
<OverlayTrigger placement="bottom" overlay={categoryTooltip}> | ||
<div className="category-label"> | ||
{this.props.categoryTruncate(this.props.category.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.
Do we need to use the truncate function? Could we use a max-width and text-overflow instead?
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 think having truncate function is more flexible and if tooltip should be shown only when text is truncated as @mcarrano suggests, I think it will be easier to implement if I stick to truncate function.
|
||
CompoundLabel.propTypes = { | ||
category: PropTypes.shape({ | ||
id: PropTypes.any.isRequired, |
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.
Please add comments so the descriptions show up in storybook.
|
||
render() { | ||
const values = [...this.props.values]; | ||
if (values.length === 0) return <div />; |
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.
return null would be better.
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.
any reason to return an empty div?
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.
No, sorry, I missed this comment, null will be better
</div> | ||
) | ||
}) | ||
); |
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.
Looks like the storybook was built before this was set correctly.
In general, I think this looks good. I'm still not sure that we need tooltips on a label if it is not truncated. What do you think @terezanovotna . The only other issue I see is that there appears to be a difference in the spacing of the internal chip with it's container (i.e. top and bottom margin not equal). Would be good to get some visual design input here. |
Thanks for the feedback @mcarrano. When the compound label is not truncated, I don't think we need a tooltip. Can we do that @PanSpagetka ? @kbaker Could you take a look on the storybook? Wondering what your visual perspective feedback is. |
I don't know of any other instances where we show a tooltip only when the text is truncated. |
@jeff-phillips-18 thanks for review, I hope your concern are resolved in second commit. Except truncate function, which I would rather leave as it is. |
Hi @PanSpagetka, Looks like the title in the Storybook should be 'Compound Label": |
Thanks for adding this! I thought I had included this link in issue #401 but I failed to paste the correct link (I fixed it now): This is a codepen that I had worked on, which reuses much of the styles for the current label component, with a few minor CSS updates to extend it for this component. Let me know if you think this is usable for this component or if you have any questions about this. |
oh, fyi, @kybaker is out this week. It would be good to get his input on styles for this. |
@dtaylor113 Yep, I agree, when it is in too narrow window, it looks bad. But I think when there are long labels in narrow space it would always feel bad. But if you think that inner sub-labels should wrap same as outer label, it could be done. Multiple Or more labels next to each other like this: @jgiardino Thanks, I think styles I am using now are good (maybe except issues with narrow resolutions) but if you agree that |
@PanSpagetka
I'm definitely open to suggestions on this. I also haven't fully tested the codepen above based on @dtaylor113's comments, so it's possible that it would need adjustments anyway. I was mainly testing what our options are for reusing existing classes and styles. Also, it might be nice to allow the background color to be defined using props. The examples included in the design doc included above are different than what I see on patternfly.org. Maybe allowing the class names (e.g. |
Hi @PanSpagetka, wondering what the status of the PR is? I'm looking to use the |
@dtaylor113 I have updated PR and storybook. State should be following:
But if it is enough to be merged, I have no idea... |
9b230b5
to
8a9cc60
Compare
Pull Request Test Coverage Report for Build 1911
💛 - Coveralls |
@patternfly/patternfly-react-ux Could someone self-assign and do a UX review please? |
I agree with @jgiardino 's comments / codepen above. It would be great if we could go that route and keep styling changes to a minimum. |
I can change styles for that @jgiardino posted but first I would like to be sure, that this is really what you want. Because some time ago, I received visual design review here and tried to change styling according to that. But if you are sure, that this component should use styling proposed by @jgiardino it will use them. I just want to finish this and I really appreciate any advice which make it happened. |
Thanks for sharing the feedback you received for this! I didn't realize there was a separate UI review outside of this repo. The visual styling that I was trying to follow are the styles shown in the design document for Filters. My thinking was that this component should be general enough that it could be used for Filters as well as other use cases like the one in ManageIQ. I'd still love for that to be the goal for this PR, but I also understand needing to finish this up. And after reading the comments from the ManageIQ design review, the example I posted might require some updates to be able to accommodate things like the different font sizes that were requested. Ideally, it would be great if the component allowed these customizations:
But I feel like this could be a LOT of work at this time. And I'm also curious whether what I describe is even what our ultimate goal should be, and if so, is there a way that we can split this work out that makes sense. @jeff-phillips-18 and @mcarrano, do you have any recommendations on how to move forward with this? |
@jgiardino you can customize both, outer and inner component by passing them CSS classes using The only problem is the color scheme proposed here is following: outer component has I came up with three possible solutions:
I think each of these solution shouldn't take too much to to implement. |
FYI those color recommendations that I provided in the other PR were from Jenny. @jgiardino, if you think these conflict, we can change as needed |
I had a chat with @jeff-phillips-18, @mcarrano, and @kybaker The conclusion regarding visual styling was to keep the color scheme the way Jenny suggested. (And to also update the filters design document to reuse the same color scheme.) Also, @kybaker had suggested that the spacing be updated to make the left/right edges more even with the spacing at the top/bottom edges, but I think a designer should confirm whether that update makes sense for the ManageIQ use case before making that change here. For the css class names that are added, we do ask that “-pf” is added somewhere in the name. For the html structure, I would expect an html structure to present the entire compound label as a list item, with the list of values presented as a nested list inside that list item, similar to what is shown in this codepen. To be semantically accurate, I wouldn’t define the category label as a list item the way it is now, it’s really the label for the list of values. Additionally, there will be updates needed to be able to use this component for Filters, based on quick testing I did using dev tools in the browser. But I realize that these last two items can be significant undertakings. Aside from the css class names, I’m open to pushing further updates off to a later PR, assuming that we can update the html structure later without making breaking changes to the component. I’m guessing if the component name and properties are the same, then changes to the html tags are fine? @jeff-phillips-18 Please weigh in with your thoughts on this one. |
Agreed, the html structure could change in a future PR as long as we can keep the public interface from changing. I was thinking |
6d7c0bb
to
c7f0ef8
Compare
@jgiardino @jeff-phillips-18 Thank you for your feedback! Ehm, I already made html changes and tried to use your css with some changes, to make it look similar. I think it does make sense to outer label be also bold, when inner labels are bold. But I could revert these changes if needed. I have added "-pf" postfix to first level css classes, but not to the nested ones, I think this should be ok? |
Once the |
Thanks for updating the html structure. The way you handled the css class names looks correct to me. I'll let one of the designers comment on the expectations regarding what should be bold or not for the ManageIQ use case. (@terezanovotna are you the right designer to weigh in on this one?) As for the use case of reusing this component for Filters, I'm assuming we can handle any further changes for that use case in a separate PR (e.g. like add a prop that will alter the visual styling when using as assigned tags vs filters). As for css, I think the only change you need to make is to remove the |
@jgiardino Thanks, yep, it works. I have also deleted duplicate |
@PanSpagetka can you add 5px margin to the left from "x"? At this moment it seems very close to the text. |
@terezanovotna - I'd consider this change to be out of scope for this PR. The spacing for the X is based on the Label component css. If we change that, the change should be introduced in the pf core css repo, and not here.
|
In that case LGTM! @miq-bot remove_label ux/review We have a call about compound label pattern tomorrow, so if anything changes, I'll keep you updated @PanSpagetka |
truncate: PropTypes.func.isRequired, | ||
className: PropTypes.string, | ||
bsStyle: PropTypes.string | ||
}; |
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.
please add comments so descriptions show in storybook
className | ||
}) => ( | ||
<li key={value.id}> | ||
<OverlayTrigger placement="bottom" overlay={tooltip(value.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.
the placement setting should be overridable via properties.
); | ||
return ( | ||
<span className="label label-primary compound-label-pf"> | ||
<OverlayTrigger placement="bottom" overlay={categoryTooltip}> |
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.
the placement setting should be overridable via properties.
truncate={this.props.valueTruncate} | ||
bsStyle={this.props.bsStyle} | ||
className={this.props.innerClassName} | ||
/> |
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.
pass along overlay trigger placement here.
@jeff-phillips-18 I hope I have fixed issues you have mention. |
733e5ac
to
8562a16
Compare
In this PR I am creating component for showing
key:values
pair with delete capability. It can be used for filters or taggingIssue
#401
Google design doc
https://docs.google.com/document/d/19Vu9Q_lfCQDkwO3LQuwsImSH0rH9i0o9AF24Uer6WqA/edit
Storybook
https://panspagetka.github.io/patternfly-react/?selectedKind=patternfly-react%2FWidgets%2FLabel&selectedStory=CompoundLabel&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybooks%2Fstorybook-addon-knobs
@terezanovotna