-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Tabs: Try a simpler tab focus style, alt #46276
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cea6e37
Initial focus style refactor.
jasmussen ba81cc8
Try alternate style.
jasmussen d543f98
Update packages/components/src/tab-panel/style.scss
jasmussen ca40566
Update packages/components/src/tab-panel/style.scss
jasmussen faf9021
Remove z-index, update tabs in site editor as well.
jasmussen eaf7c7d
Update changelog.
jasmussen ae2ab27
Update widgets screen tabs.
jasmussen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 48 additions & 33 deletions
81
packages/edit-post/src/components/sidebar/settings-header/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,68 @@ | ||
// This tab style CSS is duplicated verbatim in | ||
// /packages/components/src/tab-panel/style.scss | ||
.components-button.edit-post-sidebar__panel-tab { | ||
position: relative; | ||
border-radius: 0; | ||
height: $grid-unit-60; | ||
background: transparent; | ||
border: none; | ||
box-shadow: none; | ||
cursor: pointer; | ||
display: inline-block; | ||
padding: 3px 15px; // Use padding to offset the is-active border, this benefits Windows High Contrast mode | ||
padding: 3px $grid-unit-20; // Use padding to offset the is-active border, this benefits Windows High Contrast mode | ||
margin-left: 0; | ||
font-weight: 500; | ||
|
||
// This pseudo-element "duplicates" the tab label and sets the text to bold. | ||
// This ensures that the tab doesn't change width when selected. | ||
// See: https://github.com/WordPress/gutenberg/pull/9793 | ||
&::after { | ||
content: attr(data-label); | ||
display: block; | ||
font-weight: 600; | ||
height: 0; | ||
overflow: hidden; | ||
speak: none; | ||
visibility: hidden; | ||
&:focus:not(:disabled) { | ||
position: relative; | ||
z-index: z-index(".edit-post-sidebar__panel-tab.is-active"); | ||
box-shadow: none; | ||
} | ||
|
||
&.is-active { | ||
// The transparent shadow ensures no jumpiness when focus animates on an active tab. | ||
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) transparent, inset 0 0 -$border-width-tab 0 0 var(--wp-admin-theme-color); | ||
position: relative; | ||
// Tab indicator | ||
&::after { | ||
content: ""; | ||
position: absolute; | ||
z-index: z-index(".edit-post-sidebar__panel-tab.is-active"); | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
pointer-events: none; | ||
|
||
// Draw the indicator. | ||
background: var(--wp-admin-theme-color); | ||
height: calc(0 * var(--wp-admin-border-width-focus)); | ||
border-radius: 0; | ||
|
||
// This border appears in Windows High Contrast mode instead of the box-shadow. | ||
&::before { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
bottom: 1px; | ||
right: 0; | ||
left: 0; | ||
border-bottom: $border-width-tab solid transparent; | ||
} | ||
// Animation | ||
transition: all 0.1s linear; | ||
@include reduce-motion("transition"); | ||
} | ||
|
||
&:focus { | ||
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
position: relative; | ||
z-index: z-index(".edit-post-sidebar__panel-tab.is-active"); | ||
// Active. | ||
&.is-active::after { | ||
height: calc(1 * var(--wp-admin-border-width-focus)); | ||
} | ||
|
||
// Focus. | ||
&::before { | ||
content: ""; | ||
position: absolute; | ||
top: $grid-unit-15; | ||
right: $grid-unit-15; | ||
bottom: $grid-unit-15; | ||
left: $grid-unit-15; | ||
pointer-events: none; | ||
|
||
// Draw the indicator. | ||
box-shadow: 0 0 0 0 transparent; | ||
border-radius: $radius-block-ui; | ||
|
||
// Animation | ||
transition: all 0.1s linear; | ||
@include reduce-motion("transition"); | ||
} | ||
|
||
&.is-active:focus { | ||
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 -#{$border-width-tab * 2} 0 0 var(--wp-admin-theme-color); | ||
&:focus-visible::before { | ||
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't quite understand the purpose of all the z-index styles. Could you explain the intent?
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'm actually not sure — I know it was necessary at one point, but I think the tabs have been refactored enough that it might not be needed anymore. When I tried removing it just now, it worked fine without it. I'll try and remove it and see if that helps.