forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add showOnFocus prop to EuiScreenReader Only & Add EuiSkipLink (elast…
…ic#2976) * adds showOnFocus prop * add EuiSkipLink component * address feedback, add fixedToTop prop * addressing feedback * use EuiButton * Updated some props to be enums and extended EuiButton type and added tests * add snippets, as one does * remove tabIndex from fixed example * remove portal from docs example Co-authored-by: Caroline Horn <[email protected]>
- Loading branch information
1 parent
8c3ca5f
commit 4a27d09
Showing
17 changed files
with
455 additions
and
55 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
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,6 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { EuiScreenReaderOnlyProps } from '../../../../src/components/accessibility/screen_reader'; | ||
|
||
export const ScreenReaderOnlyDocsComponent: FunctionComponent< | ||
EuiScreenReaderOnlyProps | ||
> = () => <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,16 +1,51 @@ | ||
import React from 'react'; | ||
|
||
import { EuiScreenReaderOnly } from '../../../../src/components/accessibility/screen_reader'; | ||
import { EuiCallOut } from '../../../../src/components/call_out'; | ||
import { EuiText } from '../../../../src/components/text'; | ||
import { EuiTitle } from '../../../../src/components/title'; | ||
import { EuiLink } from '../../../../src/components/link'; | ||
|
||
export default () => ( | ||
<div> | ||
<p>This is the first paragraph. It is visible to all.</p> | ||
<EuiScreenReaderOnly> | ||
<EuiText> | ||
<EuiTitle size="xxs"> | ||
<h4>Visually hide content</h4> | ||
</EuiTitle> | ||
<p> | ||
This is the second paragraph. It is hidden for sighted users but visible | ||
to screen readers. | ||
<em> | ||
Use a screenreader to verify that there is a second paragraph in this | ||
example: | ||
</em> | ||
</p> | ||
</EuiScreenReaderOnly> | ||
<p>This is the third paragraph. It is visible to all.</p> | ||
<p>This is the first paragraph. It is visible to all.</p> | ||
<EuiScreenReaderOnly> | ||
<p> | ||
This is the second paragraph. It is hidden for sighted users but | ||
visible to screen readers. | ||
</p> | ||
</EuiScreenReaderOnly> | ||
<p>This is the third paragraph. It is visible to all.</p> | ||
<EuiTitle size="xxs"> | ||
<h4>Show on focus</h4> | ||
</EuiTitle> | ||
<p> | ||
<em> | ||
Tab through this section with your keyboard to display a ‘Skip | ||
navigation’ link: | ||
</em> | ||
</p> | ||
<p> | ||
This link is visible to all on focus:{' '} | ||
<EuiScreenReaderOnly showOnFocus> | ||
<EuiLink href="#">Skip navigation</EuiLink> | ||
</EuiScreenReaderOnly> | ||
</p> | ||
<EuiCallOut | ||
size="s" | ||
title="For a fully styled ‘Skip to main content’ solution, see the EuiSkipLink component in the next section." | ||
iconType="iInCircle" | ||
/> | ||
</EuiText> | ||
</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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { Fragment, useState } from 'react'; | ||
|
||
import { EuiSkipLink } from '../../../../src/components/accessibility/skip_link'; | ||
import { EuiCallOut } from '../../../../src/components/call_out'; | ||
import { EuiText } from '../../../../src/components/text'; | ||
import { EuiSpacer } from '../../../../src/components/spacer'; | ||
import { EuiSwitch } from '../../../../src/components/form/switch'; | ||
|
||
export default () => { | ||
const [isFixed, setFixed] = useState(false); | ||
|
||
return ( | ||
<Fragment> | ||
<EuiText> | ||
{isFixed ? ( | ||
<p> | ||
<em> | ||
Tab through this section and a fixed{' '} | ||
<strong>Skip to main content </strong> link will appear atop this | ||
page. | ||
</em> | ||
</p> | ||
) : ( | ||
<p> | ||
<em> | ||
Tab through this section and a <strong>Skip to content</strong>{' '} | ||
link will appear below. | ||
</em> | ||
</p> | ||
)} | ||
</EuiText> | ||
<EuiSpacer /> | ||
<EuiSwitch | ||
label="Fix link to top of screen" | ||
checked={isFixed} | ||
onChange={e => setFixed(e.target.checked)} | ||
/> | ||
<EuiSpacer /> | ||
{isFixed ? ( | ||
<Fragment> | ||
<EuiSkipLink | ||
destinationId="/utilities/accessibility" | ||
position="fixed"> | ||
Skip to main content | ||
</EuiSkipLink> | ||
<EuiCallOut | ||
size="s" | ||
title="A functional ‘Skip to main content’ link will be added to the EUI docs site once our URL format is updated." | ||
iconType="iInCircle" | ||
/> | ||
</Fragment> | ||
) : ( | ||
<EuiSkipLink | ||
destinationId="/utilities/accessibility" | ||
data-test-subj="skip-link-demo-subj"> | ||
Skip to content | ||
</EuiSkipLink> | ||
)} | ||
</Fragment> | ||
); | ||
}; |
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
Oops, something went wrong.