Skip to content

Commit 0360b94

Browse files
authored
fix: add box shadow instead of outline for all focusable elements and some spacing to the elements (#552)
This PR improves focus visibility **Issues** - The search and source repository buttons lacked visible focus indicators. - The theme toggle button had a low-contrast focus style in dark mode. - Default outline styles used system/WebKit colors, resulting in inconsistent rendering across browsers. - Some focus outlines were obscured due to insufficient spacing around elements. **Changes** - Replaced default outline with custom box-shadow styles, using accessible colors for both light and dark themes. - Removed the default hover outline effect on the theme toggle button to improve visual consistency. - Added padding/margin adjustments to ensure focus indicators remain visible. - Verified styles work across Chrome/Firefox. https://github.com/user-attachments/assets/a8a03791-931c-4e97-9559-da26ee4e1a45 Closes #536, #534
1 parent 96b4fe3 commit 0360b94

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

docs/_includes/header_custom.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
<button class="btn js-toggle-dark-mode" aria-label="Switch to light mode">
2-
3-
</button>
1+
<div class="js-toggle-dark-mode-wrapper">
2+
<button
3+
class="btn js-toggle-dark-mode"
4+
aria-label="Switch to light mode"
5+
type="button"
6+
>
7+
8+
</button>
9+
</div>
410

511
<script>
612
const toggleDarkMode = document.querySelector(".js-toggle-dark-mode");

docs/_sass/custom/custom.scss

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
:root {
2+
--outline-color: #{$outline-color-light};
3+
}
4+
5+
[data-theme="dark"] {
6+
--outline-color: #{$outline-color-dark};
7+
}
8+
19
html,
210
body {
311
height: 100%;
@@ -29,7 +37,7 @@ div.site-logo {
2937
color: $body-text-color;
3038
}
3139

32-
//Dark mode link styles
40+
// Dark mode link styles
3341
html[data-theme="dark"] {
3442
.main-header a,
3543
.main-header button,
@@ -56,7 +64,7 @@ html[data-theme="dark"] {
5664
}
5765
}
5866

59-
//Label colors
67+
// Label colors
6068
main {
6169
.label-green {
6270
background-color: $label-success-bg;
@@ -66,3 +74,33 @@ main {
6674
background-color: $label-error-bg;
6775
}
6876
}
77+
78+
// Outline styles
79+
.search:focus-within,
80+
.btn:focus,
81+
.btn:active,
82+
.btn:focus:hover,
83+
a:focus-visible,
84+
summary:focus-visible {
85+
outline: none;
86+
box-shadow: 0 0 0 3px var(--outline-color);
87+
border-radius: 2px;
88+
transition: box-shadow 0.2s ease;
89+
}
90+
91+
.aux-nav .aux-nav-list-item {
92+
padding: 5px;
93+
}
94+
95+
.nav-list-item {
96+
padding-left: 1px;
97+
padding-right: 1px;
98+
}
99+
100+
.js-toggle-dark-mode {
101+
height: 100%;
102+
}
103+
104+
.js-toggle-dark-mode-wrapper {
105+
padding: 5px;
106+
}

docs/_sass/custom/setup.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
$blue-400: #4da6ff;
33
$green-700: #00755c;
44
$red-600: #d13c3c;
5+
$purple-500: rgba(215, 186, 255, 0.65);
6+
$lavender: #b69cff;
57

68
// Semantic mappings
79
$link-color-dark: $blue-400;
810
$label-success-bg: $green-700;
911
$label-error-bg: $red-600;
12+
$outline-color-light: $lavender;
13+
$outline-color-dark: $purple-500;

0 commit comments

Comments
 (0)