forked from npm/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskip-link.js
More file actions
43 lines (38 loc) · 877 Bytes
/
skip-link.js
File metadata and controls
43 lines (38 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Link } from '@primer/components'
import styled from 'styled-components'
import React from 'react'
function SkipLinkBase (props) {
return (
<Link
{...props}
backgroundColor="blue.6"
color="white"
p={3}
href="#skip-nav"
fontSize={1}
>
Skip to content
</Link>
)
}
const SkipLink = styled(SkipLinkBase)`
z-index: 20;
width: auto;
height: auto;
clip: auto;
position: absolute;
overflow: hidden;
// The following rules are to ensure that the element
// is visually hidden, unless it has focus. This is the recommended
// way to hide content from:
// https://webaim.org/techniques/css/invisiblecontent/#techniques
&:not(:focus) {
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
}
`
export default SkipLink