2024-02-18 03:34:27 +00:00
|
|
|
<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>
|
|
|
|
|
|
2024-03-19 12:56:41 +00:00
|
|
|
<div class="absolute z-50 top-2 left-2 transition-transform {isFocused ? 'translate-y-0' : '-translate-y-10 sr-only'}">
|
2024-02-18 03:34:27 +00:00
|
|
|
<Button
|
|
|
|
|
size={'sm'}
|
|
|
|
|
rounded={false}
|
|
|
|
|
on:click={moveFocus}
|
|
|
|
|
on:focus={() => (isFocused = true)}
|
|
|
|
|
on:blur={() => (isFocused = false)}
|
|
|
|
|
>
|
|
|
|
|
<slot />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|