Skip to content

Commit d3ff314

Browse files
authored
a11y tweaks (#1306)
* tweak some focus states * a11y tweaks * more tweaks
1 parent 38750eb commit d3ff314

File tree

6 files changed

+46
-31
lines changed

6 files changed

+46
-31
lines changed

apps/svelte.dev/src/routes/_home/Video.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
label {
198198
opacity: 0.2;
199199
transition: opacity 0.2s;
200+
border-radius: var(--sk-border-radius);
200201
}
201202
202203
.top-controls {
@@ -237,12 +238,14 @@
237238
border-radius: 0 var(--sk-border-radius) var(--sk-border-radius) var(--sk-border-radius);
238239
} */
239240
240-
.video-player:hover label {
241+
.video-player:hover label,
242+
.video-player:focus-within label {
241243
opacity: 1;
242244
}
243245
244246
.video-player input:focus-visible ~ img {
245247
outline: 2px solid var(--sk-fg-accent);
246248
outline-offset: 2px;
249+
border-radius: var(--sk-border-radius);
247250
}
248251
</style>

packages/repl/src/lib/Output/CompilerOptions.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- svelte-ignore a11y_label_has_associated_control (TODO this warning should probably be disabled if there's a component)-->
2828
<label class="option">
2929
<span class="key">dev:</span>
30-
<span style="font-size: 1.2rem">
30+
<span style="position: relative; font-size: 1.2rem; top: 0.2em">
3131
<Checkbox
3232
checked={workspace.compiler_options.dev!}
3333
onchange={(dev) => {
@@ -70,10 +70,6 @@
7070
color: var(--shiki-token-string);
7171
}
7272
73-
label :global(input[type='checkbox']) {
74-
top: -1px;
75-
}
76-
7773
input[type='radio'] {
7874
position: absolute;
7975
top: auto;

packages/site-kit/src/lib/components/Checkbox.svelte

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
<style>
1111
input[type='checkbox'] {
12+
--thumb-size: 1em;
13+
--track-padding: 2px;
1214
/* display: block; */
1315
position: relative;
14-
height: 1em;
15-
width: 2em;
16-
top: -2px;
16+
height: calc(var(--thumb-size) + 2 * var(--track-padding));
17+
width: calc(2 * var(--thumb-size) + 2 * var(--track-padding));
1718
border-radius: 0.5em;
1819
-webkit-appearance: none;
1920
appearance: none;
20-
outline: none;
2121
border: transparent;
2222
margin: 0 0.6em 0 0;
2323
}
@@ -28,12 +28,11 @@
2828
display: block;
2929
height: 100%;
3030
width: 100%;
31-
padding: 2px;
32-
border-radius: 1em;
3331
top: 0;
3432
left: 0;
33+
border-radius: 9999px;
3534
background: var(--sk-bg-4);
36-
box-sizing: content-box;
35+
box-sizing: border-box;
3736
}
3837
3938
input[type='checkbox']:checked::before {
@@ -44,10 +43,10 @@
4443
content: '';
4544
position: absolute;
4645
display: block;
47-
height: 1em;
48-
width: 1em;
49-
top: 2px;
50-
left: 2px;
46+
height: var(--thumb-size);
47+
aspect-ratio: 1;
48+
top: var(--track-padding);
49+
left: var(--track-padding);
5150
border-radius: 1em;
5251
background: var(--sk-bg-1);
5352
box-shadow:
@@ -59,6 +58,6 @@
5958
}
6059
6160
input[type='checkbox']:checked::after {
62-
left: calc(100% - 1em + 2px);
61+
left: calc(100% - var(--thumb-size) - var(--track-padding));
6362
}
6463
</style>

packages/site-kit/src/lib/docs/DocsContents.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@
7272
}
7373
7474
li {
75+
position: relative;
7576
display: block;
7677
margin: 0;
7778
margin-bottom: 4rem;
79+
padding-right: 0.5rem; /* leave space for focus ring */
7880
}
7981
8082
li:last-child {
@@ -125,14 +127,14 @@
125127
overflow-y: auto;
126128
}
127129
128-
:global(.scrollbars-invisible) [aria-current='page']::after {
130+
:global(.scrollbars-invisible) li:has(> [aria-current='page'])::after {
129131
--size: 1.8rem;
130132
content: '';
131133
position: absolute;
132134
width: var(--size);
133135
height: var(--size);
134136
top: calc(1.4rem - var(--size) * 0.5);
135-
right: calc(-0.5 * var(--size));
137+
right: calc(-0.5rem - 0.5 * var(--size));
136138
background-color: var(--sk-bg-1);
137139
z-index: 2;
138140
position: absolute;

packages/site-kit/src/lib/markdown/renderer.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,15 @@ async function syntax_highlight({
857857
html = replace_blank_lines(highlighted);
858858
}
859859

860-
// munge shiki output: put whitespace outside `<span>` elements, so that
861-
// highlight delimiters fall outside tokens
862-
html = html.replace(/(<span[^>]+?>)(\s+)/g, '$2$1').replace(/(\s+)(<\/span>)/g, '$2$1');
860+
// munge shiki output
861+
html = html
862+
// put whitespace outside `<span>` elements, so that
863+
// highlight delimiters fall outside tokens
864+
.replace(/(<span[^>]+?>)(\s+)/g, '$2$1')
865+
.replace(/(\s+)(<\/span>)/g, '$2$1')
866+
867+
// remove tabindex
868+
.replace(' tabindex="0"', '');
863869

864870
html = html
865871
.replace(/ {13}([^ ][^]+?) {13}/g, (_, content) => {

packages/site-kit/src/lib/nav/Nav.svelte

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,17 @@ Top navigation bar for the application. It provides a slot for the left side, th
125125
<Search />
126126

127127
<div class="external-links">
128-
<a href="/chat" data-icon="discord" aria-label="Discord Chat"></a>
129-
<a
130-
href="https://bsky.app/profile/sveltesociety.dev"
131-
data-icon="bluesky"
132-
aria-label="Svelte Society on Bluesky"
133-
></a>
134-
<a href="https://github.com/sveltejs/svelte" data-icon="github" aria-label="GitHub Repo"
135-
></a>
128+
<a href="/chat" aria-label="Discord Chat">
129+
<span data-icon="discord"></span>
130+
</a>
131+
132+
<a href="https://bsky.app/profile/sveltesociety.dev" aria-label="Svelte Society on Bluesky">
133+
<span data-icon="bluesky"></span>
134+
</a>
135+
136+
<a href="https://github.com/sveltejs/svelte" aria-label="GitHub Repo">
137+
<span data-icon="github"></span>
138+
</a>
136139
</div>
137140

138141
<FontToggle />
@@ -281,6 +284,10 @@ Top navigation bar for the application. It provides a slot for the left side, th
281284
display: flex;
282285
height: 100%;
283286
margin: 0 0.5rem;
287+
288+
a {
289+
outline-offset: -2px;
290+
}
284291
}
285292
}
286293
@@ -377,9 +384,11 @@ Top navigation bar for the application. It provides a slot for the left side, th
377384
display: contents;
378385
379386
[data-icon] {
387+
display: flex;
380388
background: var(--sk-fg-3);
381389
padding: 0 0.5rem;
382390
height: 100%;
391+
aspect-ratio: 1;
383392
mask: no-repeat 50% 50%;
384393
mask-size: calc(100% - 1rem) auto;
385394
}

0 commit comments

Comments
 (0)