-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: unify vertical tabs styles #65387
Merged
Merged
Changes from 58 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
1fe9f0b
Remove inserter pattern overrides
DaniGuardiola aa7e9d9
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola a3e54c5
Make font weights 400 (inactive) and 500 (active)
DaniGuardiola 0b436e8
Apply styles only when vertical.
DaniGuardiola 299d23c
Make vertical indicator theme accent color at 4% opacity.
DaniGuardiola 30cda58
Make height 48px.
DaniGuardiola 4749518
Add radius.
DaniGuardiola 4ba287f
Also use hover styles in focus-visible.
DaniGuardiola 7847ed6
Fix indicator not visible in inserter > patterns/media.
DaniGuardiola c9e8020
Adjust padding.
DaniGuardiola 0499718
Tweak focus ring.
DaniGuardiola 77ce702
Wrap long labels.
DaniGuardiola 23f5438
Add chevron and fix a few minor details.
DaniGuardiola 5ffc33d
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola fa2da0a
Fix merge issues.
DaniGuardiola af857d3
Fix focus indicator (gets cropped with the new overflow auto setting)
DaniGuardiola a8a3f3f
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola 9867089
Fix unwanted chevron.
DaniGuardiola bd0a96c
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola 56989af
Fix unwanted nested scrollbar in inserter > patterns/media vertical t…
DaniGuardiola 517950e
Switch to transform for performance.
DaniGuardiola a708e6b
Adjust border-radius based on scaling factor.
DaniGuardiola 4aa21c8
Apply feedback.
DaniGuardiola dcbd6f5
Add changelog entry.
DaniGuardiola 0a65888
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola f0902e8
Switch to `padding-inline`.
DaniGuardiola e12afb5
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola 535463c
Remove unnecessary styles.
DaniGuardiola 3c43be8
Fix horizontal tabs height.
DaniGuardiola 2d4bc91
Remove more unnecessary styles (padding).
DaniGuardiola 7f1e764
Make horizontal padding specific to inline.
DaniGuardiola 34cece9
Make flex/whitespace styles more explicit.
DaniGuardiola 3b82ba0
Make scroll margin specific to vertical tabs.
DaniGuardiola 789545f
The "inline" in inline-flex is unnecessary and confusing, removed it.
DaniGuardiola 094786c
Remove unnecessary position: relative
DaniGuardiola 87ce756
Make resets more explicit
DaniGuardiola 9808c75
Remove unnecessary text-align.
DaniGuardiola 74851f8
Improve comment
DaniGuardiola cba3d80
Remove unnecessary margin-left
DaniGuardiola e6b902f
Clean up TabList styles.
DaniGuardiola 41dc764
Adjust text-align.
DaniGuardiola cfc7928
Clean up selector
DaniGuardiola d345ebd
Fix focus indicator
DaniGuardiola 9c28772
Clean up position: relative.
DaniGuardiola f831078
Fix typo.
DaniGuardiola b4f5c21
Add position: relative back.
DaniGuardiola a9b1578
Improve focus indicator when selectOnMove is enabled.
DaniGuardiola 5736e59
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola f4dbf4f
Add fade in effect to chevron when selectOnMove is enabled.
DaniGuardiola 94f788b
Use [data-focus-visible] consistently.
DaniGuardiola 01f31da
Styles clean up.
DaniGuardiola 4337d49
Add comment for clarity.
DaniGuardiola 01cefc9
Move scroll-margin to the right place.
DaniGuardiola bb6b4e1
Use CSS variable for accuracy.
DaniGuardiola b6710f2
Fix overflow.
DaniGuardiola 822715b
Skip failing test for Safari :(
DaniGuardiola ece5efc
Fix flashing issue.
DaniGuardiola 07069c8
Transition chevron only on selected and not on hover or focus-visible.
DaniGuardiola b008f3a
Improve chevron opacity transition with suggested value.
DaniGuardiola ee8783f
fix changelog
DaniGuardiola 3d9bde2
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into i…
DaniGuardiola 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
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
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
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 |
---|---|---|
|
@@ -9,18 +9,15 @@ import * as Ariakit from '@ariakit/react'; | |
*/ | ||
import { COLORS, CONFIG } from '../utils'; | ||
import { space } from '../utils/space'; | ||
import Icon from '../icon'; | ||
|
||
export const TabListWrapper = styled.div` | ||
position: relative; | ||
display: flex; | ||
align-items: stretch; | ||
flex-direction: row; | ||
text-align: center; | ||
overflow-x: auto; | ||
|
||
&[aria-orientation='vertical'] { | ||
flex-direction: column; | ||
text-align: start; | ||
} | ||
|
||
:where( [aria-orientation='horizontal'] ) { | ||
|
@@ -40,11 +37,12 @@ export const TabListWrapper = styled.div` | |
|
||
@media not ( prefers-reduced-motion ) { | ||
&[data-indicator-animated]::before { | ||
transition-property: transform; | ||
transition-property: transform, border-radius, border-block; | ||
transition-duration: 0.2s; | ||
transition-timing-function: ease-out; | ||
} | ||
} | ||
position: relative; | ||
&::before { | ||
content: ''; | ||
position: absolute; | ||
|
@@ -59,7 +57,7 @@ export const TabListWrapper = styled.div` | |
/* Using a large value to avoid antialiasing rounding issues | ||
when scaling in the transform, see: https://stackoverflow.com/a/52159123 */ | ||
--antialiasing-factor: 100; | ||
&:not( [aria-orientation='vertical'] ) { | ||
&[aria-orientation='horizontal'] { | ||
--fade-width: 4rem; | ||
--fade-gradient-base: transparent 0%, black var( --fade-width ); | ||
--fade-gradient-composed: var( --fade-gradient-base ), black 60%, | ||
|
@@ -104,65 +102,87 @@ export const TabListWrapper = styled.div` | |
${ COLORS.theme.accent }; | ||
} | ||
} | ||
&[aria-orientation='vertical']::before { | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: calc( var( --antialiasing-factor ) * 1px ); | ||
transform: translateY( calc( var( --selected-top, 0 ) * 1px ) ) | ||
scaleY( | ||
&[aria-orientation='vertical'] { | ||
&::before { | ||
/* Adjusting the border radius to match the scaling in the y axis. */ | ||
border-radius: ${ CONFIG.radiusSmall } / | ||
calc( | ||
var( --selected-height, 0 ) / var( --antialiasing-factor ) | ||
) | ||
${ CONFIG.radiusSmall } / | ||
( | ||
var( --selected-height, 0 ) / | ||
var( --antialiasing-factor ) | ||
) | ||
); | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: calc( var( --antialiasing-factor ) * 1px ); | ||
transform: translateY( calc( var( --selected-top, 0 ) * 1px ) ) | ||
scaleY( | ||
calc( | ||
var( --selected-height, 0 ) / | ||
var( --antialiasing-factor ) | ||
) | ||
); | ||
background-color: color-mix( | ||
in srgb, | ||
${ COLORS.theme.accent }, | ||
transparent 96% | ||
); | ||
background-color: ${ COLORS.theme.gray[ 100 ] }; | ||
} | ||
&[data-select-on-move='true']:has( | ||
:is( :focus-visible, [data-focus-visible] ) | ||
)::before { | ||
box-sizing: border-box; | ||
border: var( --wp-admin-border-width-focus ) solid | ||
${ COLORS.theme.accent }; | ||
/* Adjusting the border width to match the scaling in the y axis. */ | ||
border-block-width: calc( | ||
var( --wp-admin-border-width-focus, 1px ) / | ||
( | ||
var( --selected-height, 0 ) / | ||
var( --antialiasing-factor ) | ||
) | ||
); | ||
} | ||
} | ||
`; | ||
|
||
export const Tab = styled( Ariakit.Tab )` | ||
& { | ||
scroll-margin: 24px; | ||
flex-grow: 1; | ||
flex-shrink: 0; | ||
display: inline-flex; | ||
align-items: center; | ||
position: relative; | ||
/* Resets */ | ||
border-radius: 0; | ||
height: ${ space( 12 ) }; | ||
background: transparent; | ||
border: none; | ||
box-shadow: none; | ||
|
||
flex: 1 0 auto; | ||
white-space: nowrap; | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
line-height: 1.2; // Some languages characters e.g. Japanese may have a native higher line-height. | ||
padding: ${ space( 4 ) }; | ||
margin-left: 0; | ||
font-weight: 500; | ||
text-align: inherit; | ||
line-height: 1.2; // Characters in some languages (e.g. Japanese) may have a native higher line-height. | ||
font-weight: 400; | ||
color: ${ COLORS.theme.foreground }; | ||
|
||
&[aria-disabled='true'] { | ||
cursor: default; | ||
color: ${ COLORS.ui.textDisabled }; | ||
} | ||
|
||
&:not( [aria-disabled='true'] ):hover { | ||
&:not( [aria-disabled='true'] ):is( :hover, [data-focus-visible] ) { | ||
color: ${ COLORS.theme.accent }; | ||
} | ||
|
||
&:focus:not( :disabled ) { | ||
position: relative; | ||
box-shadow: none; | ||
outline: none; | ||
} | ||
|
||
// Focus. | ||
// Focus indicator. | ||
position: relative; | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
top: ${ space( 3 ) }; | ||
right: ${ space( 3 ) }; | ||
bottom: ${ space( 3 ) }; | ||
left: ${ space( 3 ) }; | ||
pointer-events: none; | ||
|
||
// Draw the indicator. | ||
|
@@ -179,19 +199,65 @@ export const Tab = styled( Ariakit.Tab )` | |
} | ||
} | ||
|
||
&:focus-visible::after { | ||
&[data-focus-visible]::after { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
[aria-orientation='horizontal'] & { | ||
padding-inline: ${ space( 4 ) }; | ||
height: ${ space( 12 ) }; | ||
text-align: center; | ||
scroll-margin: 24px; | ||
|
||
&::after { | ||
content: ''; | ||
inset: ${ space( 3 ) }; | ||
} | ||
} | ||
|
||
[aria-orientation='vertical'] & { | ||
min-height: ${ space( | ||
10 | ||
) }; // Avoid fixed height to allow for long strings that go in multiple lines. | ||
padding: ${ space( 2 ) } ${ space( 3 ) }; | ||
min-height: ${ space( 10 ) }; | ||
text-align: start; | ||
|
||
&[aria-selected='true'] { | ||
color: ${ COLORS.theme.accent }; | ||
fill: currentColor; | ||
} | ||
} | ||
[aria-orientation='vertical'][data-select-on-move='false'] &::after { | ||
content: ''; | ||
inset: var( --wp-admin-border-width-focus ); | ||
} | ||
`; | ||
|
||
export const TabChildren = styled.span` | ||
flex-grow: 1; | ||
`; | ||
|
||
export const TabChevron = styled( Icon )` | ||
flex-shrink: 0; | ||
margin-inline-end: ${ space( -1 ) }; | ||
[aria-orientation='horizontal'] & { | ||
justify-content: center; | ||
display: none; | ||
} | ||
opacity: 0; | ||
[role='tab']:is( [aria-selected='true'], [data-focus-visible], :hover ) & { | ||
opacity: 1; | ||
} | ||
// The chevron is transitioned into existence when selectOnMove is enabled, | ||
// because otherwise it looks jarring, as it shows up outside of the focus | ||
// indicator that's being animated at the same time. | ||
@media not ( prefers-reduced-motion ) { | ||
[data-select-on-move='true'] | ||
[role='tab']:is( [aria-selected='true'], ) | ||
& { | ||
transition: opacity 0.3s ease-in; | ||
stokesman marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @t-hamano oof, I accidentally replaced the wrong transition, this is where it should have been replaced. |
||
} | ||
} | ||
&:dir( rtl ) { | ||
rotate: 180deg; | ||
} | ||
`; | ||
|
||
|
@@ -201,7 +267,7 @@ export const TabPanel = styled( Ariakit.TabPanel )` | |
outline: none; | ||
} | ||
|
||
&:focus-visible { | ||
&[data-focus-visible] { | ||
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) | ||
${ COLORS.theme.accent }; | ||
// Windows high contrast mode. | ||
|
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
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
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
Oops, something went wrong.
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.
This is probably fixed by ariakit/ariakit#4094 which is included in
@ariakit/react
0.4.11
.We should follow-up to update ariakit-related dependencies, and consequently we should be able to remove
:focus-visible
🤞