Skip to content

Commit 4d4079c

Browse files
committed
feat: default focus ring for Root component contents
1 parent 7432dac commit 4d4079c

File tree

10 files changed

+55
-2
lines changed

10 files changed

+55
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@utrecht/focus-ring-css": minor
3+
---
4+
5+
Add mixins for default focus indicator for all focusable elements:

.changeset/shy-wasps-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@utrecht/html-content-css": minor
3+
---
4+
5+
Add default focus indicator to all focusable elements inside the HTML Content component.

.changeset/silver-days-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@utrecht/root-css": minor
3+
---
4+
5+
Add default focus indicator to all focusable elements inside the Root component.

components/focus-ring/src/_mixin.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@
3636
@include utrecht-focus-visible;
3737
}
3838
}
39+
40+
/* Override the browser focus ring with our own focus ring.
41+
* Use `:where()` so the CSS selector specificity is `0,0,0`.
42+
*/
43+
@mixin utrecht-focus-ring-default {
44+
:where(:focus-visible) {
45+
@include utrecht-focus-ring;
46+
}
47+
}
48+
49+
/* Override the browser focus ring with our own focus ring.
50+
* Use `:where()` so the CSS selector specificity is `0,0,0`.
51+
*/
52+
@mixin utrecht-focus-ring-default-container {
53+
:where(&) :where(:focus-visible) {
54+
@include utrecht-focus-ring;
55+
}
56+
}

components/html-content/src/_mixin.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@use "~@utrecht/document-css/src/html/mixin" as *;
1616
@use "~@utrecht/emphasis-css/src/html/mixin" as *;
1717
@use "~@utrecht/figure-css/src/html/mixin" as *;
18+
@use "~@utrecht/focus-ring-css/src/mixin" as *;
1819
@use "~@utrecht/form-css/src/html/mixin" as *;
1920
@use "~@utrecht/form-fieldset-css/src/html/mixin" as *;
2021
@use "~@utrecht/form-label-css/src/html/mixin" as *;
@@ -74,5 +75,7 @@
7475
}
7576

7677
@mixin utrecht-html-content-container {
78+
@include utrecht-focus-ring-default-container;
79+
7780
--utrecht-space-around: 1;
7881
}

components/root/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"clean": "rimraf dist"
1717
},
1818
"devDependencies": {
19-
"@utrecht/build-utils-css": "workspace:*"
19+
"@utrecht/build-utils-css": "workspace:*",
20+
"@utrecht/focus-ring-css": "workspace:*"
2021
},
2122
"keywords": [
2223
"nl-design-system"

components/root/src/_mixin.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Copyright (c) 2021-2024 Gemeente Utrecht
55
*/
66

7+
@use "~@utrecht/focus-ring-css/src/mixin" as *;
8+
79
@mixin reset-font-smoothing {
810
/* reset `font-smoothing: antialiasing`, prefer automatic (`subpixel-antialiasing`) behavior for high-dpi screens */
911
-webkit-font-smoothing: auto !important;
@@ -13,7 +15,7 @@
1315
@mixin utrecht-root {
1416
/*
1517
* Goals:
16-
*
18+
*
1719
* - take up 100% of the space, both horizontally and vertically.
1820
* - create a scrollable viewport experience both on `<html>` in the root,
1921
* as well as on a `<div>` somewhere in a document.
@@ -43,3 +45,7 @@
4345
text-size-adjust: none;
4446
word-break: break-word;
4547
}
48+
49+
@mixin utrecht-root__focus-indicator {
50+
@include utrecht-focus-ring;
51+
}

components/root/src/html/_mixin.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
*/
66

77
@use "../mixin" as *;
8+
@use "~@utrecht/focus-ring-css/src/mixin" as *;
89

910
@mixin utrecht-html-html {
1011
html {
1112
@include utrecht-root;
1213
}
14+
15+
@include utrecht-focus-ring-default;
1316
}
1417

1518
/**
@@ -20,4 +23,6 @@
2023
:root {
2124
@include utrecht-root;
2225
}
26+
27+
@include utrecht-focus-ring-default;
2328
}

components/root/src/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
@use "./mixin" as *;
8+
@use "~@utrecht/focus-ring-css/src/mixin" as *;
89

910
.utrecht-root {
1011
@include utrecht-root;
12+
@include utrecht-focus-ring-default-container;
1113
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)