mirror of
https://github.com/immich-app/immich.git
synced 2025-02-04 01:09:14 -05:00
feat(web): add skip link to top navigation (#7091)
* feat(web): add skip link to top nav * Styling skip link with tailwind
This commit is contained in:
parent
70e5febb72
commit
9c1dd373a5
5 changed files with 33 additions and 0 deletions
|
@ -66,6 +66,8 @@
|
||||||
{disabled}
|
{disabled}
|
||||||
{title}
|
{title}
|
||||||
on:click
|
on:click
|
||||||
|
on:focus
|
||||||
|
on:blur
|
||||||
class="{className} inline-flex items-center justify-center transition-colors disabled:cursor-not-allowed disabled:opacity-60 {colorClasses[
|
class="{className} inline-flex items-center justify-center transition-colors disabled:cursor-not-allowed disabled:opacity-60 {colorClasses[
|
||||||
color
|
color
|
||||||
]} {sizeClasses[size]}"
|
]} {sizeClasses[size]}"
|
||||||
|
|
27
web/src/lib/components/elements/buttons/skip-link.svelte
Normal file
27
web/src/lib/components/elements/buttons/skip-link.svelte
Normal file
|
@ -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>
|
|
@ -23,6 +23,7 @@
|
||||||
<slot name="header" />
|
<slot name="header" />
|
||||||
</header>
|
</header>
|
||||||
<main
|
<main
|
||||||
|
tabindex="-1"
|
||||||
class="relative grid h-screen grid-cols-[theme(spacing.18)_auto] overflow-hidden bg-immich-bg pt-[var(--navbar-height)] dark:bg-immich-dark-bg md:grid-cols-[theme(spacing.64)_auto]"
|
class="relative grid h-screen grid-cols-[theme(spacing.18)_auto] overflow-hidden bg-immich-bg pt-[var(--navbar-height)] dark:bg-immich-dark-bg md:grid-cols-[theme(spacing.64)_auto]"
|
||||||
>
|
>
|
||||||
<slot name="sidebar">
|
<slot name="sidebar">
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import IconButton from '$lib/components/elements/buttons/icon-button.svelte';
|
import IconButton from '$lib/components/elements/buttons/icon-button.svelte';
|
||||||
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
||||||
|
import SkipLink from '$lib/components/elements/buttons/skip-link.svelte';
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
import { resetSavedUser, user } from '$lib/stores/user.store';
|
import { resetSavedUser, user } from '$lib/stores/user.store';
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section id="dashboard-navbar" class="fixed z-[900] h-[var(--navbar-height)] w-screen text-sm">
|
<section id="dashboard-navbar" class="fixed z-[900] h-[var(--navbar-height)] w-screen text-sm">
|
||||||
|
<SkipLink>Skip to content</SkipLink>
|
||||||
<div
|
<div
|
||||||
class="grid h-full grid-cols-[theme(spacing.18)_auto] items-center border-b bg-immich-bg py-2 dark:border-b-immich-dark-gray dark:bg-immich-dark-bg md:grid-cols-[theme(spacing.64)_auto]"
|
class="grid h-full grid-cols-[theme(spacing.18)_auto] items-center border-b bg-immich-bg py-2 dark:border-b-immich-dark-gray dark:bg-immich-dark-bg md:grid-cols-[theme(spacing.64)_auto]"
|
||||||
>
|
>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
<section
|
<section
|
||||||
id="sidebar"
|
id="sidebar"
|
||||||
|
tabindex="-1"
|
||||||
class="immich-scrollbar group relative z-10 flex w-18 flex-col gap-1 overflow-y-auto bg-immich-bg pt-8 transition-all duration-200 dark:bg-immich-dark-bg hover:sm:w-64 hover:sm:border-r hover:sm:pr-6 hover:sm:shadow-2xl hover:sm:dark:border-r-immich-dark-gray md:w-64 md:pr-6 hover:md:border-none hover:md:shadow-none"
|
class="immich-scrollbar group relative z-10 flex w-18 flex-col gap-1 overflow-y-auto bg-immich-bg pt-8 transition-all duration-200 dark:bg-immich-dark-bg hover:sm:w-64 hover:sm:border-r hover:sm:pr-6 hover:sm:shadow-2xl hover:sm:dark:border-r-immich-dark-gray md:w-64 md:pr-6 hover:md:border-none hover:md:shadow-none"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|
Loading…
Add table
Reference in a new issue