webui/src/routes/+layout.svelte

50 lines
1.1 KiB
Svelte
Raw Normal View History

2023-11-17 00:05:35 +00:00
<script lang="ts">
import {
Navbar,
NavbarBrand,
Nav,
NavItem,
NavLink,
Collapse,
Dropdown,
DropdownMenu,
DropdownItem,
DropdownToggle
} from 'sveltestrap';
2023-11-17 12:12:22 +00:00
import { locale, locales, waitLocale } from 'svelte-i18n';
import type { LayoutLoad } from './$types';
import { browser } from '$app/environment';
2023-11-17 18:10:46 +00:00
import { page } from '$app/stores';
2023-11-17 00:05:35 +00:00
export const setLocale = (lang: string) => () => {
locale.set(lang);
2023-11-17 12:12:22 +00:00
localStorage.setItem("locale", lang)
2023-11-17 00:05:35 +00:00
}
</script>
<Navbar expand="md">
<NavbarBrand>&#8383;TClock</NavbarBrand>
<Collapse navbar expand="md">
<Nav class="me-auto" navbar>
<NavItem>
2023-11-17 18:10:46 +00:00
<NavLink href="/" active="{$page.url.pathname === ("/")}">Home</NavLink>
2023-11-17 00:05:35 +00:00
</NavItem>
<NavItem>
2023-11-17 18:10:46 +00:00
<NavLink href="/api" active="{$page.url.pathname === ("/api")}">API</NavLink>
2023-11-17 00:05:35 +00:00
</NavItem>
</Nav>
<Dropdown inNavbar>
<DropdownToggle nav caret>{$locale}</DropdownToggle>
<DropdownMenu end>
{#each $locales as locale}
<DropdownItem on:click={setLocale(locale)}>{locale}</DropdownItem>
{/each}
</DropdownMenu>
</Dropdown>
</Collapse>
</Navbar>
<!-- +layout.svelte -->
<slot />