4
4
* Component tandem to allow users to skip navigation content
5
5
*
6
6
* @see Docs https://next.vue.chakra-ui.com/c-skip-nav
7
- * @see Source https://github.com/chakra-ui/chakra-ui-vue-next/blob/master/packages/c-skip-nav/src/c-skip-nav/c-skip-nav.ts
7
+ * @see Source https://github.com/chakra-ui/chakra-ui-vue-next/blob/master/packages/c-skip-nav/src/c-skip-nav.tsx
8
8
* @see WebAIM https://webaim.org/techniques/skipnav/
9
9
*/
10
10
11
- import { defineComponent , computed , h } from "vue"
12
- import {
13
- chakra ,
14
- ComponentWithProps ,
15
- HTMLChakraProps ,
16
- SystemStyleObject ,
17
- useStyleConfig ,
18
- } from "@chakra-ui/vue-system"
19
- import { CBox } from "@chakra-ui/vue-next"
20
- import { getValidChildren } from "@chakra-ui/vue-utils"
21
-
22
- const FALLBACK_ID = "chakra-skip-nav"
23
-
24
- export interface CSkipNavLinkProps extends HTMLChakraProps < "a" > { }
25
-
26
- export const CSkipNavLink : ComponentWithProps <
27
- CSkipNavLinkProps
28
- > = defineComponent ( {
29
- name : "CSkipNavLink" ,
30
- props : {
31
- id : {
32
- type : String ,
33
- default : FALLBACK_ID ,
34
- } ,
35
- } ,
36
- setup ( props , { slots, attrs } ) {
37
- const styles = useStyleConfig ( "SkipLink" , props )
38
-
39
- const skipLinkStyles = computed < SystemStyleObject > ( ( ) => {
40
- return {
41
- userSelect : "none" ,
42
- border : "0" ,
43
- borderRadius : "md" ,
44
- fontWeight : "semibold" ,
45
- height : "1px" ,
46
- width : "1px" ,
47
- margin : "-1px" ,
48
- padding : "0" ,
49
- outline : "0" ,
50
- overflow : "hidden" ,
51
- position : "absolute" ,
52
- clip : "rect(0 0 0 0)" ,
53
- ...styles . value ,
54
- _focus : {
55
- clip : "auto" ,
56
- width : "auto" ,
57
- height : "auto" ,
58
- boxShadow : "outline" ,
59
- padding : "1rem" ,
60
- position : "fixed" ,
61
- top : "1.5rem" ,
62
- insetStart : "1.5rem" ,
63
- } ,
64
- }
65
- } )
66
-
67
- return ( ) => {
68
- return (
69
- < chakra . a href = { `#${ props . id } ` } __css = { skipLinkStyles . value } { ...attrs } >
70
- { ( ) => getValidChildren ( slots ) }
71
- </ chakra . a >
72
- )
73
- }
74
- } ,
75
- } )
76
-
77
- export interface CSkipNavContentProps extends HTMLChakraProps < "div" > { }
78
-
79
- export const CSkipNavContent : ComponentWithProps < CSkipNavContentProps > =
80
- defineComponent ( {
81
- name : "CSkipNavContent" ,
82
- props : {
83
- id : {
84
- type : String ,
85
- default : FALLBACK_ID ,
86
- } ,
87
- } ,
88
- setup ( props , { attrs, slots } ) {
89
- return ( ) => {
90
- return (
91
- < CBox tabIndex = "-1" id = { props . id } data-testid = { FALLBACK_ID } { ...attrs } >
92
- { ( ) => getValidChildren ( slots ) }
93
- </ CBox >
94
- )
95
- }
96
- } ,
97
- } )
98
-
11
+ import { defineComponent , computed , h } from "vue"
12
+ import {
13
+ chakra ,
14
+ ComponentWithProps ,
15
+ HTMLChakraProps ,
16
+ SystemStyleObject ,
17
+ useStyleConfig ,
18
+ } from "@chakra-ui/vue-system"
19
+ import { CBox } from "@chakra-ui/vue-next"
20
+ import { getValidChildren } from "@chakra-ui/vue-utils"
21
+
22
+ const FALLBACK_ID = "chakra-skip-nav"
23
+
24
+ export interface CSkipNavLinkProps extends HTMLChakraProps < "a" > { }
25
+
26
+ export const CSkipNavLink : ComponentWithProps < CSkipNavLinkProps > =
27
+ defineComponent ( {
28
+ name : "CSkipNavLink" ,
29
+ props : {
30
+ id : {
31
+ type : String ,
32
+ default : FALLBACK_ID ,
33
+ } ,
34
+ } ,
35
+ setup ( props , { slots, attrs } ) {
36
+ const styles = useStyleConfig ( "SkipLink" , props )
37
+
38
+ const skipLinkStyles = computed < SystemStyleObject > ( ( ) => {
39
+ return {
40
+ userSelect : "none" ,
41
+ border : "0" ,
42
+ borderRadius : "md" ,
43
+ fontWeight : "semibold" ,
44
+ height : "1px" ,
45
+ width : "1px" ,
46
+ margin : "-1px" ,
47
+ padding : "0" ,
48
+ outline : "0" ,
49
+ overflow : "hidden" ,
50
+ position : "absolute" ,
51
+ clip : "rect(0 0 0 0)" ,
52
+ ...styles . value ,
53
+ _focus : {
54
+ clip : "auto" ,
55
+ width : "auto" ,
56
+ height : "auto" ,
57
+ boxShadow : "outline" ,
58
+ padding : "1rem" ,
59
+ position : "fixed" ,
60
+ top : "1.5rem" ,
61
+ insetStart : "1.5rem" ,
62
+ } ,
63
+ }
64
+ } )
65
+
66
+ return ( ) => {
67
+ return (
68
+ < chakra . a
69
+ href = { `#${ props . id } ` }
70
+ __css = { skipLinkStyles . value }
71
+ { ...attrs }
72
+ >
73
+ { ( ) => getValidChildren ( slots ) }
74
+ </ chakra . a >
75
+ )
76
+ }
77
+ } ,
78
+ } )
79
+
80
+ export interface CSkipNavContentProps extends HTMLChakraProps < "div" > { }
81
+
82
+ export const CSkipNavContent : ComponentWithProps < CSkipNavContentProps > =
83
+ defineComponent ( {
84
+ name : "CSkipNavContent" ,
85
+ props : {
86
+ id : {
87
+ type : String ,
88
+ default : FALLBACK_ID ,
89
+ } ,
90
+ } ,
91
+ setup ( props , { attrs, slots } ) {
92
+ return ( ) => {
93
+ return (
94
+ < CBox
95
+ tabIndex = "-1"
96
+ id = { props . id }
97
+ data-testid = { FALLBACK_ID }
98
+ { ...attrs }
99
+ >
100
+ { ( ) => getValidChildren ( slots ) }
101
+ </ CBox >
102
+ )
103
+ }
104
+ } ,
105
+ } )
0 commit comments