Keyboard Accessibility Fix: "Skip to content" link for documentation pages. (#480)
* As part of accessibility requirements, Users who rely on keyboard for navigation should have a way to bypass repetitive content while navigating with Tab key. The concept of 'Skip to main content' link is to click it to go directly to main content, instead of traversing across the entire side-bar, headers, table of contents etc. * Linting
This commit is contained in:
Родитель
61d5ee8ce0
Коммит
c77cfff7fe
|
@ -35,6 +35,18 @@ export const logoImageStyle = mergeStyles({
|
||||||
lineHeight: "1",
|
lineHeight: "1",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const skipContentStyle = mergeStyles({
|
||||||
|
left: "50%",
|
||||||
|
position: "absolute",
|
||||||
|
transform: "translateY(-250%)",
|
||||||
|
padding: "8px",
|
||||||
|
transition: "transform 0.3s",
|
||||||
|
|
||||||
|
"&:focus": {
|
||||||
|
transform: "translateY(0%)",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const headerPipeStyle = mergeStyles({
|
export const headerPipeStyle = mergeStyles({
|
||||||
marginTop: "0px !important",
|
marginTop: "0px !important",
|
||||||
marginLeft: "7px !important",
|
marginLeft: "7px !important",
|
||||||
|
|
|
@ -9,6 +9,7 @@ import DocsHtmlContent from "./components/DocsHtmlContent";
|
||||||
import Topic from "./components/Topic";
|
import Topic from "./components/Topic";
|
||||||
import { DATA_URL, SAS_URL, STAC_URL } from "../../utils/constants";
|
import { DATA_URL, SAS_URL, STAC_URL } from "../../utils/constants";
|
||||||
import ScrollToTop from "../../components/ScrollToTop";
|
import ScrollToTop from "../../components/ScrollToTop";
|
||||||
|
import { skipContentStyle } from "components/Header/styles";
|
||||||
|
|
||||||
const OpenApiSpec = React.lazy(() => import("./components/OpenApiSpec"));
|
const OpenApiSpec = React.lazy(() => import("./components/OpenApiSpec"));
|
||||||
|
|
||||||
|
@ -59,6 +60,15 @@ const Docs = () => {
|
||||||
|
|
||||||
const documentationPane = (
|
const documentationPane = (
|
||||||
<div className="grid-content" style={docPageStyle}>
|
<div className="grid-content" style={docPageStyle}>
|
||||||
|
<Link
|
||||||
|
className={skipContentStyle}
|
||||||
|
onClick={() => {
|
||||||
|
const urlWithoutHash = window.location.href.split("#")[0];
|
||||||
|
window.location.href = urlWithoutHash + "#generated-docs-content";
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Skip to content
|
||||||
|
</Link>
|
||||||
{tocComponent}
|
{tocComponent}
|
||||||
<div style={docContentStyle}>
|
<div style={docContentStyle}>
|
||||||
{breadcrumb}
|
{breadcrumb}
|
||||||
|
|
|
@ -9,12 +9,14 @@ import { a11yPostProcessDom } from "../../../utils";
|
||||||
interface DocsHtmlContentProps {
|
interface DocsHtmlContentProps {
|
||||||
className: string;
|
className: string;
|
||||||
markupJson: any;
|
markupJson: any;
|
||||||
|
idText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DocsHtmlContent: React.FC<DocsHtmlContentProps> = ({
|
const DocsHtmlContent: React.FC<DocsHtmlContentProps> = ({
|
||||||
className,
|
className,
|
||||||
markupJson,
|
markupJson,
|
||||||
children,
|
children,
|
||||||
|
idText,
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const contentRef = useRef<HTMLDivElement>(null);
|
const contentRef = useRef<HTMLDivElement>(null);
|
||||||
|
@ -114,7 +116,7 @@ const DocsHtmlContent: React.FC<DocsHtmlContentProps> = ({
|
||||||
: DOMPurify.sanitize(bodyWithRoutedLinks);
|
: DOMPurify.sanitize(bodyWithRoutedLinks);
|
||||||
|
|
||||||
const content = processedMarkup ? (
|
const content = processedMarkup ? (
|
||||||
<div className={className}>
|
<div className={className} id={idText}>
|
||||||
{children}
|
{children}
|
||||||
<div
|
<div
|
||||||
ref={contentRef}
|
ref={contentRef}
|
||||||
|
|
|
@ -27,6 +27,7 @@ const Topic: React.FC<TopicProps> = ({ topics }) => {
|
||||||
<>
|
<>
|
||||||
<div style={bodyStyle}>
|
<div style={bodyStyle}>
|
||||||
<DocsHtmlContent
|
<DocsHtmlContent
|
||||||
|
idText="generated-docs-content"
|
||||||
className="generated-docs markdown-source"
|
className="generated-docs markdown-source"
|
||||||
markupJson={doc}
|
markupJson={doc}
|
||||||
/>
|
/>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче