feat: improve semantic nav/main tags (#17800)

feat: nav/main elements

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Min Idzelis 2025-04-29 13:51:39 -04:00 committed by GitHub
parent d9ce74b896
commit 07290580a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 111 additions and 113 deletions

View File

@ -49,7 +49,7 @@
{@render header?.()} {@render header?.()}
</header> </header>
<main <div
tabindex="-1" tabindex="-1"
class="relative grid h-dvh grid-cols-[theme(spacing.0)_auto] overflow-hidden bg-immich-bg max-md:pt-[var(--navbar-height-md)] pt-[var(--navbar-height)] dark:bg-immich-dark-bg sidebar:grid-cols-[theme(spacing.64)_auto]" class="relative grid h-dvh grid-cols-[theme(spacing.0)_auto] overflow-hidden bg-immich-bg max-md:pt-[var(--navbar-height-md)] pt-[var(--navbar-height)] dark:bg-immich-dark-bg sidebar:grid-cols-[theme(spacing.64)_auto]"
> >
@ -59,7 +59,7 @@
<SideBar /> <SideBar />
{/if} {/if}
<section class="relative"> <main class="relative">
{#if title || buttons} {#if title || buttons}
<div <div
class="absolute flex h-16 w-full place-items-center justify-between border-b p-2 dark:border-immich-dark-gray dark:text-immich-dark-fg" class="absolute flex h-16 w-full place-items-center justify-between border-b p-2 dark:border-immich-dark-gray dark:text-immich-dark-fg"
@ -79,5 +79,5 @@
<div class="{scrollbarClass} absolute {hasTitleClass} w-full overflow-y-auto" use:useActions={use}> <div class="{scrollbarClass} absolute {hasTitleClass} w-full overflow-y-auto" use:useActions={use}>
{@render children?.()} {@render children?.()}
</div> </div>
</section> </main>
</main> </div>

View File

@ -67,7 +67,7 @@
</script> </script>
<div in:fly={{ y: 10, duration: 200 }} class="absolute top-0 w-full z-[100] bg-transparent"> <div in:fly={{ y: 10, duration: 200 }} class="absolute top-0 w-full z-[100] bg-transparent">
<div <nav
id="asset-selection-app-bar" id="asset-selection-app-bar"
class={[ class={[
'grid', 'grid',
@ -94,5 +94,5 @@
<div class="me-4 flex place-items-center gap-1 justify-self-end"> <div class="me-4 flex place-items-center gap-1 justify-self-end">
{@render trailing?.()} {@render trailing?.()}
</div> </div>
</div> </nav>
</div> </div>

View File

@ -55,7 +55,7 @@
<HelpAndFeedbackModal onClose={() => (shouldShowHelpPanel = false)} {info} /> <HelpAndFeedbackModal onClose={() => (shouldShowHelpPanel = false)} {info} />
{/if} {/if}
<section <nav
id="dashboard-navbar" id="dashboard-navbar"
class="fixed z-[900] max-md:h-[var(--navbar-height-md)] h-[var(--navbar-height)] w-dvw text-sm" class="fixed z-[900] max-md:h-[var(--navbar-height-md)] h-[var(--navbar-height)] w-dvw text-sm"
> >
@ -209,4 +209,4 @@
</section> </section>
</div> </div>
</div> </div>
</section> </nav>

View File

@ -7,14 +7,12 @@
import { t } from 'svelte-i18n'; import { t } from 'svelte-i18n';
</script> </script>
<SideBarSection> <SideBarSection ariaLabel={$t('primary')}>
<nav aria-label={$t('primary')}>
<SideBarLink title={$t('users')} routeId={AppRoute.ADMIN_USER_MANAGEMENT} icon={mdiAccountMultipleOutline} /> <SideBarLink title={$t('users')} routeId={AppRoute.ADMIN_USER_MANAGEMENT} icon={mdiAccountMultipleOutline} />
<SideBarLink title={$t('jobs')} routeId={AppRoute.ADMIN_JOBS} icon={mdiSync} /> <SideBarLink title={$t('jobs')} routeId={AppRoute.ADMIN_JOBS} icon={mdiSync} />
<SideBarLink title={$t('settings')} routeId={AppRoute.ADMIN_SETTINGS} icon={mdiCog} /> <SideBarLink title={$t('settings')} routeId={AppRoute.ADMIN_SETTINGS} icon={mdiCog} />
<SideBarLink title={$t('external_libraries')} routeId={AppRoute.ADMIN_LIBRARY_MANAGEMENT} icon={mdiBookshelf} /> <SideBarLink title={$t('external_libraries')} routeId={AppRoute.ADMIN_LIBRARY_MANAGEMENT} icon={mdiBookshelf} />
<SideBarLink title={$t('server_stats')} routeId={AppRoute.ADMIN_STATS} icon={mdiServer} /> <SideBarLink title={$t('server_stats')} routeId={AppRoute.ADMIN_STATS} icon={mdiServer} />
</nav>
<BottomInfo /> <BottomInfo />
</SideBarSection> </SideBarSection>

View File

@ -7,10 +7,11 @@
import { onMount, type Snippet } from 'svelte'; import { onMount, type Snippet } from 'svelte';
interface Props { interface Props {
ariaLabel?: string;
children?: Snippet; children?: Snippet;
} }
let { children }: Props = $props(); let { ariaLabel, children }: Props = $props();
const isHidden = $derived(!sidebarStore.isOpen && !mobileDevice.isFullSidebar); const isHidden = $derived(!sidebarStore.isOpen && !mobileDevice.isFullSidebar);
const isExpanded = $derived(sidebarStore.isOpen && !mobileDevice.isFullSidebar); const isExpanded = $derived(sidebarStore.isOpen && !mobileDevice.isFullSidebar);
@ -30,8 +31,9 @@
}; };
</script> </script>
<section <nav
id="sidebar" id="sidebar"
aria-label={ariaLabel}
tabindex="-1" tabindex="-1"
class="immich-scrollbar relative z-10 w-0 sidebar:w-[16rem] overflow-y-auto overflow-x-hidden bg-immich-bg pt-8 transition-all duration-200 dark:bg-immich-dark-bg" class="immich-scrollbar relative z-10 w-0 sidebar:w-[16rem] overflow-y-auto overflow-x-hidden bg-immich-bg pt-8 transition-all duration-200 dark:bg-immich-dark-bg"
class:shadow-2xl={isExpanded} class:shadow-2xl={isExpanded}
@ -46,4 +48,4 @@
<div class="pe-6 flex flex-col gap-1 h-max min-h-full"> <div class="pe-6 flex flex-col gap-1 h-max min-h-full">
{@render children?.()} {@render children?.()}
</div> </div>
</section> </nav>

View File

@ -42,8 +42,7 @@
let isUtilitiesSelected: boolean = $state(false); let isUtilitiesSelected: boolean = $state(false);
</script> </script>
<SideBarSection> <SideBarSection ariaLabel={$t('primary')}>
<nav aria-label={$t('primary')}>
<SideBarLink <SideBarLink
title={$t('photos')} title={$t('photos')}
routeId="/(user)/photos" routeId="/(user)/photos"
@ -137,7 +136,6 @@
icon={isTrashSelected ? mdiTrashCan : mdiTrashCanOutline} icon={isTrashSelected ? mdiTrashCan : mdiTrashCanOutline}
></SideBarLink> ></SideBarLink>
{/if} {/if}
</nav>
<BottomInfo /> <BottomInfo />
</SideBarSection> </SideBarSection>