feat: added particle and reformatting

This commit is contained in:
Bart van der Braak 2024-02-02 01:08:13 +01:00
parent 5158767019
commit 32b6bf7582
147 changed files with 1186 additions and 922 deletions

View file

@ -1,9 +1,9 @@
<script lang="ts">
import { cn } from "$lib/utils";
import { page } from "$app/stores";
import { Button } from "$lib/components/ui/button";
import { cubicInOut } from "svelte/easing";
import { crossfade } from "svelte/transition";
import { cn } from '$lib/utils';
import { page } from '$app/stores';
import { Button } from '$lib/components/ui/button';
import { cubicInOut } from 'svelte/easing';
import { crossfade } from 'svelte/transition';
let className: string | undefined | null = undefined;
export let items: { href: string; title: string }[];
@ -15,24 +15,21 @@
});
</script>
<nav class={cn("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1", className)}>
<nav class={cn('flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1', className)}>
{#each items as item}
{@const isActive = $page.url.pathname === item.href}
<Button
href={item.href}
variant="ghost"
class={cn(
!isActive && "hover:underline",
"relative justify-start hover:bg-transparent"
)}
class={cn(!isActive && 'hover:underline', 'relative justify-start hover:bg-transparent')}
data-sveltekit-noscroll
>
{#if isActive}
<div
class="absolute inset-0 rounded-md bg-muted"
in:send={{ key: "active-sidebar-tab" }}
out:receive={{ key: "active-sidebar-tab" }}
in:send={{ key: 'active-sidebar-tab' }}
out:receive={{ key: 'active-sidebar-tab' }}
/>
{/if}
<div class="relative">

View file

@ -1,33 +1,31 @@
<script lang="ts">
import { Separator } from "$lib/components/ui/separator";
import SidebarNav from "./(components)/sidebar-nav.svelte";
import { Separator } from '$lib/components/ui/separator';
import SidebarNav from './(components)/sidebar-nav.svelte';
const sidebarNavItems = [
{
title: "Profile",
href: "/settings"
title: 'Profile',
href: '/settings'
},
{
title: "Account",
href: "/settings/account"
title: 'Account',
href: '/settings/account'
},
{
title: "Appearance",
href: "/settings/appearance"
title: 'Appearance',
href: '/settings/appearance'
},
{
title: "Notifications",
href: "/settings/notifications"
title: 'Notifications',
href: '/settings/notifications'
}
];
</script>
<div class="hidden space-y-6 p-10 pb-16 md:block">
<div class="space-y-6 p-10 pb-16 md:block">
<div class="space-y-0.5">
<h2 class="text-2xl font-bold tracking-tight">Settings</h2>
<p class="text-muted-foreground">
Manage your account settings and set e-mail preferences.
</p>
<p class="text-muted-foreground">Manage your account settings and set e-mail preferences.</p>
</div>
<Separator class="my-6" />
<div class="flex flex-col space-y-8 lg:flex-row lg:space-x-12 lg:space-y-0">

View file

@ -1,7 +1,7 @@
import type { PageServerLoad } from "./$types";
import { superValidate } from "sveltekit-superforms/server";
import { profileFormSchema } from "./profile-form.svelte";
import { fail, type Actions } from "@sveltejs/kit";
import type { PageServerLoad } from './$types';
import { superValidate } from 'sveltekit-superforms/server';
import { profileFormSchema } from './profile-form.svelte';
import { fail, type Actions } from '@sveltejs/kit';
export const load: PageServerLoad = async () => {
return {

View file

@ -1,7 +1,7 @@
<script lang="ts">
import type { PageData } from "./$types";
import ProfileForm from "./profile-form.svelte";
import { Separator } from "$lib/components/ui/separator";
import type { PageData } from './$types';
import ProfileForm from './profile-form.svelte';
import { Separator } from '$lib/components/ui/separator';
export let data: PageData;
</script>

View file

@ -1,7 +1,7 @@
import { superValidate } from "sveltekit-superforms/server";
import type { PageServerLoad } from "./$types";
import { accountFormSchema } from "./account-form.svelte";
import { fail, type Actions } from "@sveltejs/kit";
import { superValidate } from 'sveltekit-superforms/server';
import type { PageServerLoad } from './$types';
import { accountFormSchema } from './account-form.svelte';
import { fail, type Actions } from '@sveltejs/kit';
export const load: PageServerLoad = async () => {
return {

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { Separator } from "$lib/components/ui/separator";
import AccountForm from "./account-form.svelte";
import type { PageData } from "./$types";
import { Separator } from '$lib/components/ui/separator';
import AccountForm from './account-form.svelte';
import type { PageData } from './$types';
export let data: PageData;
</script>

View file

@ -1,16 +1,16 @@
<script lang="ts" context="module">
import { z } from "zod";
import { z } from 'zod';
const languages = {
en: "English",
fr: "French",
de: "German",
es: "Spanish",
pt: "Portuguese",
ru: "Russian",
ja: "Japanese",
ko: "Korean",
zh: "Chinese"
en: 'English',
fr: 'French',
de: 'German',
es: 'Spanish',
pt: 'Portuguese',
ru: 'Russian',
ja: 'Japanese',
ko: 'Korean',
zh: 'Chinese'
} as const;
type Language = keyof typeof languages;
@ -18,10 +18,10 @@
export const accountFormSchema = z.object({
name: z
.string({
required_error: "Required."
required_error: 'Required.'
})
.min(2, "Name must be at least 2 characters.")
.max(30, "Name must not be longer than 30 characters"),
.min(2, 'Name must be at least 2 characters.')
.max(30, 'Name must not be longer than 30 characters'),
// Hack: https://github.com/colinhacks/zod/issues/2280
language: z.enum(Object.keys(languages) as [Language, ...Language[]])
});
@ -30,9 +30,9 @@
</script>
<script lang="ts">
import * as Form from "$lib/components/ui/form";
import type { SuperValidated } from "sveltekit-superforms";
import { cn } from "$lib/utils";
import * as Form from '$lib/components/ui/form';
import type { SuperValidated } from 'sveltekit-superforms';
import { cn } from '$lib/utils';
export let data: SuperValidated<AccountFormSchema>;
</script>
@ -62,10 +62,7 @@
<Form.Select selected={{ value, label: languages[value] }}>
<Form.SelectTrigger
placeholder="Select language"
class={cn(
"w-[200px] justify-between",
!attrs.input.value && "text-muted-foreground"
)}
class={cn('w-[200px] justify-between', !attrs.input.value && 'text-muted-foreground')}
/>
<Form.SelectContent class="h-52 overflow-y-auto">
{#each Object.entries(languages) as [value, lang]}
@ -75,9 +72,7 @@
{/each}
</Form.SelectContent>
</Form.Select>
<Form.Description>
This is the language that will be used in the dashboard.
</Form.Description>
<Form.Description>This is the language that will be used in the dashboard.</Form.Description>
<Form.Validation />
</Form.Field>
</Form.Item>

View file

@ -1,7 +1,7 @@
import { superValidate } from "sveltekit-superforms/server";
import type { PageServerLoad } from "../$types";
import { appearanceFormSchema } from "./appearance-form.svelte";
import { fail, type Actions } from "@sveltejs/kit";
import { superValidate } from 'sveltekit-superforms/server';
import type { PageServerLoad } from '../$types';
import { appearanceFormSchema } from './appearance-form.svelte';
import { fail, type Actions } from '@sveltejs/kit';
export const load: PageServerLoad = async () => {
return {

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { Separator } from "$lib/components/ui/separator";
import type { PageData } from "./$types";
import AppearanceForm from "./appearance-form.svelte";
import { Separator } from '$lib/components/ui/separator';
import type { PageData } from './$types';
import AppearanceForm from './appearance-form.svelte';
export let data: PageData;
</script>

View file

@ -1,14 +1,14 @@
<script lang="ts" context="module">
import type { SuperValidated } from "sveltekit-superforms";
import { z } from "zod";
import type { SuperValidated } from 'sveltekit-superforms';
import { z } from 'zod';
export const appearanceFormSchema = z.object({
theme: z.enum(["light", "dark"], {
required_error: "Please select a theme."
theme: z.enum(['light', 'dark'], {
required_error: 'Please select a theme.'
}),
font: z.enum(["inter", "manrope", "system"], {
invalid_type_error: "Select a font",
required_error: "Please select a font."
font: z.enum(['inter', 'manrope', 'system'], {
invalid_type_error: 'Select a font',
required_error: 'Please select a font.'
})
});
@ -16,8 +16,8 @@
</script>
<script lang="ts">
import * as Form from "$lib/components/ui/form";
import Label from "$lib/components/ui/label/label.svelte";
import * as Form from '$lib/components/ui/form';
import Label from '$lib/components/ui/label/label.svelte';
export let data: SuperValidated<AppearanceFormSchema>;
</script>
@ -51,23 +51,17 @@
<Form.RadioGroup class="grid max-w-md grid-cols-2 gap-8 pt-2" orientation="horizontal">
<Label for="light" class="[&:has([data-state=checked])>div]:border-primary">
<Form.RadioItem id="light" value="light" class="sr-only" />
<div
class="items-center rounded-md border-2 border-muted p-1 hover:border-accent"
>
<div class="items-center rounded-md border-2 border-muted p-1 hover:border-accent">
<div class="space-y-2 rounded-sm bg-[#ecedef] p-2">
<div class="space-y-2 rounded-md bg-white p-2 shadow-sm">
<div class="h-2 w-[80px] rounded-lg bg-[#ecedef]" />
<div class="h-2 w-[100px] rounded-lg bg-[#ecedef]" />
</div>
<div
class="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm"
>
<div class="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm">
<div class="h-4 w-4 rounded-full bg-[#ecedef]" />
<div class="h-2 w-[100px] rounded-lg bg-[#ecedef]" />
</div>
<div
class="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm"
>
<div class="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm">
<div class="h-4 w-4 rounded-full bg-[#ecedef]" />
<div class="h-2 w-[100px] rounded-lg bg-[#ecedef]" />
</div>
@ -85,15 +79,11 @@
<div class="h-2 w-[80px] rounded-lg bg-slate-400" />
<div class="h-2 w-[100px] rounded-lg bg-slate-400" />
</div>
<div
class="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm"
>
<div class="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm">
<div class="h-4 w-4 rounded-full bg-slate-400" />
<div class="h-2 w-[100px] rounded-lg bg-slate-400" />
</div>
<div
class="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm"
>
<div class="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm">
<div class="h-4 w-4 rounded-full bg-slate-400" />
<div class="h-2 w-[100px] rounded-lg bg-slate-400" />
</div>

View file

@ -1,7 +1,7 @@
import { superValidate } from "sveltekit-superforms/server";
import type { PageServerLoad } from "../$types";
import { notificationsFormSchema } from "./notifications-form.svelte";
import { fail, type Actions } from "@sveltejs/kit";
import { superValidate } from 'sveltekit-superforms/server';
import type { PageServerLoad } from '../$types';
import { notificationsFormSchema } from './notifications-form.svelte';
import { fail, type Actions } from '@sveltejs/kit';
export const load: PageServerLoad = async () => {
return {

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { Separator } from "$lib/components/ui/separator";
import NotificationsForm from "./notifications-form.svelte";
import type { PageData } from "./$types";
import { Separator } from '$lib/components/ui/separator';
import NotificationsForm from './notifications-form.svelte';
import type { PageData } from './$types';
export let data: PageData;
</script>

View file

@ -1,8 +1,8 @@
<script lang="ts" context="module">
import { z } from "zod";
import { z } from 'zod';
export const notificationsFormSchema = z.object({
type: z.enum(["all", "mentions", "none"], {
required_error: "You need to select a notification type."
type: z.enum(['all', 'mentions', 'none'], {
required_error: 'You need to select a notification type.'
}),
mobile: z.boolean().default(false).optional(),
communication_emails: z.boolean().default(false).optional(),
@ -14,9 +14,9 @@
</script>
<script lang="ts">
import type { SuperValidated } from "sveltekit-superforms";
import * as Form from "$lib/components/ui/form";
import { Label } from "$lib/components/ui/label";
import type { SuperValidated } from 'sveltekit-superforms';
import * as Form from '$lib/components/ui/form';
import { Label } from '$lib/components/ui/label';
export let data: SuperValidated<NotificationFormSchema>;
</script>
@ -54,9 +54,7 @@
<Form.Item class="flex flex-row items-center justify-between rounded-lg border p-4">
<div class="space-y-0.5">
<Form.Label class="text-base">Communication emails</Form.Label>
<Form.Description>
Receive emails about your account activity.
</Form.Description>
<Form.Description>Receive emails about your account activity.</Form.Description>
</div>
<Form.Switch />
</Form.Item>
@ -102,8 +100,7 @@
<div class="space-y-1 leading-none">
<Form.Label>Use different settings for my mobile devices</Form.Label>
<Form.Description>
You can manage your mobile notifications in the{" "}<a href="/settings"
>mobile settings</a
You can manage your mobile notifications in the{' '}<a href="/settings">mobile settings</a
> page.
</Form.Description>
</div>

View file

@ -1,23 +1,23 @@
<script lang="ts" context="module">
import { z } from "zod";
import { z } from 'zod';
export const profileFormSchema = z.object({
username: z
.string()
.min(2, "Username must be at least 2 characters.")
.max(30, "Username must not be longer than 30 characters"),
email: z.string({ required_error: "Please select an email to display" }).email(),
bio: z.string().min(4).max(160).default("I own a computer."),
.min(2, 'Username must be at least 2 characters.')
.max(30, 'Username must not be longer than 30 characters'),
email: z.string({ required_error: 'Please select an email to display' }).email(),
bio: z.string().min(4).max(160).default('I own a computer.'),
website: z
.string()
.url({ message: "Please enter a valid URL." })
.default("https://shadcn-svelte.com")
.url({ message: 'Please enter a valid URL.' })
.default('https://shadcn-svelte.com')
});
export type ProfileFormSchema = typeof profileFormSchema;
</script>
<script lang="ts">
import * as Form from "$lib/components/ui/form";
import type { SuperValidated } from "sveltekit-superforms";
import * as Form from '$lib/components/ui/form';
import type { SuperValidated } from 'sveltekit-superforms';
export let data: SuperValidated<ProfileFormSchema>;
</script>
@ -35,8 +35,8 @@
<Form.Label>Username</Form.Label>
<Form.Input placeholder="@shadcn" />
<Form.Description>
This is your public display name. It can be your real name or a pseudonym. You can
only change this once every 30 days.
This is your public display name. It can be your real name or a pseudonym. You can only
change this once every 30 days.
</Form.Description>
<Form.Validation />
</Form.Field>
@ -50,17 +50,14 @@
<Form.SelectItem value="m@example.com" label="m@example.com"
>m@example.com
</Form.SelectItem>
<Form.SelectItem value="m@google.com" label="m@google.com"
>m@google.com
</Form.SelectItem>
<Form.SelectItem value="m@google.com" label="m@google.com">m@google.com</Form.SelectItem>
<Form.SelectItem value="m@support.com" label="m@support.com"
>m@support.com
</Form.SelectItem>
</Form.SelectContent>
</Form.Select>
<Form.Description>
You can manage verified email addresses in your <a href="/examples/forms"
>email settings</a
You can manage verified email addresses in your <a href="/examples/forms">email settings</a
>.
</Form.Description>
<Form.Validation />