Update README.md #51
9 changed files with 95 additions and 41 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
@import 'tailwindcss/base';
|
@import 'tailwindcss/base';
|
||||||
@import 'tailwindcss/components';
|
@import 'tailwindcss/components';
|
||||||
@import 'tailwindcss/utilities';
|
@import 'tailwindcss/utilities';
|
||||||
@import '@flaticon/flaticon-uicons/css/all/all';
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||||
"nav_greeting": "Hello {name}!",
|
"nav_greeting": "Hello {name}!",
|
||||||
|
"nav_menu_sms": "SMS",
|
||||||
|
"nav_menu_settings": "Settings",
|
||||||
|
"nav_menu_logout": "Logout",
|
||||||
"login_tab_login": "Login",
|
"login_tab_login": "Login",
|
||||||
"login_tab_register": "Register",
|
"login_tab_register": "Register",
|
||||||
"login_label_email": "Email",
|
"login_label_email": "Email",
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,23 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { DaisyColor, DaisySize } from '$lib/types';
|
import type { DaisyColor, DaisySize } from '$lib/types';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
import type { HTMLInputTypeAttribute } from 'svelte/elements';
|
import type { HTMLInputTypeAttribute, SvelteHTMLElements } from 'svelte/elements';
|
||||||
import { fade as fadeTransition } from 'svelte/transition';
|
import { fade as fadeTransition } from 'svelte/transition';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
bordered?: boolean;
|
bordered?: boolean;
|
||||||
color?: Exclude<DaisyColor, 'neutral'>;
|
color?: Exclude<DaisyColor, 'neutral'>;
|
||||||
disabled?: boolean;
|
|
||||||
error?: string | Snippet;
|
error?: string | Snippet;
|
||||||
fade?: boolean;
|
fade?: boolean;
|
||||||
start?: string | Snippet;
|
start?: string | Snippet;
|
||||||
end?: string | Snippet;
|
end?: string | Snippet;
|
||||||
label?: string | Snippet;
|
label?: string | Snippet;
|
||||||
name: string;
|
|
||||||
placeholder?: string;
|
|
||||||
size?: DaisySize;
|
size?: DaisySize;
|
||||||
type?: Extract<
|
type?: Extract<
|
||||||
HTMLInputTypeAttribute,
|
HTMLInputTypeAttribute,
|
||||||
'email' | 'password' | 'search' | 'tel' | 'text' | 'url'
|
'email' | 'password' | 'search' | 'tel' | 'text' | 'url'
|
||||||
>;
|
>;
|
||||||
};
|
} & Omit<SvelteHTMLElements['input'], 'type'>;
|
||||||
|
|
||||||
let {
|
let {
|
||||||
bordered = false,
|
bordered = false,
|
||||||
|
|
@ -35,10 +32,11 @@
|
||||||
placeholder,
|
placeholder,
|
||||||
size,
|
size,
|
||||||
type = 'text',
|
type = 'text',
|
||||||
|
...props
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="form-control w-full">
|
<label class="form-control w-full" transition:fadeTransition={{ duration: fade ? 200 : 0 }}>
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<span
|
<span
|
||||||
class="label-text"
|
class="label-text"
|
||||||
|
|
@ -65,7 +63,6 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
transition:fadeTransition={{ duration: fade ? 200 : 0 }}
|
|
||||||
class="input flex w-full items-center gap-2"
|
class="input flex w-full items-center gap-2"
|
||||||
class:input-bordered={bordered}
|
class:input-bordered={bordered}
|
||||||
class:input-xs={size === 'xs'}
|
class:input-xs={size === 'xs'}
|
||||||
|
|
@ -85,7 +82,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
{@render start?.()}
|
{@render start?.()}
|
||||||
{/if}
|
{/if}
|
||||||
<input {disabled} {name} {placeholder} {type} class="grow" />
|
<input {...props} {disabled} {name} {placeholder} {type} class="grow" />
|
||||||
{#if typeof end === 'string'}
|
{#if typeof end === 'string'}
|
||||||
{end}
|
{end}
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,20 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Story name="Default" args={{ title: 'Storybook' }} />
|
<Story name="Default">
|
||||||
|
<Navbar>
|
||||||
|
{#snippet start()}
|
||||||
|
<button class="btn">Home</button>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet center()}
|
||||||
|
<h2 class="text-xl">Title</h2>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet end()}
|
||||||
|
<div class="avatar placeholder">
|
||||||
|
<div class="w-8 rounded-full bg-neutral text-neutral-content">
|
||||||
|
<span class="text-xs">UI</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</Navbar>
|
||||||
|
</Story>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,11 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { messages } from '$lib/i18n';
|
import type { Snippet } from 'svelte';
|
||||||
import SignOutButton from 'clerk-sveltekit/client/SignOutButton.svelte';
|
|
||||||
|
|
||||||
let { title, username }: { title: string; username: string } = $props();
|
let { start, center, end }: { start?: Snippet; center?: Snippet; end?: Snippet } = $props();
|
||||||
|
|
||||||
let message = $derived(messages.nav_greeting({ name: username }));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<header class="navbar justify-between bg-base-200 px-4">
|
<header class="navbar justify-between bg-base-200 px-4">
|
||||||
<h2 class="prose prose-xl">Hestia</h2>
|
<div class="navbar-start">{@render start?.()}</div>
|
||||||
<h1 class="prose prose-2xl">{title}</h1>
|
<div class="navbar-center">{@render center?.()}</div>
|
||||||
<p class="prose prose-lg">{message}</p>
|
<div class="navbar-end">{@render end?.()}</div>
|
||||||
<SignOutButton />
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,6 @@ export async function validateSession({ locals }: ServerLoadEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user: { name: user.name },
|
user: { name: user.name, hasImage: clerkUser.hasImage, imageUrl: clerkUser.imageUrl },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
|
<ParaglideJS {i18n}>
|
||||||
<ClerkProvider publishableKey={PUBLIC_CLERK_PUBLISHABLE_KEY}>
|
<ClerkProvider publishableKey={PUBLIC_CLERK_PUBLISHABLE_KEY}>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</ClerkProvider>
|
</ClerkProvider>
|
||||||
|
</ParaglideJS>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ParaglideJS {i18n}>
|
<style>
|
||||||
<style>
|
|
||||||
.layout {
|
.layout {
|
||||||
@apply h-screen w-screen bg-base-100;
|
@apply h-screen w-screen bg-base-100;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</ParaglideJS>
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { Button } from '$lib/components/Actions';
|
||||||
import { Navbar } from '$lib/components/Navigation';
|
import { Navbar } from '$lib/components/Navigation';
|
||||||
import type { User } from '@prisma/client';
|
import { messages } from '$lib/i18n';
|
||||||
|
import 'clerk-sveltekit/client';
|
||||||
|
import SignOutButton from 'clerk-sveltekit/client/SignOutButton.svelte';
|
||||||
|
import { LogOut, MessageCircleMore } from 'lucide-svelte';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import 'clerk-sveltekit/client';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: Snippet;
|
children: Snippet;
|
||||||
data: {
|
data: PageData;
|
||||||
user: Omit<User, 'password'>;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let { children, data }: Props = $props();
|
let { children, data }: Props = $props();
|
||||||
|
|
@ -42,7 +45,52 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let message = $derived(messages.nav_greeting({ name: data.user.name }));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Navbar title="Svelte" username={data.user.name} />
|
{#snippet userMenu()}
|
||||||
|
<div class="dropdown dropdown-end">
|
||||||
|
<div tabindex="0" role="button" class="btn btn-circle btn-primary btn-sm ring">
|
||||||
|
<div class="avatar placeholder online">
|
||||||
|
<div class="w-8 rounded-full">
|
||||||
|
{#if data.user.hasImage}
|
||||||
|
<img src={data.user.imageUrl} alt="Avatar" />
|
||||||
|
{:else}
|
||||||
|
<span>{data.user.name.at(0)}</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||||
|
<ul
|
||||||
|
tabindex="0"
|
||||||
|
class="menu dropdown-content menu-lg z-[1] mt-4 w-52 rounded-box bg-base-200 p-2 text-right shadow"
|
||||||
|
>
|
||||||
|
<li>
|
||||||
|
<button onclick={() => goto('/app/sms')}
|
||||||
|
><MessageCircleMore /> {messages.nav_menu_sms()}</button
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
<li><SignOutButton><LogOut /> {messages.nav_menu_logout()}</SignOutButton></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
<Navbar>
|
||||||
|
{#snippet start()}
|
||||||
|
<Button onclick={() => goto('/app')}>
|
||||||
|
<h2 class="prose prose-xl">Hestia</h2>
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet center()}
|
||||||
|
<h1 class="prose prose-2xl">Svelte</h1>
|
||||||
|
{/snippet}
|
||||||
|
{#snippet end()}
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<p class="prose prose-lg">{message}</p>
|
||||||
|
{@render userMenu()}
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</Navbar>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,2 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a href="/app/sms" class="btn btn-ghost">SMS</a>
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue