Skip to content

Conversation

@kmcfaul
Copy link
Contributor

@kmcfaul kmcfaul commented May 1, 2020

What: Closes #3688

The onClose prop, if present, will add the close button to the label, and the href prop, if present, will change the to an element.

Breaking changes

  1. Default color changed to grey. Design also adjusted.

@patternfly-build
Copy link
Collaborator

patternfly-build commented May 1, 2020

import { InfoCircleIcon } from '@patternfly/react-icons';

SimpleLabel = () => (
FilledLabels = () => (
Copy link
Contributor

@jenny-s51 jenny-s51 May 1, 2020

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="#">
Copy link
Contributor

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.

Copy link
Contributor

@redallen redallen left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Works for me!

@redallen
Copy link
Contributor

redallen commented May 6, 2020

CI is sad:

http://localhost:9000/documentation/react/components/label/filled
@patternfly/react-docs: ================= Violations =================
@patternfly/react-docs: {
@patternfly/react-docs:   "data": "",
@patternfly/react-docs:   "id": "button-has-visible-text",
@patternfly/react-docs:   "impact": "critical",
@patternfly/react-docs:   "message": "Element does not have inner text that is visible to screen readers",
@patternfly/react-docs:   "relatedNodes": [
@patternfly/react-docs:     {
@patternfly/react-docs:       "html": "<button class=\"pf-c-button pf-m-plain\" type=\"button\" data-ouia-component-type=\"PF4/Button\" data-ouia-safe=\"true\">"
@patternfly/react-docs:     }
@patternfly/react-docs:   ]
@patternfly/react-docs: }

@kmcfaul
Copy link
Contributor Author

kmcfaul commented May 6, 2020

I didn't change the documentation, so it has to be the change to the default button. Does it need an aria label maybe?

@redallen
Copy link
Contributor

redallen commented May 6, 2020

@kmcfaul Yes, I think you need to set some default closeBtnProps

@tlabaj tlabaj requested a review from mcoker May 6, 2020 20:02
Copy link
Contributor

@mcoker mcoker left a 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'
Copy link
Contributor

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.

Copy link
Contributor

@redallen redallen left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @kmcfaul !!

Copy link
Contributor

@jenny-s51 jenny-s51 left a comment

Choose a reason for hiding this comment

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

Great work @kmcfaul!

@redallen redallen merged commit 5b50d2e into patternfly:v4 May 7, 2020
@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@4.2.23
  • @patternfly/react-core@4.11.0
  • @patternfly/react-docs@5.2.27
  • @patternfly/react-inline-edit-extension@4.3.23
  • demo-app-ts@4.8.0
  • @patternfly/react-integration@4.8.0
  • @patternfly/react-table@4.3.23
  • @patternfly/react-topology@4.2.23
  • @patternfly/react-virtualized-extension@4.2.23

Thanks for your contribution! 🎉

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.

Label: updates to support new design

6 participants