-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06fe023
commit 9011e7e
Showing
8 changed files
with
153 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
|
||
import { EuiSkipLink } from '../../../../src/components/accessibility/skip_link'; | ||
import { EuiCallOut } from '../../../../src/components/call_out'; | ||
import { EuiText } from '../../../../src/components/text'; | ||
import { EuiPortal } from '../../../../src/components/portal'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiText> | ||
<p> | ||
<em> | ||
Tab out of the browser's address bar and a{' '} | ||
<strong>Skip to main content</strong> link will appear on this page. | ||
</em> | ||
</p> | ||
<EuiCallOut | ||
size="s" | ||
title="A functional ‘Skip to main content’ link will be added to the EUI docs site once the URL format is updated." | ||
iconType="iInCircle" | ||
/> | ||
</EuiText> | ||
<EuiPortal> | ||
<EuiSkipLink | ||
destination="/#/utilities/accessibility" | ||
label="Skip to content" | ||
// TODO this tabIndex value won't be necessary once a real skip to content link is added to the EUI docs site. | ||
// Adding the link is blocked until the new static site system (and non-hashed URL) is in place. | ||
// eslint-disable-next-line jsx-a11y/tabindex-no-positive | ||
tabIndex={1} | ||
/> | ||
</EuiPortal> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@import 'screen_reader'; | ||
@import 'skip_link'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.euiSkipLink { | ||
@include euiSlightShadow; | ||
display: block; | ||
z-index: $euiZHeader + 1; | ||
background-color: $euiColorPrimary; | ||
color: $euiColorGhost; | ||
font-size: $euiFontSizeS; | ||
padding: $euiSizeM $euiSize; | ||
|
||
&:focus, | ||
&:hover { | ||
position: fixed; | ||
top: 0; | ||
left: $euiSizeS; | ||
border-radius: 0 0 $euiBorderRadius $euiBorderRadius; | ||
text-decoration: underline; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { EuiKeyboardAccessible } from './keyboard_accessible'; | ||
export { EuiScreenReaderOnly } from './screen_reader'; | ||
export { EuiSkipLink } from './skip_link'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import classNames from 'classnames'; | ||
import { EuiScreenReaderOnly } from '../accessibility/screen_reader'; | ||
|
||
export interface EuiSkipLinkProps { | ||
/** | ||
* Typically an anchor id (e.g. `#a11yMainContent`), the value provided here | ||
* equates to the href for the link. | ||
*/ | ||
destination: string; | ||
|
||
/** | ||
* The text to be displayed as a link. | ||
*/ | ||
label: string; | ||
|
||
tabIndex?: number; | ||
} | ||
|
||
export const EuiSkipLink: FunctionComponent<EuiSkipLinkProps> = ({ | ||
destination, | ||
label, | ||
tabIndex = 0, | ||
}) => { | ||
const classes = classNames('euiSkipLink'); | ||
|
||
return ( | ||
<EuiScreenReaderOnly showOnFocus> | ||
<a className={classes} href={destination} tabIndex={tabIndex}> | ||
{label} | ||
</a> | ||
</EuiScreenReaderOnly> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters