Skip to content

Commit 756c61d

Browse files
committed
Update visually-hidden with enhancements from WebC bed
https://github.com/rdela/webcbed/pulls?q=is%3Apr Also, like 11ty#9, introduces JSDoc-style comments, curious what we think about those.
1 parent f4a91bd commit 756c61d

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

_components/visually-hidden.webc

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<style webc:scoped>
2-
/* https://www.a11yproject.com/posts/how-to-hide-content/ */
3-
:host {
4-
clip: rect(0 0 0 0);
5-
clip-path: inset(50%);
6-
height: 1px;
7-
overflow: hidden;
8-
position: absolute;
9-
white-space: nowrap;
10-
width: 1px;
11-
}
2+
/**
3+
* Visually hide elements while allowing them to remain focusable
4+
*
5+
* Learn more:
6+
* - https://www.a11yproject.com/posts/how-to-hide-content/
7+
* - https://blog.logrocket.com/design-accessibility-css-visually-hidden-class/
8+
* - https://front-end.social/@joshwcomeau/112574609127860924
9+
*/
10+
:host:not(:has(:is(a:active, a:focus))) {
11+
clip: rect(0 0 0 0);
12+
clip-path: inset(50%);
13+
height: 1px;
14+
overflow: hidden;
15+
position: absolute;
16+
white-space: nowrap;
17+
width: 1px;
18+
}
19+
:host:has(:is(a:active, a:focus)) {
20+
margin: var(--box-margin);
21+
}
1222
</style>

0 commit comments

Comments
 (0)