-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): add skip link to top navigation (#7091)
* feat(web): add skip link to top nav * Styling skip link with tailwind
- Loading branch information
1 parent
70e5feb
commit 9c1dd37
Showing
5 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts"> | ||
import Button from './button.svelte'; | ||
/** | ||
* Target for the skip link to move focus to. | ||
*/ | ||
export let target: string = 'main'; | ||
let isFocused = false; | ||
const moveFocus = () => { | ||
const targetEl = document.querySelector<HTMLElement>(target); | ||
targetEl?.focus(); | ||
}; | ||
</script> | ||
|
||
<div class="absolute top-2 left-2 transition-transform {isFocused ? 'translate-y-0' : '-translate-y-10 sr-only'}"> | ||
<Button | ||
size={'sm'} | ||
rounded={false} | ||
on:click={moveFocus} | ||
on:focus={() => (isFocused = true)} | ||
on:blur={() => (isFocused = false)} | ||
> | ||
<slot /> | ||
</Button> | ||
</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
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