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(Button): consume Penta tokens and update examples #9934

Merged
merged 4 commits into from
Jan 16, 2024

Conversation

adamviktora
Copy link
Contributor

@adamviktora adamviktora commented Jan 4, 2024

What: Closes #9907

This is a followup to a core PR: patternfly/patternfly#6127

  • Breaking change: renamed isActive prop to isClicked, codemod issue followup: Button - Penta updates pf-codemods#546
  • introduced: hasNoPadding prop, stateful variant + state prop
  • updated examples to use Flex so buttons are not that tight next to each other

@adamviktora adamviktora requested review from a team, mcoker and tlabaj and removed request for a team January 4, 2024 15:43
@wise-king-sullyman wise-king-sullyman linked an issue Jan 4, 2024 that may be closed by this pull request
@adamviktora adamviktora added Breaking change 💥 this change requires a major release and has API changes. Penta labels Jan 4, 2024
@patternfly-build
Copy link
Contributor

patternfly-build commented Jan 4, 2024

@nicolethoen
Copy link
Contributor

can we open a code mod issue to track this breaking change?

@adamviktora
Copy link
Contributor Author

sure! codemod followup: patternfly/pf-codemods#546
we could keep the property name as isActive I think so we don't have that many codemods, but to be consistent with core, isClicked or clicked will be better

@jeff-phillips-18
Copy link
Member

we could keep the property name as isActive I think so we don't have that many codemods, but to be consistent with core, isClicked or clicked will be better

How is isClicked better? What is the modifier supposed to convey? I wouldn't think I would ever have to tell a button programmatically that it is clicked. isActive makes more sense to me if the intent is to show that the button is currently selected.

@mcoker
Copy link
Contributor

mcoker commented Jan 5, 2024

hey @jeff-phillips-18! With v6/penta, we introduced tokens (global vars) for colors and borders and stuff that we're currently calling "clicked" (you can see here, just look for --clicked) as a sort of catch-all for the variation of a token when something is selected, active, expanded/open, etc. This state in the button isn't terribly prescriptive, and could be used for any of those cases.

One issue with calling it "active" is we have modifiers classes for certain things to apply the hover/focus/active styling when the thing isn't actually hovered/focused/active. Eg, in a typeahead select, the text input in the toggle has actual focus, so when you're using the keyboard to navigate the open menu items, we apply .pf-m-focus to force the :focus styling on those items to mimic tabbing through menu items with actual browser focus. We're trying to reserve the active/focus/etc naming for when that prop/class represents that particular state, and are calling something "clicked" to represent the catch-all states.

Screenshot 2024-01-05 at 12 37 03 PM

Does that make sense or do you think we should reconsider anything? Naming things is hard, so your feedback is much appreciated!

/** Sets state of the stateful button variant. Default is "unread" */
state?: 'read' | 'unread' | 'attention';
/** Applies no padding on a plain button variant. Use when plain button is placed inline with text */
noPadding?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

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.

LGTM! 👍👍

Copy link
Collaborator

@andrew-ronaldson andrew-ronaldson left a comment

Choose a reason for hiding this comment

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

Approved! Good to have you back @adamviktora !

@jeff-phillips-18
Copy link
Member

Does that make sense or do you think we should reconsider anything? Naming things is hard, so your feedback is much appreciated!

I get it now. Naming is hard, clicked is as good as anything. Thanks for the explanation @mcoker

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Looks good! Just s few small comments

packages/react-core/src/components/Button/Button.tsx Outdated Show resolved Hide resolved
xtest('Renders with class pf-m-active when isActive = true', () => {
render(<Button isActive>Active Button</Button>);
expect(screen.getByRole('button')).toHaveClass('pf-m-active');
xtest('Renders with class pf-m-clicked when isClicked = true', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reenable this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, there will no longer be the isActive prop and the pf-m-active modifier in V6, it is renamed to isClicked. So I don't think we should reenable that test.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you modified it for the isClicked. Does the test fail? I that why it is still disabled?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have opened this issue #9989

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I did not realize that when it is marked as xtest and not test that it means the test is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix PR: #10013

Copy link
Collaborator

@lboehling lboehling left a comment

Choose a reason for hiding this comment

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

lgtm!

@adamviktora
Copy link
Contributor Author

adamviktora commented Jan 16, 2024

@mcoker I am noticing a slight difference in the border color of a stateful read button variant when applying the pf-m-clicked modifier vs actually clicking the button and thus applying :focus or :hover pseudo class.

Applying pf-m-clicked class:

--pf-v5-c-button--BorderColor: var(--pf-v5-c-button--m-clicked--BorderColor)
Screenshot 2024-01-16 at 10 37 48

Focus or hover:

--pf-v5-c-button--BorderColor: var(--pf-v5-c-button--hover--BorderColor)
Screenshot 2024-01-16 at 10 37 33

@mcoker
Copy link
Contributor

mcoker commented Jan 16, 2024

Hey @adamviktora, here is the design - it looks like that's intentional?

Screenshot 2024-01-16 at 2 13 18 PM

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM.

@tlabaj tlabaj merged commit d7a3b29 into patternfly:v6 Jan 16, 2024
13 checks passed
@tlabaj tlabaj mentioned this pull request Jan 16, 2024
@patternfly-build
Copy link
Contributor

Your changes have been released in:

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change 💥 this change requires a major release and has API changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Button): Consume Penta tokens
8 participants