Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Buttons need hover, active, and focus states #99

Closed
jffng opened this issue Oct 13, 2021 · 6 comments · Fixed by #275
Closed

Buttons need hover, active, and focus states #99

jffng opened this issue Oct 13, 2021 · 6 comments · Fixed by #275

Comments

@jffng
Copy link
Collaborator

jffng commented Oct 13, 2021

Describe the bug
Currently the buttons do not have hover, active, or focus states. Also it looks like their font weight is incorrect.

Screenshots

Current Desired
Screen Shot 2021-10-13 at 9 16 06 AM Screen Shot 2021-10-13 at 9 15 27 AM
@jffng jffng added the [Type] Bug Something isn't working label Oct 13, 2021
@jffng jffng added this to the Feature Freeze milestone Oct 13, 2021
@jffng jffng added [Component] Blocks and removed [Type] Bug Something isn't working labels Oct 13, 2021
@jffng
Copy link
Collaborator Author

jffng commented Oct 13, 2021

Related upstream issue: WordPress/gutenberg#27075

@jffng jffng linked a pull request Oct 25, 2021 that will close this issue
@jffng
Copy link
Collaborator Author

jffng commented Oct 26, 2021

I started working on this a bit in the theme, and it helped to outline the considerations.

Use cases to consider

  • User adjusts padding at the global level
  • User adjusts padding at the block level
  • User adjusts colors
  • User selects the outline button style

Challenges

  • The design uses a border in its hover state. We want to maintain consistent visual spacing between hover and resting states, i.e. the dimensions of the button shouldn't change between hover / resting. Ideally the default size of the button is the same between non-outline and outline buttons too. To do this, we need to calculate the padding value since it is different in hover vs resting state, and it depends on the border width.
  • Global styles supplies padding values in-line when they are block-level customizations, but the styles are compiled into the .wp-block-button__link class when they are global customizations. Theme provided CSS is loaded after these customizations, making creating the right level of CSS specificity a challenge if we want to provide a default and allow for the user to make global customizations to the button padding. See Global Styles: consider loading user styles after theme styles gutenberg#34141 for more context

@kjellr
Copy link
Collaborator

kjellr commented Nov 3, 2021

Just a heads up that Gutenberg support for button hover states is no longer planned for 5.9, so we'll need to make a call about whether or not to build something into the theme.

I'll sum up my current thoughts here:

I haven't made up my mind one way or another yet, but in general, it seems clear that we have a bunch of non-ideal options to choose from.

@carolinan
Copy link
Collaborator

It is so much easier to only style one button. The other variations can be deregistered 🤐

@paaljoachim
Copy link

paaljoachim commented Nov 3, 2021

Can we perhaps get it into a WP 5.9.1 theme update instead?

@kjellr kjellr removed this from the Feature Freeze milestone Nov 12, 2021
@kjellr
Copy link
Collaborator

kjellr commented Nov 30, 2021

We haven't updated this in a while, so just adding a few notes from various slack conversations:

  • @jffng and I have been leaning towards not adding button hover states. The previous explorations linked above have all been too complicated, or haven't looked great. Users will able to add their own hover states when Gutenberg supports this.
  • We've had mixed signals on whether or not that would be ok from an a11y perspective though. On one hand, WCAG does not require hover states for buttons. But on the other hand, it's better to do it. Also, these are actually just links styled up to look like buttons.
  • If we did implement something, maybe a simple opacity change would take care of this and also not interfere too much with future Gutenberg features.

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