File tree 6 files changed +71
-0
lines changed
translations/locales/en-US
6 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { useState } from 'react' ;
2
+ import classNames from 'classnames' ;
3
+ import PropTypes from 'prop-types' ;
4
+ import { useTranslation } from 'react-i18next' ;
5
+
6
+ const SkipLink = ( { targetId, text } ) => {
7
+ const [ focus , setFocus ] = useState ( false ) ;
8
+ const { t } = useTranslation ( ) ;
9
+ const handleFocus = ( ) => {
10
+ setFocus ( true ) ;
11
+ } ;
12
+
13
+ const handleBlur = ( ) => {
14
+ setFocus ( false ) ;
15
+ } ;
16
+ const linkClasses = classNames ( 'skip_link' , { focus } ) ;
17
+
18
+ return (
19
+ < a
20
+ href = { `#${ targetId } ` }
21
+ className = { linkClasses }
22
+ onFocus = { handleFocus }
23
+ onBlur = { handleBlur }
24
+ >
25
+ { t ( `SkipLink.${ text } ` ) }
26
+ </ a >
27
+ ) ;
28
+ } ;
29
+
30
+ SkipLink . propTypes = {
31
+ targetId : PropTypes . string . isRequired ,
32
+ text : PropTypes . string . isRequired
33
+ } ;
34
+
35
+ export default SkipLink ;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Routing from './routes';
9
9
import ThemeProvider from './modules/App/components/ThemeProvider' ;
10
10
import Loader from './modules/App/components/loader' ;
11
11
import './i18n' ;
12
+ import SkipLink from './components/SkipLink' ;
12
13
13
14
require ( './styles/main.scss' ) ;
14
15
@@ -23,6 +24,7 @@ const App = () => (
23
24
< Provider store = { store } >
24
25
< ThemeProvider >
25
26
< Router history = { browserHistory } >
27
+ < SkipLink targetId = "play-sketch" text = "PlaySketch" />
26
28
< Routing />
27
29
</ Router >
28
30
</ ThemeProvider >
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ const Toolbar = (props) => {
61
61
</ button >
62
62
< button
63
63
className = { playButtonClass }
64
+ id = "play-sketch"
64
65
onClick = { ( ) => {
65
66
props . syncFileContent ( ) ;
66
67
dispatch ( startSketch ( ) ) ;
Original file line number Diff line number Diff line change
1
+ @use " sass:math" ;
2
+
3
+ .skip_link {
4
+ left : 50% ;
5
+ transform : translateX (-50% );
6
+ top : 1% ;
7
+ clip : rect (0 0 0 0 );
8
+ overflow : hidden ;
9
+ position : absolute ;
10
+ border-radius : 3px ;
11
+ white-space : nowrap ;
12
+ vertical-align : middle ;
13
+ background-color : transparent ;
14
+ font-size : #{math .div (12 , $base-font-size )} rem;
15
+ line-height : #{math .div (50 , $base-font-size )} rem;line-height : 11px ;
16
+ padding : #{math .div (10 , $base-font-size )} rem #{math .div (10 , $base-font-size )} rem;
17
+ background : #fff ;
18
+ display : inline-block ;
19
+ text-transform : uppercase ;
20
+ transition : none ;
21
+ z-index : 5 ;
22
+ }
23
+
24
+ .skip_link :focus {
25
+ clip : auto ;
26
+ overflow : visible ;
27
+ width : auto ;
28
+ height : auto ;
29
+ }
Original file line number Diff line number Diff line change 54
54
@import ' components/collection' ;
55
55
@import ' components/collection-create' ;
56
56
@import ' components/quick-add' ;
57
+ @import ' components/skip-link' ;
57
58
58
59
@import ' layout/dashboard' ;
59
60
@import ' layout/ide' ;
Original file line number Diff line number Diff line change 621
621
"PrivacyPolicy" : " Privacy Policy" ,
622
622
"TermsOfUse" : " Terms of Use" ,
623
623
"CodeOfConduct" : " Code of Conduct"
624
+ },
625
+ "SkipLink" : {
626
+ "PlaySketch" : " Skip to Play Sketch"
624
627
}
625
628
}
You can’t perform that action at this time.
0 commit comments