format: whole project
This commit is contained in:
1 parent
b883b5f6e0
commit
80269cf275
79 files changed
+590
-612
No files matched your search
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
|
||||
const badgeColor = {
|
||||
red: 'bg-red-500 text-white ring-transparent',
|
||||
green: 'bg-green-500 text-white dark:text-black ring-transparent',
|
||||
@@ -31,15 +30,14 @@
|
||||
type BadgeColor = keyof typeof badgeColor
|
||||
type BadgeRoundness = keyof typeof badgeRoundness
|
||||
|
||||
|
||||
interface Props {
|
||||
label?: string;
|
||||
color?: BadgeColor;
|
||||
rounding?: BadgeRoundness;
|
||||
allowIconOnly?: boolean;
|
||||
class?: string;
|
||||
icon?: import('svelte').Snippet;
|
||||
children?: import('svelte').Snippet;
|
||||
label?: string
|
||||
color?: BadgeColor
|
||||
rounding?: BadgeRoundness
|
||||
allowIconOnly?: boolean
|
||||
class?: string
|
||||
icon?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -51,8 +49,7 @@
|
||||
icon,
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<span
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import { slide } from 'svelte/transition'
|
||||
|
||||
interface Props {
|
||||
open?: boolean;
|
||||
class?: string;
|
||||
summary?: import('svelte').Snippet<[any]>;
|
||||
extended?: import('svelte').Snippet;
|
||||
children?: import('svelte').Snippet<[any]>;
|
||||
open?: boolean
|
||||
class?: string
|
||||
summary?: import('svelte').Snippet<[any]>
|
||||
extended?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet<[any]>
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@
|
||||
extended,
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div {...rest} class={clazz}>
|
||||
<button onclick={() => (open = !open)} class="w-full">
|
||||
{@render summary?.({ open, })}
|
||||
{@render summary?.({ open })}
|
||||
</button>
|
||||
{@render extended?.()}
|
||||
{#if open}
|
||||
<div transition:slide={{ axis: 'y', easing: expoOut, duration: 300 }}>
|
||||
{@render children?.({ open, })}
|
||||
{@render children?.({ open })}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1,27 +1,35 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
defaultValue?: boolean;
|
||||
checked?: boolean | undefined;
|
||||
inlineDescription?: boolean;
|
||||
children?: import('svelte').Snippet;
|
||||
description?: import('svelte').Snippet;
|
||||
}
|
||||
interface Props {
|
||||
defaultValue?: boolean
|
||||
checked?: boolean | undefined
|
||||
inlineDescription?: boolean
|
||||
children?: import('svelte').Snippet
|
||||
description?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
defaultValue = false,
|
||||
checked = $bindable(defaultValue),
|
||||
inlineDescription = false,
|
||||
children,
|
||||
description
|
||||
}: Props = $props();
|
||||
let {
|
||||
defaultValue = false,
|
||||
checked = $bindable(defaultValue),
|
||||
inlineDescription = false,
|
||||
children,
|
||||
description,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<label class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2">
|
||||
<input type="checkbox" bind:checked class="cursor-pointer" />
|
||||
<div class="inline-flex {inlineDescription ? 'flex-row' : 'flex-col'} font-medium gap-1">
|
||||
{@render children?.()}
|
||||
{#if description}
|
||||
<span class="font-normal text-slate-600 dark:text-zinc-400">{@render description?.()}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<label
|
||||
class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"
|
||||
>
|
||||
<input type="checkbox" bind:checked class="cursor-pointer" />
|
||||
<div
|
||||
class="inline-flex {inlineDescription
|
||||
? 'flex-row'
|
||||
: 'flex-col'} font-medium gap-1"
|
||||
>
|
||||
{@render children?.()}
|
||||
{#if description}
|
||||
<span class="font-normal text-slate-600 dark:text-zinc-400">
|
||||
{@render description?.()}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</label>
|
||||
@@ -1,14 +1,12 @@
|
||||
<script lang="ts">
|
||||
|
||||
|
||||
interface Props {
|
||||
for?: string | undefined;
|
||||
for?: string | undefined
|
||||
/**
|
||||
* The `text` prop will take precedence over the slot.
|
||||
*/
|
||||
text?: string | undefined;
|
||||
class?: string;
|
||||
children?: import('svelte').Snippet;
|
||||
* The `text` prop will take precedence over the slot.
|
||||
*/
|
||||
text?: string | undefined
|
||||
class?: string
|
||||
children?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -18,8 +16,7 @@
|
||||
class: clazz = '',
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<script lang="ts">
|
||||
import { createBubbler } from 'svelte/legacy';
|
||||
import { createBubbler } from 'svelte/legacy'
|
||||
|
||||
const bubble = createBubbler();
|
||||
const bubble = createBubbler()
|
||||
import { generateID } from '../forms/helper.js'
|
||||
|
||||
type T = $$Generic
|
||||
|
||||
interface Props {
|
||||
value: T;
|
||||
group: T;
|
||||
inlineDescription?: boolean;
|
||||
id?: string;
|
||||
disabled?: boolean;
|
||||
children?: import('svelte').Snippet;
|
||||
description?: import('svelte').Snippet;
|
||||
value: T
|
||||
group: T
|
||||
inlineDescription?: boolean
|
||||
id?: string
|
||||
disabled?: boolean
|
||||
children?: import('svelte').Snippet
|
||||
description?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
children,
|
||||
description,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -2,25 +2,24 @@
|
||||
import { generateID } from '../forms/helper.js'
|
||||
|
||||
interface Props {
|
||||
group?: string;
|
||||
row?: boolean;
|
||||
class?: string;
|
||||
children?: import('svelte').Snippet<[any]>;
|
||||
group?: string
|
||||
row?: boolean
|
||||
class?: string
|
||||
children?: import('svelte').Snippet<[any]>
|
||||
}
|
||||
|
||||
let {
|
||||
group = generateID(),
|
||||
row = false,
|
||||
class: clazz = '',
|
||||
children
|
||||
}: Props = $props();
|
||||
|
||||
children,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<div
|
||||
class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz || ''}"
|
||||
>
|
||||
{@render children?.({ group, })}
|
||||
{@render children?.({ group })}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,12 +1,11 @@
|
||||
<script lang="ts">
|
||||
|
||||
interface Props {
|
||||
defaultValue?: boolean;
|
||||
checked?: boolean;
|
||||
labelClass?: string;
|
||||
class?: string;
|
||||
children?: import('svelte').Snippet;
|
||||
description?: import('svelte').Snippet;
|
||||
defaultValue?: boolean
|
||||
checked?: boolean
|
||||
labelClass?: string
|
||||
class?: string
|
||||
children?: import('svelte').Snippet
|
||||
description?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -15,9 +14,8 @@
|
||||
labelClass = '',
|
||||
class: clazz = '',
|
||||
children,
|
||||
description
|
||||
}: Props = $props();
|
||||
|
||||
description,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<label
|
||||
@@ -39,7 +37,7 @@
|
||||
class="box-border w-5 h-full bg-white peer-checked:dark:bg-black rounded-full shadow-sm
|
||||
group-active:w-6 transition peer-checked:translate-x-5 group-active:peer-checked:translate-x-4
|
||||
rtl:peer-checked:-translate-x-5 rtl:group-active:peer-checked:-translate-x-4"
|
||||
></div>
|
||||
></div>
|
||||
</div>
|
||||
<div class="flex flex-col {labelClass}">
|
||||
{@render children?.()}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
width?: number;
|
||||
width?: number
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
let { width = 16, ...rest }: Props = $props();
|
||||
let { width = 16, ...rest }: Props = $props()
|
||||
</script>
|
||||
|
||||
<svg
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { createBubbler } from 'svelte/legacy';
|
||||
import { createBubbler } from 'svelte/legacy'
|
||||
|
||||
const bubble = createBubbler();
|
||||
const bubble = createBubbler()
|
||||
type Elevation = keyof typeof elevationClass
|
||||
type Padding = keyof typeof paddingClass
|
||||
type Rounding = keyof typeof roundedClass
|
||||
@@ -46,15 +46,14 @@
|
||||
none: '',
|
||||
}
|
||||
|
||||
|
||||
interface Props {
|
||||
elevation?: Elevation;
|
||||
padding?: Padding;
|
||||
rounding?: Rounding;
|
||||
color?: Color;
|
||||
element?: string;
|
||||
class?: string;
|
||||
children?: import('svelte').Snippet;
|
||||
elevation?: Elevation
|
||||
padding?: Padding
|
||||
rounding?: Rounding
|
||||
color?: Color
|
||||
element?: string
|
||||
class?: string
|
||||
children?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -67,8 +66,7 @@
|
||||
class: clazz = '',
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
|
||||
+46
-46
@@ -4,62 +4,62 @@ import { writable } from 'svelte/store'
|
||||
export let shownModal = writable<Modal | undefined>(undefined)
|
||||
|
||||
interface Modal {
|
||||
actions: Action[]
|
||||
title: string
|
||||
body?: string
|
||||
/**
|
||||
* Whether the modal has a close button or not
|
||||
*/
|
||||
dismissable: boolean
|
||||
type: 'error' | 'info' | 'success'
|
||||
actions: Action[]
|
||||
title: string
|
||||
body?: string
|
||||
/**
|
||||
* Whether the modal has a close button or not
|
||||
*/
|
||||
dismissable: boolean
|
||||
type: 'error' | 'info' | 'success'
|
||||
}
|
||||
|
||||
type Action = {
|
||||
/**
|
||||
* What function to run when this action is clicked. If undefined, it'll close the window.
|
||||
*/
|
||||
action: () => any
|
||||
type: 'danger' | 'secondary' | 'primary'
|
||||
content: string
|
||||
icon?: IconSource
|
||||
close: boolean
|
||||
/**
|
||||
* What function to run when this action is clicked. If undefined, it'll close the window.
|
||||
*/
|
||||
action: () => any
|
||||
type: 'danger' | 'secondary' | 'primary'
|
||||
content: string
|
||||
icon?: IconSource
|
||||
close: boolean
|
||||
}
|
||||
|
||||
export const action = (action?: {
|
||||
action?: () => any
|
||||
type?: 'danger' | 'secondary' | 'primary'
|
||||
content?: string
|
||||
icon?: IconSource
|
||||
close?: boolean
|
||||
action?: () => any
|
||||
type?: 'danger' | 'secondary' | 'primary'
|
||||
content?: string
|
||||
icon?: IconSource
|
||||
close?: boolean
|
||||
}): Action => ({
|
||||
action: action?.action
|
||||
? () => {
|
||||
action?.action?.()
|
||||
if (action.close) shownModal.set(undefined)
|
||||
}
|
||||
: () => shownModal.set(undefined),
|
||||
type: action?.type ?? 'secondary',
|
||||
content: action?.content || 'OK',
|
||||
close: action?.close ?? true
|
||||
action: action?.action
|
||||
? () => {
|
||||
action?.action?.()
|
||||
if (action.close) shownModal.set(undefined)
|
||||
}
|
||||
: () => shownModal.set(undefined),
|
||||
type: action?.type ?? 'secondary',
|
||||
content: action?.content || 'OK',
|
||||
close: action?.close ?? true,
|
||||
})
|
||||
|
||||
export function modal(inputModal: {
|
||||
actions?: Action[]
|
||||
title: string
|
||||
body: string
|
||||
/**
|
||||
* Whether the modal has a close button or not
|
||||
*/
|
||||
dismissable?: boolean
|
||||
type?: 'error' | 'info' | 'success'
|
||||
actions?: Action[]
|
||||
title: string
|
||||
body: string
|
||||
/**
|
||||
* Whether the modal has a close button or not
|
||||
*/
|
||||
dismissable?: boolean
|
||||
type?: 'error' | 'info' | 'success'
|
||||
}) {
|
||||
const modal: Modal = {
|
||||
actions: inputModal.actions ?? [action()],
|
||||
dismissable: inputModal.dismissable ?? true,
|
||||
title: inputModal.title,
|
||||
body: inputModal.body,
|
||||
type: inputModal.type ?? 'info'
|
||||
}
|
||||
const modal: Modal = {
|
||||
actions: inputModal.actions ?? [action()],
|
||||
dismissable: inputModal.dismissable ?? true,
|
||||
title: inputModal.title,
|
||||
body: inputModal.body,
|
||||
type: inputModal.type ?? 'info',
|
||||
}
|
||||
|
||||
shownModal.set(modal)
|
||||
shownModal.set(modal)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import Routebar from './Routebar.svelte';
|
||||
import Routebar from './Routebar.svelte'
|
||||
import Button from '../button/Button.svelte'
|
||||
|
||||
type Route = string
|
||||
@@ -10,24 +10,22 @@
|
||||
name: string
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* The routes for the routebar.
|
||||
*/
|
||||
routes: RouteObject[];
|
||||
currentRoute?: Route | undefined;
|
||||
parentRoute?: Route | undefined;
|
||||
depth?: number;
|
||||
* The routes for the routebar.
|
||||
*/
|
||||
routes: RouteObject[]
|
||||
currentRoute?: Route | undefined
|
||||
parentRoute?: Route | undefined
|
||||
depth?: number
|
||||
}
|
||||
|
||||
let {
|
||||
routes,
|
||||
currentRoute = undefined,
|
||||
parentRoute = undefined,
|
||||
depth = 0
|
||||
}: Props = $props();
|
||||
depth = 0,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<svelte:element this={depth == 0 ? 'nav' : 'ul'} class="flex flex-col h-full">
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import { Icon, InformationCircle } from 'svelte-hero-icons'
|
||||
|
||||
interface Props {
|
||||
content?: string | undefined;
|
||||
children?: import('svelte').Snippet;
|
||||
content?: string | undefined
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let { content = undefined, children }: Props = $props();
|
||||
let { content = undefined, children }: Props = $props()
|
||||
</script>
|
||||
|
||||
<Material
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<script>
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
* @property {import('svelte').Snippet} [children]
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
* @property {import('svelte').Snippet} [children]
|
||||
*/
|
||||
|
||||
/** @type {Props} */
|
||||
let { children } = $props();
|
||||
/** @type {Props} */
|
||||
let { children } = $props()
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1"
|
||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1"
|
||||
>
|
||||
<div>{@render children?.()}</div>
|
||||
<hr class="flex-shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70" />
|
||||
<div>{@render children?.()}</div>
|
||||
<hr
|
||||
class="flex-shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70"
|
||||
/>
|
||||
</div>
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
|
||||
import { onMount, onDestroy, createEventDispatcher } from 'svelte'
|
||||
let slottedElements: HTMLDivElement = $state(), portal: HTMLDivElement
|
||||
let slottedElements: HTMLDivElement = $state(),
|
||||
portal: HTMLDivElement
|
||||
|
||||
const dispatch = createEventDispatcher<{ mounted: void }>()
|
||||
|
||||
@@ -21,12 +22,11 @@
|
||||
})
|
||||
|
||||
interface Props {
|
||||
class?: string;
|
||||
children?: import('svelte').Snippet;
|
||||
class?: string
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let { class: clazz = '', children }: Props = $props();
|
||||
|
||||
let { class: clazz = '', children }: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="portal-initial-mount-point">
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
interface Props {
|
||||
toast: Toast;
|
||||
toast: Toast
|
||||
}
|
||||
|
||||
let { toast }: Props = $props();
|
||||
let { toast }: Props = $props()
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -3,63 +3,65 @@ import { writable } from 'svelte/store'
|
||||
type ToastType = keyof typeof toastColors
|
||||
|
||||
export const toastColors = {
|
||||
error: 'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
|
||||
warning:
|
||||
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
|
||||
success: 'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
|
||||
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg'
|
||||
error:
|
||||
'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
|
||||
warning:
|
||||
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
|
||||
success:
|
||||
'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
|
||||
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg',
|
||||
}
|
||||
|
||||
export interface Toast {
|
||||
id: number
|
||||
title?: string
|
||||
content: string
|
||||
type: ToastType
|
||||
loading?: boolean
|
||||
action?: () => any
|
||||
id: number
|
||||
title?: string
|
||||
content: string
|
||||
type: ToastType
|
||||
loading?: boolean
|
||||
action?: () => any
|
||||
}
|
||||
|
||||
export const toasts = writable<Toast[]>([])
|
||||
|
||||
export function toast({
|
||||
title,
|
||||
content,
|
||||
type = 'info',
|
||||
duration = 5000,
|
||||
loading = false,
|
||||
action
|
||||
title,
|
||||
content,
|
||||
type = 'info',
|
||||
duration = 5000,
|
||||
loading = false,
|
||||
action,
|
||||
}: {
|
||||
title?: string
|
||||
content: string
|
||||
type?: ToastType
|
||||
duration?: number
|
||||
loading?: boolean
|
||||
action?: () => any
|
||||
title?: string
|
||||
content: string
|
||||
type?: ToastType
|
||||
duration?: number
|
||||
loading?: boolean
|
||||
action?: () => any
|
||||
}) {
|
||||
let id = 0
|
||||
let id = 0
|
||||
|
||||
toasts.update((toasts) => {
|
||||
id = Math.floor(Math.random() * 10000)
|
||||
toasts.update((toasts) => {
|
||||
id = Math.floor(Math.random() * 10000)
|
||||
|
||||
return [
|
||||
...toasts,
|
||||
{
|
||||
id: id,
|
||||
content: content,
|
||||
title: title,
|
||||
type: type,
|
||||
loading: loading,
|
||||
action: action
|
||||
}
|
||||
]
|
||||
})
|
||||
return [
|
||||
...toasts,
|
||||
{
|
||||
id: id,
|
||||
content: content,
|
||||
title: title,
|
||||
type: type,
|
||||
loading: loading,
|
||||
action: action,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
}, duration)
|
||||
setTimeout(() => {
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
}, duration)
|
||||
|
||||
return id
|
||||
return id
|
||||
}
|
||||
|
||||
export const removeToast = (id: number) =>
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
@@ -1,7 +1,7 @@
|
||||
export const debounce = (fn: Function, ms = 300) => {
|
||||
let timeoutId: ReturnType<typeof setTimeout>
|
||||
return function (this: any, ...args: any[]) {
|
||||
clearTimeout(timeoutId)
|
||||
timeoutId = setTimeout(() => fn.apply(this, args), ms)
|
||||
}
|
||||
let timeoutId: ReturnType<typeof setTimeout>
|
||||
return function (this: any, ...args: any[]) {
|
||||
clearTimeout(timeoutId)
|
||||
timeoutId = setTimeout(() => fn.apply(this, args), ms)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user