perf: remove useless components
This commit is contained in:
6 files changed
-294
No files matched your search
@@ -1,89 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import Button from '../button/Button.svelte'
|
|
||||||
import Material from '../materials/Material.svelte'
|
|
||||||
import { Check, Icon, Clipboard } from 'svelte-hero-icons'
|
|
||||||
import { scale } from 'svelte/transition'
|
|
||||||
|
|
||||||
let copied = $state(false)
|
|
||||||
|
|
||||||
let pre = $state<HTMLPreElement>()
|
|
||||||
|
|
||||||
const copy = () => {
|
|
||||||
if (children) {
|
|
||||||
if (pre) navigator.clipboard.writeText(pre.innerText)
|
|
||||||
} else if (src) {
|
|
||||||
navigator.clipboard.writeText(src)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
src: string
|
|
||||||
filename?: string | undefined
|
|
||||||
htmlSrc?: string | undefined
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
class?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
src,
|
|
||||||
filename = undefined,
|
|
||||||
htmlSrc = undefined,
|
|
||||||
children,
|
|
||||||
class: clazz = '',
|
|
||||||
...rest
|
|
||||||
}: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Material
|
|
||||||
class="overflow-hidden flex flex-col divide-y divide-slate-200 dark:divide-zinc-800"
|
|
||||||
padding="none"
|
|
||||||
rounding="md"
|
|
||||||
>
|
|
||||||
{#if filename}
|
|
||||||
<div class="flex flex-row items-center justify-between p-3 px-4 text-xs">
|
|
||||||
<span>
|
|
||||||
{filename}
|
|
||||||
</span>
|
|
||||||
<Button
|
|
||||||
size="square-sm"
|
|
||||||
color="tertiary"
|
|
||||||
aria-label="Copy"
|
|
||||||
onclick={() => {
|
|
||||||
copied = true
|
|
||||||
copy()
|
|
||||||
setTimeout(() => (copied = false), 2000)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="relative w-full h-full grid place-items-center">
|
|
||||||
{#if !copied}
|
|
||||||
<div
|
|
||||||
transition:scale={{ opacity: 0, start: 0.3 }}
|
|
||||||
style="grid-row: 1; grid-column: 1;"
|
|
||||||
>
|
|
||||||
<Icon src={Clipboard} size="16" />
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div
|
|
||||||
transition:scale={{ opacity: 0, start: 0.3 }}
|
|
||||||
style="grid-row: 1; grid-column: 1;"
|
|
||||||
>
|
|
||||||
<Icon src={Check} size="16" mini />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
<pre
|
|
||||||
bind:this={pre}
|
|
||||||
{...rest}
|
|
||||||
class="{clazz} bg-white dark:bg-zinc-900 px-4 overflow-auto max-h-96">
|
|
||||||
{#if htmlSrc}
|
|
||||||
{@html htmlSrc}
|
|
||||||
{:else if children}
|
|
||||||
{@render children?.()}
|
|
||||||
{:else if src}
|
|
||||||
{src}
|
|
||||||
{/if}
|
|
||||||
</pre>
|
|
||||||
</Material>
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Button } from '../index.js'
|
|
||||||
import { Check, Icon, Clipboard } from 'svelte-hero-icons'
|
|
||||||
import { scale } from 'svelte/transition'
|
|
||||||
|
|
||||||
let copied = $state(false)
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
/**
|
|
||||||
* Show a copy button.
|
|
||||||
*/
|
|
||||||
value: string
|
|
||||||
copy?: boolean
|
|
||||||
class?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
let { value, copy = true, class: clazz = '' }: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="px-4 py-1 flex justify-between max-w-full box-border bg-slate-100 dark:bg-zinc-950 items-center gap-4 rounded-md border dark:border-zinc-800
|
|
||||||
{clazz}"
|
|
||||||
>
|
|
||||||
<pre class="overflow-auto max-w-full whitespace-nowrap w-max">
|
|
||||||
{value}
|
|
||||||
</pre>
|
|
||||||
{#if copy}
|
|
||||||
<Button
|
|
||||||
size="square-md"
|
|
||||||
color="tertiary"
|
|
||||||
aria-label="Copy"
|
|
||||||
onclick={() => {
|
|
||||||
copied = true
|
|
||||||
navigator.clipboard.writeText(value)
|
|
||||||
setTimeout(() => (copied = false), 2000)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="relative w-full h-full grid place-items-center">
|
|
||||||
{#if !copied}
|
|
||||||
<div
|
|
||||||
transition:scale={{ opacity: 0, start: 0.3 }}
|
|
||||||
class="top-0 left-0"
|
|
||||||
style="grid-row: 1; grid-column: 1;"
|
|
||||||
>
|
|
||||||
<Icon src={Clipboard} size="18" mini />
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div
|
|
||||||
transition:scale={{ opacity: 0, start: 0.3 }}
|
|
||||||
class="top-0 left-0"
|
|
||||||
style="grid-row: 1; grid-column: 1;"
|
|
||||||
>
|
|
||||||
<Icon src={Check} size="18" mini />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { createBubbler } from 'svelte/legacy'
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
value,
|
|
||||||
group = $bindable(),
|
|
||||||
inlineDescription = false,
|
|
||||||
id = generateID(),
|
|
||||||
disabled = false,
|
|
||||||
children,
|
|
||||||
description,
|
|
||||||
...rest
|
|
||||||
}: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
{...rest}
|
|
||||||
{id}
|
|
||||||
type="radio"
|
|
||||||
bind:group
|
|
||||||
{value}
|
|
||||||
onblur={bubble('blur-sm')}
|
|
||||||
onchange={bubble('change')}
|
|
||||||
{disabled}
|
|
||||||
class="cursor-pointer disabled:cursor-not-allowed peer disabled:opacity-50"
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
for={id}
|
|
||||||
class="inline-flex {inlineDescription
|
|
||||||
? 'flex-row'
|
|
||||||
: 'flex-col'} cursor-pointer peer-disabled:cursor-not-allowed font-medium gap-1 peer-disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{@render children?.()}
|
|
||||||
{#if description}
|
|
||||||
<span class="font-normal text-slate-600 dark:text-zinc-400">
|
|
||||||
{@render description?.()}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { generateID } from '../forms/helper.js'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
group?: string
|
|
||||||
row?: boolean
|
|
||||||
class?: string
|
|
||||||
children?: import('svelte').Snippet<[{ group: string }]>
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
group = generateID(),
|
|
||||||
row = false,
|
|
||||||
class: clazz = '',
|
|
||||||
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 })}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
export { default as Button } from './button/Button.svelte'
|
export { default as Button } from './button/Button.svelte'
|
||||||
export { buttonColor, buttonSize, buttonShadow } from './button/Button.svelte'
|
export { buttonColor, buttonSize, buttonShadow } from './button/Button.svelte'
|
||||||
export { default as Codeblock } from './code/Codeblock.svelte'
|
|
||||||
export { default as Snippet } from './code/Snippet.svelte'
|
|
||||||
export { default as Spinner } from './loader/Spinner.svelte'
|
export { default as Spinner } from './loader/Spinner.svelte'
|
||||||
export { default as Material } from './materials/Material.svelte'
|
export { default as Material } from './materials/Material.svelte'
|
||||||
|
|
||||||
@@ -18,9 +16,6 @@ export { default as ImageInput } from './forms/ImageInput.svelte'
|
|||||||
export { default as Checkbox } from './forms/Checkbox.svelte'
|
export { default as Checkbox } from './forms/Checkbox.svelte'
|
||||||
export { default as Switch } from './forms/Switch.svelte'
|
export { default as Switch } from './forms/Switch.svelte'
|
||||||
|
|
||||||
export { default as Radio } from './forms/Radio.svelte'
|
|
||||||
export { default as RadioGroup } from './forms/RadioGroup.svelte'
|
|
||||||
|
|
||||||
export { default as Popover } from './popover/Popover.svelte'
|
export { default as Popover } from './popover/Popover.svelte'
|
||||||
export { default as Menu } from './popover/Menu.svelte'
|
export { default as Menu } from './popover/Menu.svelte'
|
||||||
export { default as MenuDivider } from './popover/MenuDivider.svelte'
|
export { default as MenuDivider } from './popover/MenuDivider.svelte'
|
||||||
@@ -35,5 +30,4 @@ export { default as ToastContainer } from './toast/ToastContainer.svelte'
|
|||||||
|
|
||||||
export { default as Note } from './note/Note.svelte'
|
export { default as Note } from './note/Note.svelte'
|
||||||
export { default as Badge } from './badge/Badge.svelte'
|
export { default as Badge } from './badge/Badge.svelte'
|
||||||
export { default as Placeholder } from './placeholder/Placeholder.svelte'
|
|
||||||
export { default as Search } from './search/Search.svelte'
|
export { default as Search } from './search/Search.svelte'
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
|
||||||
interface Props {
|
|
||||||
icon?: IconSource
|
|
||||||
title?: string
|
|
||||||
description?: string
|
|
||||||
customIcon?: import('svelte').Snippet
|
|
||||||
customTitle?: import('svelte').Snippet
|
|
||||||
customDescription?: import('svelte').Snippet
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
icon,
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
customIcon,
|
|
||||||
customTitle,
|
|
||||||
customDescription,
|
|
||||||
children,
|
|
||||||
}: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="text-slate-700 dark:text-zinc-300 flex flex-col justify-center items-center gap-2"
|
|
||||||
>
|
|
||||||
{#if icon || customIcon}
|
|
||||||
<div
|
|
||||||
class="border border-slate-200 dark:border-zinc-700 dark:bg-zinc-800 p-3 rounded-full"
|
|
||||||
>
|
|
||||||
{#if customIcon}
|
|
||||||
{@render customIcon?.()}
|
|
||||||
{:else if icon}
|
|
||||||
<Icon src={icon} size="28" />
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
<div class="flex flex-col gap-1 text-center">
|
|
||||||
<h1 class="text-slate-900 dark:text-zinc-100 text-lg font-medium">
|
|
||||||
{#if customTitle}
|
|
||||||
{@render customTitle?.()}
|
|
||||||
{:else if title}
|
|
||||||
{title}
|
|
||||||
{/if}
|
|
||||||
</h1>
|
|
||||||
{#if description || customDescription}
|
|
||||||
<p class="text-sm text-center font-normal">
|
|
||||||
{#if customDescription}
|
|
||||||
{@render customDescription?.()}
|
|
||||||
{:else if description}
|
|
||||||
{description}
|
|
||||||
{/if}
|
|
||||||
</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{@render children?.()}
|
|
||||||
</div>
|
|
||||||
Reference in new issue
Block a user