mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
improve header accessibility
add skip navigation link + minor fixes
This commit is contained in:
parent
7aaaf998a8
commit
6d7e92d73b
5 changed files with 42 additions and 0 deletions
|
@ -2055,5 +2055,6 @@
|
||||||
"added to": "added to",
|
"added to": "added to",
|
||||||
"removed from": "removed from",
|
"removed from": "removed from",
|
||||||
"Item removed from Watch Later": "Item removed from Watch Later",
|
"Item removed from Watch Later": "Item removed from Watch Later",
|
||||||
|
"Skip navigation": "Skip navigation",
|
||||||
"--end--": "--end--"
|
"--end--": "--end--"
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,24 @@ type Props = {
|
||||||
activeChannelStakedLevel: number,
|
activeChannelStakedLevel: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
@ -254,6 +272,7 @@ const Header = (props: Props) => {
|
||||||
<Button
|
<Button
|
||||||
className="header__navigation-item header__navigation-item--lbry"
|
className="header__navigation-item header__navigation-item--lbry"
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
|
aria-label={__('Home')}
|
||||||
label={'LBRY'}
|
label={'LBRY'}
|
||||||
// @endif
|
// @endif
|
||||||
// @if TARGET='web'
|
// @if TARGET='web'
|
||||||
|
@ -271,6 +290,8 @@ const Header = (props: Props) => {
|
||||||
{...homeButtonNavigationProps}
|
{...homeButtonNavigationProps}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SkipNavigationButton />
|
||||||
|
|
||||||
{!authHeader && (
|
{!authHeader && (
|
||||||
<div className="header__center">
|
<div className="header__center">
|
||||||
{/* @if TARGET='app' */}
|
{/* @if TARGET='app' */}
|
||||||
|
|
|
@ -109,6 +109,7 @@ function Page(props: Props) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<main
|
<main
|
||||||
|
id={'main-content'}
|
||||||
className={classnames(MAIN_CLASS, className, {
|
className={classnames(MAIN_CLASS, className, {
|
||||||
'main--full-width': fullWidthPage,
|
'main--full-width': fullWidthPage,
|
||||||
'main--auth-page': authPage,
|
'main--auth-page': authPage,
|
||||||
|
|
|
@ -326,6 +326,7 @@ function SideNavigation(props: Props) {
|
||||||
>
|
>
|
||||||
{!isOnFilePage && (
|
{!isOnFilePage && (
|
||||||
<nav
|
<nav
|
||||||
|
aria-label={'Sidebar'}
|
||||||
className={classnames('navigation', {
|
className={classnames('navigation', {
|
||||||
'navigation--micro': microNavigation,
|
'navigation--micro': microNavigation,
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
|
|
|
@ -9,6 +9,24 @@
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-webkit-app-region: drag;
|
-webkit-app-region: drag;
|
||||||
|
|
||||||
|
.skip-button {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
margin: 0 var(--spacing-s);
|
||||||
|
&:focus {
|
||||||
|
opacity: 1;
|
||||||
|
position: relative;
|
||||||
|
overflow: unset;
|
||||||
|
width: inherit;
|
||||||
|
height: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
& > * {
|
& > * {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue