Skip to content

Commit

Permalink
feat: skip to main content button
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc authored and tiensonqin committed Aug 26, 2022
1 parent 5ff79cb commit c3799b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/accessibility.spec.ts
Expand Up @@ -7,4 +7,4 @@ test('check a11y for the whole page', async ({ page }) => {
await injectAxe(page)
await createRandomPage(page)
await checkA11y(page)
})
})
7 changes: 6 additions & 1 deletion src/main/frontend/components/sidebar.cljs
Expand Up @@ -602,7 +602,12 @@
{:class (util/classnames [{:ls-left-sidebar-open left-sidebar-open?
:ls-right-sidebar-open sidebar-open?
:ls-wide-mode wide-mode?}])}

[:button#skip-to-main
{:click #(.focus (gdom/getElement "#main-content-container"))
:on-key-press (fn [e]
(when (= (.-key e) "Enter")
(.focus (gdom/getElement "#main-content-container"))))}
"Skip to main content"]
[:div.#app-container
[:div#left-container
{:class (if (state/sub :ui/sidebar-open?) "overflow-hidden" "w-full")}
Expand Down
14 changes: 14 additions & 0 deletions src/main/frontend/components/sidebar.css
Expand Up @@ -25,6 +25,20 @@
flex: 0 0 100%;
}

#skip-to-main {
@apply fixed p-2 rounded;

left: 50%;
transform: translate(-50%, 0);
background-color: var(--ls-secondary-background-color);
top: -100px;
z-index: 10000;

&:focus {
top: 20px;
}
}

#left-container {
@apply flex flex-1 flex-col relative h-screen;
}
Expand Down

0 comments on commit c3799b3

Please sign in to comment.