added breadcrumbs and update layouts

pull/3/head
TZGyn 2 years ago
parent ca55b04492
commit 27e732940a
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

Binary file not shown.

@ -41,7 +41,7 @@
"cmdk-sv": "^0.0.13",
"drizzle-orm": "^0.29.0",
"he": "^1.2.0",
"lucide-svelte": "^0.292.0",
"lucide-svelte": "^0.356.0",
"mode-watcher": "^0.1.2",
"nanoid": "^5.0.3",
"node-html-parser": "^6.1.12",

@ -1,13 +1,8 @@
<script lang="ts">
import { page } from '$app/stores'
import UserIcon from './UserIcon.svelte'
import { Separator } from '$lib/components/ui/separator'
import ThemeToggle from './theme-toggle.svelte'
import { Button } from '$lib/components/ui/button'
import { cn } from '$lib/utils'
export let email: string = ''
let className: string | undefined = undefined
export { className as class }
@ -25,14 +20,6 @@
className,
)}>
<div>
<div class="flex h-20 items-center justify-between p-4">
<div class="flex items-center justify-start gap-4">
<UserIcon {email} />
{email}
</div>
<ThemeToggle />
</div>
<div class="flex flex-col gap-4 p-4">
{#each routes as route}
<Button

@ -0,0 +1,23 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements'
import { MoreHorizontal } from 'lucide-svelte'
import { cn } from '$lib/utils.js'
type $$Props = HTMLAttributes<HTMLSpanElement> & {
el?: HTMLSpanElement
}
export let el: $$Props['el'] = undefined
let className: $$Props['class'] = undefined
export { className as class }
</script>
<span
bind:this={el}
role="presentation"
aria-hidden="true"
class={cn('flex h-9 w-9 items-center justify-center', className)}
{...$$restProps}>
<MoreHorizontal class="h-4 w-4" />
<span class="sr-only">More</span>
</span>

@ -0,0 +1,16 @@
<script lang="ts">
import type { HTMLLiAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
type $$Props = HTMLLiAttributes & {
el?: HTMLLIElement;
};
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<li bind:this={el} class={cn("inline-flex items-center gap-1.5", className)}>
<slot />
</li>

@ -0,0 +1,34 @@
<script lang="ts">
import type { HTMLAnchorAttributes } from 'svelte/elements'
import { cn } from '$lib/utils.js'
type $$Props = HTMLAnchorAttributes & {
el?: HTMLAnchorElement
asChild?: boolean
}
export let href: $$Props['href'] = undefined
export let el: $$Props['el'] = undefined
export let asChild: $$Props['asChild'] = false
let className: $$Props['class'] = undefined
export { className as class }
let attrs: Record<string, unknown>
$: attrs = {
class: cn(
'transition-colors hover:text-foreground hover:cursor-pointer',
className,
),
href,
...$$restProps,
}
</script>
{#if asChild}
<slot {attrs} />
{:else}
<a bind:this={el} {...attrs} {href}>
<slot {attrs} />
</a>
{/if}

@ -0,0 +1,23 @@
<script lang="ts">
import type { HTMLOlAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
type $$Props = HTMLOlAttributes & {
el?: HTMLOListElement;
};
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<ol
bind:this={el}
class={cn(
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
className
)}
{...$$restProps}
>
<slot />
</ol>

@ -0,0 +1,26 @@
<script lang="ts">
import type { HTMLAnchorAttributes } from 'svelte/elements'
import { cn } from '$lib/utils.js'
type $$Props = HTMLAnchorAttributes & {
el?: HTMLSpanElement
}
export let el: $$Props['el'] = undefined
export let className: $$Props['class'] = undefined
export let href: $$Props['href'] = undefined
export { className as class }
</script>
<a
bind:this={el}
aria-disabled="true"
aria-current="page"
{href}
class={cn(
'font-normal text-foreground hover:cursor-pointer',
className,
)}
{...$$restProps}>
<slot />
</a>

@ -0,0 +1,24 @@
<script lang="ts">
import type { HTMLLiAttributes } from 'svelte/elements'
import { ChevronRight } from 'lucide-svelte'
import { cn } from '$lib/utils.js'
type $$Props = HTMLLiAttributes & {
el?: HTMLLIElement
}
export let el: $$Props['el'] = undefined
let className: $$Props['class'] = undefined
export { className as class }
</script>
<li
role="presentation"
aria-hidden="true"
class={cn('[&>svg]:size-3.5', className)}
bind:this={el}
{...$$restProps}>
<slot>
<ChevronRight size={16} />
</slot>
</li>

@ -0,0 +1,15 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
type $$Props = HTMLAttributes<HTMLElement> & {
el?: HTMLElement;
};
export let el: $$Props["el"] = undefined;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<nav class={className} bind:this={el} aria-label="breadcrumb" {...$$restProps}>
<slot />
</nav>

@ -0,0 +1,25 @@
import Root from "./breadcrumb.svelte";
import Ellipsis from "./breadcrumb-ellipsis.svelte";
import Item from "./breadcrumb-item.svelte";
import Separator from "./breadcrumb-separator.svelte";
import Link from "./breadcrumb-link.svelte";
import List from "./breadcrumb-list.svelte";
import Page from "./breadcrumb-page.svelte";
export {
Root,
Ellipsis,
Item,
Separator,
Link,
List,
Page,
//
Root as Breadcrumb,
Ellipsis as BreadcrumbEllipsis,
Item as BreadcrumbItem,
Separator as BreadcrumbSeparator,
Link as BreadcrumbLink,
List as BreadcrumbList,
Page as BreadcrumbPage,
};

@ -3,9 +3,12 @@ import type { LayoutServerLoad } from './$types'
export const load = (async (event) => {
const user = event.locals.userObject
const breadcrumbs = [{ name: 'Home', path: '/' }]
return {
shortener_url:
process.env.PUBLIC_SHORTENER_URL ?? '3000.tzgyn.com',
user: user,
breadcrumbs,
}
}) satisfies LayoutServerLoad

@ -6,6 +6,9 @@
import { Menu } from 'lucide-svelte'
import UserIcon from '$lib/components/UserIcon.svelte'
import { Separator } from '$lib/components/ui/separator'
import ThemeToggle from '$lib/components/theme-toggle.svelte'
import * as Breadcrumb from '$lib/components/ui/breadcrumb'
import { page } from '$app/stores'
export let data: PageData
@ -16,55 +19,96 @@
}
</script>
<div class="flex h-screen w-full">
<Sidebar email={data.user.email} class="hidden lg:flex" />
<div
class="flex h-full max-h-screen w-full flex-col overflow-hidden">
<div class="flex h-screen w-full flex-col">
<div class="flex border-b">
<div
class="bg-background block w-full border-b px-4 py-2 lg:hidden">
<Sheet.Root bind:open={sheetOpen}>
<Sheet.Trigger asChild let:builder>
<Button builders={[builder]} variant="ghost" class="p-2">
<Menu />
</Button>
</Sheet.Trigger>
<Sheet.Content side="left" class="flex flex-col">
<Sheet.Header class="pb-16">
<Sheet.Title>Shortener</Sheet.Title>
</Sheet.Header>
<div class="flex grow flex-col gap-4">
<Button
on:click={closeSheet}
variant="ghost"
href="/"
class="justify-start text-base">Home</Button>
<Button
on:click={closeSheet}
variant="ghost"
href="/links"
class="justify-start text-base">Links</Button>
<Button
on:click={closeSheet}
variant="ghost"
href="/projects"
class="justify-start text-base ">Projects</Button>
</div>
<div class="flex flex-col justify-between">
<div></div>
<div class="flex flex-col gap-4">
<Separator />
<div class="flex items-center justify-between">
<UserIcon
email={data.user.email}
onClick={closeSheet} />
class="flex h-20 w-full items-center justify-between gap-6 p-4">
<UserIcon email={data.user.email} />
<div class="w-full">
<Breadcrumb.Root>
<Breadcrumb.List>
{#if $page.data.breadcrumbs}
{#each $page.data.breadcrumbs as breadcrumb, index}
{#if index == $page.data.breadcrumbs.length - 1}
<Breadcrumb.Item>
<Breadcrumb.Page href={breadcrumb.path}>
{breadcrumb.name}
</Breadcrumb.Page>
</Breadcrumb.Item>
{:else}
<Breadcrumb.Item>
<Breadcrumb.Link href={breadcrumb.path}>
{breadcrumb.name}
</Breadcrumb.Link>
</Breadcrumb.Item>
{/if}
{#if index != $page.data.breadcrumbs.length - 1}
<Breadcrumb.Separator />
{/if}
{/each}
{:else}
<Breadcrumb.Item>
<Breadcrumb.Link href={'/'}>Home</Breadcrumb.Link>
</Breadcrumb.Item>
{/if}
</Breadcrumb.List>
</Breadcrumb.Root>
</div>
<ThemeToggle />
</div>
</div>
<div class="flex h-full">
<Sidebar class="hidden lg:flex" />
<div
class="flex h-full max-h-screen w-full flex-col overflow-hidden">
<div
class="block w-full border-b bg-background px-4 py-2 lg:hidden">
<Sheet.Root bind:open={sheetOpen}>
<Sheet.Trigger asChild let:builder>
<Button builders={[builder]} variant="ghost" class="p-2">
<Menu />
</Button>
</Sheet.Trigger>
<Sheet.Content side="left" class="flex flex-col">
<Sheet.Header class="pb-16">
<Sheet.Title>Shortener</Sheet.Title>
</Sheet.Header>
<div class="flex grow flex-col gap-4">
<Button
on:click={closeSheet}
variant="ghost"
href="/"
class="justify-start text-base">Home</Button>
<Button
on:click={closeSheet}
variant="ghost"
href="/links"
class="justify-start text-base">Links</Button>
<Button
on:click={closeSheet}
variant="ghost"
href="/projects"
class="justify-start text-base ">Projects</Button>
</div>
<div class="flex flex-col justify-between">
<div></div>
<div class="flex flex-col gap-4">
<Separator />
<div class="flex items-center justify-between">
<UserIcon
email={data.user.email}
onClick={closeSheet} />
</div>
</div>
</div>
</div>
</Sheet.Content>
</Sheet.Root>
</div>
<div class="flex h-full w-full flex-col overflow-hidden">
<slot />
</Sheet.Content>
</Sheet.Root>
</div>
<div class="flex h-full w-full flex-col overflow-hidden">
<slot />
</div>
</div>
</div>
</div>

@ -0,0 +1,10 @@
import type { LayoutServerLoad } from './$types'
export const load = (async (event) => {
const { breadcrumbs: parentBreadcrumbs } = await event.parent()
const breadcrumbs = [
...parentBreadcrumbs,
{ name: 'Links', path: '/links' },
]
return { breadcrumbs }
}) satisfies LayoutServerLoad

@ -0,0 +1,10 @@
import type { LayoutServerLoad } from './$types'
export const load = (async (event) => {
const { breadcrumbs: parentBreadcrumbs } = await event.parent()
const breadcrumbs = [
...parentBreadcrumbs,
{ name: 'Projects', path: '/projects' },
]
return { breadcrumbs }
}) satisfies LayoutServerLoad

@ -0,0 +1,10 @@
import type { LayoutServerLoad } from './$types'
export const load = (async (event) => {
const { breadcrumbs: parentBreadcrumbs } = await event.parent()
const breadcrumbs = [
...parentBreadcrumbs,
{ name: 'Settings', path: '/settings' },
]
return { breadcrumbs }
}) satisfies LayoutServerLoad
Loading…
Cancel
Save