-
Notifications
You must be signed in to change notification settings - Fork 62
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
Restore focus rings #230
base: main
Are you sure you want to change the base?
Restore focus rings #230
Changes from 5 commits
4ec6887
19095d2
94f15e1
9f92b72
bc60ffe
b820e8d
d2f1069
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
-moz-user-select: none; | ||
-ms-user-select: none; | ||
-webkit-user-select: none; | ||
outline-offset: 0.25rem; | ||
|
||
&:hover { | ||
text-decoration: none; | ||
|
@@ -76,6 +77,12 @@ | |
border-width: 1px !important; | ||
border-style: solid !important; | ||
} | ||
.sd-btn-#{$color}:focus-visible { | ||
outline-color: var(--sd-color-#{$color}) !important; | ||
&::after { | ||
outline-color: var(--sd-color-#{$color}) !important; | ||
} | ||
Comment on lines
+82
to
+84
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. This is mainly for link-cards where the |
||
} | ||
} | ||
|
||
// make parent clickable | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,15 @@ | |
margin-left: 0; | ||
margin-right: 0; | ||
} | ||
|
||
.sd-stretched-link:focus-visible { | ||
outline: none; | ||
|
||
&::after { | ||
outline-style: auto; | ||
outline-color: var(--sd-color-primary); | ||
} | ||
Comment on lines
+29
to
+32
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. The trick of using The browser's default stylesheet has some This is why I set the outline color here explicitly, because the |
||
} | ||
} | ||
|
||
.sd-card-hover:hover { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,12 +58,18 @@ $semantic-colors: ( | |
&.sd-bg-#{$color}:hover { | ||
background-color: var(--sd-color-#{$color}-highlight) !important; | ||
} | ||
&.sd-bg-#{$color}:focus-visible { | ||
outline-color: var(--sd-color-#{$color}-highlight) !important; | ||
} | ||
} | ||
a { | ||
&.sd-bg-#{$color}:focus, | ||
&.sd-bg-#{$color}:hover { | ||
background-color: var(--sd-color-#{$color}-highlight) !important; | ||
} | ||
&.sd-bg-#{$color}:focus-visible { | ||
outline-color: var(--sd-color-#{$color}-highlight) !important; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -90,6 +96,9 @@ $semantic-colors: ( | |
&.sd-outline-#{$color}:hover { | ||
border-color: var(--sd-color-#{$color}-highlight) !important; | ||
} | ||
&.sd-outline-#{$color}:focus-visible { | ||
outline-color: var(--sd-color-#{$color}-highlight) !important; | ||
} | ||
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. This file sets the focus ring color to match either the border color or the background color of links and buttons. |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,17 +29,14 @@ details.sd-dropdown { | |
display: none; | ||
} | ||
|
||
&:focus { | ||
outline: none; | ||
} | ||
|
||
Comment on lines
-32
to
-35
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. As mentioned in the PR description, I really don't understand why this rule was ever put in place. |
||
// The title is split into three parts: | ||
// 1. The icon (optional), which should be on the left | ||
// 2. The text, which should be in the middle, and take all available space | ||
// 3. The state marker, which should be on the right | ||
|
||
display: inline-flex; | ||
justify-content: space-between; | ||
outline-offset: 0.25rem; | ||
|
||
.sd-summary-icon { | ||
margin-right: 0.6em; | ||
|
@@ -64,7 +61,7 @@ details.sd-dropdown { | |
pointer-events: none; | ||
// align the icon vertically within its container | ||
display: inline-flex; | ||
align-items: center; | ||
align-self: center; | ||
} | ||
|
||
// make the state marker a bit more prominent when hovered | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ | |
.sd-sphinx-override p { | ||
margin-top: 0; | ||
} | ||
|
||
.sd-sphinx-override:focus-visible { | ||
outline-offset: 0.25rem; | ||
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. This helps ensure that this extension's focus rings are accessible. If the focus ring hugs the element, if there is no gap, and the background or border color of the element matches the focus ring, then it will be hard to perceive the focus ring, and therefore not accessible. For reference, see WCAG 2.2 Understanding Docs - Understanding SC 2.4.13: |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
} | ||
|
||
// Disable focus indicator for pointer devices | ||
&:not(.focus-visible) + label { | ||
&:not(:focus-visible) + label { | ||
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. I'm almost certain this was a typo. It has the unfortunate consequence of turning off focus rings on tabs. Here's how. The I think this rule was intended to prevent an effect on touchscreen devices where you tap an element and it gets briefly highlighted (or darklighted). |
||
outline: none; | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
|
@@ -48,7 +48,7 @@ | |
cursor: pointer; | ||
font-size: var(--sd-fontsize-tabs-label); | ||
font-weight: 700; | ||
padding: 1em 1.25em 0.5em; | ||
padding: 0.5em 1.25em 0.5em; | ||
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. As mentioned in the PR, this makes the top and bottom padding symmetrical. It's unclear to me why there was more top padding to begin with. I thought maybe it was to create some white space above the tabbed panel, but it already has top margin, so this value is a bit puzzling to me. I may be missing something here.
gabalafou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
transition: color 250ms; | ||
width: auto; | ||
z-index: 1; | ||
|
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's important to put some space between the button and the focus ring in case the two have matching colors.