-
Notifications
You must be signed in to change notification settings - Fork 377
feat(Label): refactor for updated design and features #4165
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
Conversation
|
PF4 preview: https://patternfly-react-pr-4165.surge.sh |
| import { InfoCircleIcon } from '@patternfly/react-icons'; | ||
|
|
||
| SimpleLabel = () => ( | ||
| FilledLabels = () => ( |
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.
Rename to OutlinedLabels
| Blue removeable | ||
| </Label> <Label variant="outline" color="blue" icon={<InfoCircleIcon />} onClose={Function.prototype}> | ||
| Blue icon removeable | ||
| </Label> <Label variant="outline" color="blue" href="#"> |
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.
Would it make sense to set the hrefs to #filled or #outline for the link labels in both examples? At the moment when I click an outlined label with a link, it takes me back up to the top of the page.
redallen
left a comment
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.
Slight API change, DRY tests, and this looks good!
| /** Aria label of the close button. */ | ||
| closeBtnAriaLabel?: string; | ||
| /** Id of the close button. */ | ||
| closeBtnId?: 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.
I already know someone is going to want to customize the button they put in here... Can we just make the close button a React.ReactNode that the consumer can pass in, but has a default of:
<Button
type="button"
variant="plain"
onClick={onClose}
aria-label={'some-default'}
id={'some-default'}
aria-labelledby={`'some-default'`}
>
<TimesIcon />
</Button>if they pass onClose? It also cleans up having to support the closeBtnAriaLabel, closeBtnId, and closeBtnTextId props.
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'll add a node property for a full custom button, and will condense the various default button props into a general 'closeBtnProps' object. That way users can pass in whatever labelling/id they want without needing multiple props or to define a full 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.
Works for me!
packages/react-core/src/components/Label/__tests__/Label.test.tsx
Outdated
Show resolved
Hide resolved
|
CI is sad: |
|
I didn't change the documentation, so it has to be the change to the default button. Does it need an aria label maybe? |
|
@kmcfaul Yes, I think you need to set some default |
mcoker
left a comment
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.
Very nice!!
| onClose, | ||
| closeBtn, | ||
| closeBtnProps = { | ||
| 'aria-label': 'label-close-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.
Try:
closeBtnProps = {
'aria-label': 'label-close-button',
...closeBtnProps
}
or else when a consumer specifies just one property other than aria-label the aria-label won't be set. If that syntax doesn't work, on line 56 {...{'aria-label': 'label-close-button', ...closeBtnProps}} should.
redallen
left a comment
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.
LGTM! Thanks @kmcfaul !!
jenny-s51
left a comment
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.
Great work @kmcfaul!
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #3688
The
onCloseprop, if present, will add the close button to the label, and thehrefprop, if present, will change the to an element.Breaking changes