add SkipNavigationButton to its own file
This commit is contained in:
parent
f6261611f0
commit
6a8d32c9bf
3 changed files with 26 additions and 20 deletions
|
@ -2059,5 +2059,8 @@
|
||||||
"by %channelTitle%": "by %channelTitle%",
|
"by %channelTitle%": "by %channelTitle%",
|
||||||
"Reset": "Reset",
|
"Reset": "Reset",
|
||||||
"Reset to original (previous) publish date": "Reset to original (previous) publish date",
|
"Reset to original (previous) publish date": "Reset to original (previous) publish date",
|
||||||
|
"Trending for #Art": "Trending for #Art",
|
||||||
|
"Trending for #Education": "Trending for #Education",
|
||||||
|
"Trending for #Technology": "Trending for #Technology",
|
||||||
"--end--": "--end--"
|
"--end--": "--end--"
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { useIsMobile } from 'effects/use-screensize';
|
||||||
import NotificationBubble from 'component/notificationBubble';
|
import NotificationBubble from 'component/notificationBubble';
|
||||||
import NotificationHeaderButton from 'component/notificationHeaderButton';
|
import NotificationHeaderButton from 'component/notificationHeaderButton';
|
||||||
import ChannelThumbnail from 'component/channelThumbnail';
|
import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
|
import SkipNavigationButton from 'component/skipNavigationButton';
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
import { remote } from 'electron';
|
import { remote } from 'electron';
|
||||||
import { IS_MAC } from 'component/app/view';
|
import { IS_MAC } from 'component/app/view';
|
||||||
|
@ -64,26 +65,6 @@ type Props = {
|
||||||
activeChannelStakedLevel: number,
|
activeChannelStakedLevel: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Allow screen reader users ( or keyboard navigation )
|
|
||||||
// to jump to main content
|
|
||||||
const SkipNavigationButton = () => {
|
|
||||||
const skipNavigation = (e) => {
|
|
||||||
// Match any focusable element
|
|
||||||
const focusableElementQuery = `
|
|
||||||
#main-content [tabindex]:not([tabindex="-1"]):not(:disabled),
|
|
||||||
#main-content a:not([aria-hidden]):not([tabindex="-1"]):not(:disabled),
|
|
||||||
#main-content button:not([aria-hidden]):not([tabindex="-1"]):not(:disabled)
|
|
||||||
`;
|
|
||||||
// Find first focusable element
|
|
||||||
const element = document.querySelector(focusableElementQuery);
|
|
||||||
// Trigger focus to skip navigation
|
|
||||||
if (element && element.focus) {
|
|
||||||
element.focus();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return <Button className={'skip-button'} onClick={skipNavigation} label={__('Skip Navigation')} button={'link'} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Header = (props: Props) => {
|
const Header = (props: Props) => {
|
||||||
const {
|
const {
|
||||||
balance,
|
balance,
|
||||||
|
|
22
ui/component/skipNavigationButton/index.jsx
Normal file
22
ui/component/skipNavigationButton/index.jsx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// @flow
|
||||||
|
import React from 'react';
|
||||||
|
import Button from 'component/button';
|
||||||
|
// Allow screen reader users ( or keyboard navigation )
|
||||||
|
// to jump to main content
|
||||||
|
export default function SkipNavigationButton() {
|
||||||
|
const skipNavigation = (e) => {
|
||||||
|
// Match any focusable element
|
||||||
|
const focusableElementQuery = `
|
||||||
|
#main-content [tabindex]:not([tabindex="-1"]):not(:disabled),
|
||||||
|
#main-content a:not([aria-hidden]):not([tabindex="-1"]):not(:disabled),
|
||||||
|
#main-content button:not([aria-hidden]):not([tabindex="-1"]):not(:disabled)
|
||||||
|
`;
|
||||||
|
// Find first focusable element
|
||||||
|
const element = document.querySelector(focusableElementQuery);
|
||||||
|
// Trigger focus to skip navigation
|
||||||
|
if (element && element.focus) {
|
||||||
|
element.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return <Button className={'skip-button'} onClick={skipNavigation} label={__('Skip Navigation')} button={'link'} />;
|
||||||
|
}
|
Loading…
Reference in a new issue