8000 feat(button): add animation for hover and clicked by srambach · Pull Request #6675 · patternfly/patternfly · GitHub
[go: up one dir, main page]

Skip to content

feat(button): add animation for hover and clicked#6675

Merged
mcoker merged 7 commits intopatternfly:v6from
srambach:6516-motion-tokens-and-more
May 31, 2024
Merged

feat(button): add animation for hover and clicked#6675
mcoker merged 7 commits intopatternfly:v6from
srambach:6516-motion-tokens-and-more

Conversation

@srambach
Copy link
Member

@patternfly-build
Copy link
Collaborator
patternfly-build commented May 20, 2024

@srambach
Copy link
Member Author

@andrew-ronaldson should this same animation also be on menu toggles?

@andrew-ronaldson
Copy link
Collaborator

@andrew-ronaldson should this same animation also be on menu toggles?

Yes I think so.

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.

sweet moves, ace!

Comment on lines +304 to +306
transition-timing-function: var(--#{$button}--TransitionTimingFunction);
transition-duration: var(--#{$button}--TransitionDuration);
transition-property: background-color;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nit and you may know this but the shorthand version would be

transition: background-color var(--#{$button}--TransitionDuration) var(--#{$button}--TransitionTimingFunction);

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the property isn't a variable I wasn't sure if the shorthand version was advisable or not? I can change it if you think it's better.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mcoker I realized color needed to be transformed as well, so I left this as is since the shorthand doesn't take multiple properties (unless we use all)

Copy link
@kaylachumley kaylachumley 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
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! Left a few nit comments.

Also maybe this question has already been asked or is obvious, but in figma the annotations say "on button click...". Just want to point out that for the button, we have "clicked" styles for the .pf-m-clicked variation, but that might be different from just clicking on a button. The .pf-m-clicked variation is for something like a button that's used to open a drawer. We'll apply the clicked variation to indicate that the drawer is expanded, and remove it when the drawer is closed. Just plain ol' clicking on a button triggers something called :active, which happens when you hold down your mouse button (or whatever pointer device or the enter/space key on the keyboard). Here's a codepen showing an :active transition - https://codepen.io/mcoker/pen/WNBROpE. I don't know that it means anything in terms of this PR, since the hover/focus and clicked transitions are all the same, but wanted to make sure we were referring to the same thing.

Comment on lines +26 to +27
--#{$button}--hover--TransitionDuration: var(--pf-t--global--motion--duration--fade--default);
--#{$button}--hover--TransitionTimingFunction: var(--pf-t--global--motion--timing-function--default);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need hover (and clicked) vars? If the goal is just to smooth out the background/border/text color changes that happen as either the user interacts with the button, or the button changes states programmatically, it seems like a base transition for those properties should be good enough, and whatever state changes happen will all get that change.

Comment on lines +316 to +318
transition-timing-function: var(--#{$button}--TransitionTimingFunction);
transition-duration: var(--#{$button}--TransitionDuration);
transition-property: border-color, border-width, color;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't declare anything in content for ::after, so I don't think you need color here.

And since it's ::after and the vars used are the same as the parent, assuming you'd just add border-color, border-width to .#{$button}'s transition-property if these styles existed on that selector, I might write it this way - no downsides that I can think of?

Suggested change
transition-timing-function: var(--#{$button}--TransitionTimingFunction);
transition-duration: var(--#{$button}--TransitionDuration);
transition-property: border-color, border-width, color;
transition: inherit; // inherits everything
transition-property: border-color, border-width; // changes transition-property

An aside, color isn't showing up in the preview for some reason, but it's there locally when I pull down your branch, so I'm assuming it's just a surge glitch 🤷‍♂️

@mcoker
Copy link
Contributor
mcoker commented May 30, 2024

Oh I meant to leave one more comment. In terms of allowing users to theme/customize the button animations, I think this PR is good, but it looks to assume the following which I just wanted to confirm is 👍👍

  • The properties to transition (text color, background color, border color, border width) are not intended to be themed since we don't have a var for transition-property.
  • The timing function and duration can be themed, but it's a single timing function and a single duration and it applies to all of the properties listed above. For example, we don't intend for background color and border width to have different timing functions or durations.

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.

Looks good! Just one question 👍

Comment on lines +312 to +313
transition-timing-function: inherit;
transition-duration: inherit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm - since the initial value of transition-property is "all", leaving that out here will set that. Was that intended? If not, transition: inherit; should do the trick.

Copy link
Member Author

Choose a reason for hiding this comment

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

eh, not really 😄 I'll fix it.

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.

🚀

@mcoker mcoker merged commit 6584f8b into patternfly:v6 May 31, 2024
@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.0.0-alpha.146 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buttons - Animating transitions on all buttons variants.

5 participants

0