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
Unify focus styles, and pave the way for them to be customizable #21141
Conversation
@mixin block-style__is-active() { | ||
color: $white; | ||
background: $dark-gray-primary; | ||
@mixin input-style__focus() { |
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.
These mixins arguably should also be removed. However they are fairly widely used, and in places that are affected by upstream CSS bleed. That's why I omitted these for now. They can be revisited separately.
packages/base-styles/_variables.scss
Outdated
$border-width-focus: 1.5px; | ||
$border-width-tab: 4px; | ||
|
||
:root { |
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.
Is there a better place than this SCSS file to output these? I imagine there is, because right now the variable appears duplicated a bunch of times, and it shouldn't be. I would appreciate advice here.
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.
What's the reasoning for using a CSS variable here. It seems inconsistent with the other variables (grids, colors...)
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.
They're both variables, that's all the reasoning there is. And that's why I was asking for advice on what might be a better place. It also gets duplicated when here, so it really isn't the best place — just not sure where to put it.
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 think the best way to do it would be something like
$border-width-focus: var( --border-width-focus, 1.5px );
and just use $border-width-focus
everywhere without this root rule.
That said, I'd prefer if we avoid introducing these variables in this PR in order to give it more thoughts and also be consistent with the variables we propose.
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.
The reason for doing it the way it's been done currently, is to provide a fallback for IE11.
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.
It can potentially be automated using a Post CSS plugin. Maybe by replacing var
above with a custom one config
or something
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.
Good argument for leaving it to a separate PR.
Size Change: +13.2 kB (1%) Total Size: 879 kB
|
Filename | Size | Change | |
---|---|---|---|
build/a11y/index.js |
998 B | 0 B | |
build/annotations/index.js |
3.45 kB | 0 B | |
build/api-fetch/index.js |
3.39 kB | 0 B | |
build/autop/index.js |
2.58 kB | 0 B | |
build/blob/index.js |
620 B | 0 B | |
build/block-directory/index.js |
6.02 kB | 0 B | |
build/block-directory/style-rtl.css |
760 B | 0 B | |
build/block-directory/style.css |
760 B | 0 B | |
build/block-editor/index.js |
102 kB | 0 B | |
build/block-library/editor-rtl.css |
7.21 kB | 0 B | |
build/block-library/editor.css |
7.21 kB | 0 B | |
build/block-library/index.js |
111 kB | 0 B | |
build/block-library/style-rtl.css |
7.5 kB | 0 B | |
build/block-library/style.css |
7.51 kB | 0 B | |
build/block-library/theme-rtl.css |
669 B | 0 B | |
build/block-library/theme.css |
671 B | 0 B | |
build/block-serialization-default-parser/index.js |
1.65 kB | 0 B | |
build/block-serialization-spec-parser/index.js |
3.1 kB | 0 B | |
build/blocks/index.js |
57.5 kB | 0 B | |
build/components/index.js |
191 kB | 0 B | |
build/compose/index.js |
6.21 kB | 0 B | |
build/core-data/index.js |
10.7 kB | 0 B | |
build/data-controls/index.js |
1.04 kB | 0 B | |
build/data/index.js |
8.26 kB | 0 B | |
build/date/index.js |
5.36 kB | 0 B | |
build/deprecated/index.js |
772 B | 0 B | |
build/dom-ready/index.js |
568 B | 0 B | |
build/dom/index.js |
3.05 kB | 0 B | |
build/edit-navigation/index.js |
2.4 kB | 0 B | |
build/edit-navigation/style-rtl.css |
95 B | 0 B | |
build/edit-navigation/style.css |
95 B | 0 B | |
build/edit-post/index.js |
92.3 kB | 0 B | |
build/edit-site/index.js |
9.04 kB | 0 B | |
build/edit-widgets/index.js |
4.43 kB | 0 B | |
build/editor/editor-styles-rtl.css |
423 B | 0 B | |
build/editor/editor-styles.css |
426 B | 0 B | |
build/editor/index.js |
42.8 kB | 0 B | |
build/element/index.js |
4.44 kB | 0 B | |
build/escape-html/index.js |
733 B | 0 B | |
build/format-library/index.js |
6.95 kB | 0 B | |
build/format-library/style-rtl.css |
502 B | 0 B | |
build/format-library/style.css |
502 B | 0 B | |
build/hooks/index.js |
1.93 kB | 0 B | |
build/html-entities/index.js |
621 B | 0 B | |
build/i18n/index.js |
3.57 kB | 0 B | |
build/is-shallow-equal/index.js |
710 B | 0 B | |
build/keyboard-shortcuts/index.js |
2.3 kB | 0 B | |
build/keycodes/index.js |
1.7 kB | 0 B | |
build/list-reusable-blocks/index.js |
2.99 kB | 0 B | |
build/list-reusable-blocks/style-rtl.css |
226 B | 0 B | |
build/list-reusable-blocks/style.css |
226 B | 0 B | |
build/media-utils/index.js |
4.84 kB | 0 B | |
build/notices/index.js |
1.57 kB | 0 B | |
build/nux/index.js |
3.01 kB | 0 B | |
build/nux/style-rtl.css |
616 B | 0 B | |
build/nux/style.css |
613 B | 0 B | |
build/plugins/index.js |
2.54 kB | 0 B | |
build/primitives/index.js |
1.5 kB | 0 B | |
build/priority-queue/index.js |
780 B | 0 B | |
build/redux-routine/index.js |
2.83 kB | 0 B | |
build/rich-text/index.js |
14.5 kB | 0 B | |
build/server-side-render/index.js |
2.55 kB | 0 B | |
build/shortcode/index.js |
1.7 kB | 0 B | |
build/token-list/index.js |
1.28 kB | 0 B | |
build/url/index.js |
4.01 kB | 0 B | |
build/viewport/index.js |
1.6 kB | 0 B | |
build/warning/index.js |
1.14 kB | 0 B | |
build/wordcount/index.js |
1.18 kB | 0 B |
1a22569
to
9948524
Compare
Okay, rebased and removed the CSS variable for now. I still think we should create a CSS variable for the focus style, so that it can be easily customized for example in options. But that is perhaps something for a different time. |
I tried this out today. In Chrome the focus states look wonderful. I did notice that the checkboxes and color circles still didn't reflect this new change. and But that can always be another PR. In Firefox however, the focus states seemed a bit awkward. They were even around the element. Some items showed a stronger bottom-right shadow, while others showed a thicker top border. |
6d5ea59
to
a90ae14
Compare
Thank you Mark. I'm having a hard time reproducing the bottom right shadow issue in Firefox. The GIF you're showing has a thicker bottom border to indicate the active tab, this just happens to be the same color as the focus style. But I'm open to suggestions for how to tweak the details here — it feels important to keep the bottom border thickness even while showing focus. I did notice a little animation flicker that I'll see if I can address! |
Addressed the jumpiness. Forgot to mention that yes, good call on the color swatches and checkboxes. There are some elements inside the canvas as well, like when a social link button (not the block) has focus. But as you allude to, I'd like to revisit those separately as this PR is becoming a little big. |
32c45c9
to
5048298
Compare
5048298
to
4205f73
Compare
Similar color swatch comments and social links as you mentioned but other focuc styles look fine
This PR does a number of things, the most important one perhaps just being a ton of code cleanup and simplification. It:
Additionally, it adds a new focus highlight CSS variable,— Out for now, can be revisited.--border-width-focus
, which opens up the door to users customizing these.A couple of GIFs:
Here, a user customized the CSS variable in the inspector: