prep: replace $$props.class with props
This commit is contained in:
1 parent
3ca72662ca
commit
0718c8e0c6
69 files changed
+383
-214
No files matched your search
@@ -1,52 +1,57 @@
|
||||
<script lang="ts">
|
||||
export let label: string = ''
|
||||
export let label: string = ''
|
||||
|
||||
const badgeColor = {
|
||||
red: 'bg-red-500 text-white ring-transparent',
|
||||
green: 'bg-green-500 text-white dark:text-black ring-transparent',
|
||||
yellow: 'bg-yellow-500 text-black ring-transparent',
|
||||
gray: 'bg-gray-600 text-white ring-transparent',
|
||||
blue: 'bg-blue-500 text-white ring-transparent',
|
||||
purple: 'bg-purple-500 text-white ring-transparent',
|
||||
'red-subtle': `bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400
|
||||
const badgeColor = {
|
||||
red: 'bg-red-500 text-white ring-transparent',
|
||||
green: 'bg-green-500 text-white dark:text-black ring-transparent',
|
||||
yellow: 'bg-yellow-500 text-black ring-transparent',
|
||||
gray: 'bg-gray-600 text-white ring-transparent',
|
||||
blue: 'bg-blue-500 text-white ring-transparent',
|
||||
purple: 'bg-purple-500 text-white ring-transparent',
|
||||
'red-subtle': `bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400
|
||||
ring-red-400 dark:ring-red-500/30`,
|
||||
'green-subtle': `bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400
|
||||
'green-subtle': `bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400
|
||||
ring-green-400 dark:ring-green-500/30`,
|
||||
'yellow-subtle': `bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400
|
||||
'yellow-subtle': `bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400
|
||||
ring-yellow-400 dark:ring-yellow-500/30`,
|
||||
'gray-subtle': `bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-300
|
||||
'gray-subtle': `bg-gray-100 dark:bg-gray-500/20 text-gray-700 dark:text-gray-300
|
||||
ring-gray-400 dark:ring-gray-400/30`,
|
||||
'blue-subtle': `bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300
|
||||
'blue-subtle': `bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300
|
||||
ring-blue-400 dark:ring-blue-400/30`,
|
||||
'purple-subtle': `bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-400
|
||||
'purple-subtle': `bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-400
|
||||
ring-purple-400 dark:ring-purple-500/30`,
|
||||
custom: ''
|
||||
}
|
||||
custom: '',
|
||||
}
|
||||
|
||||
const badgeRoundness = {
|
||||
full: 'rounded-full',
|
||||
md: 'rounded-md',
|
||||
custom: ''
|
||||
}
|
||||
const badgeRoundness = {
|
||||
full: 'rounded-full',
|
||||
md: 'rounded-md',
|
||||
custom: '',
|
||||
}
|
||||
|
||||
type BadgeColor = keyof typeof badgeColor
|
||||
type BadgeRoundness = keyof typeof badgeRoundness
|
||||
type BadgeColor = keyof typeof badgeColor
|
||||
type BadgeRoundness = keyof typeof badgeRoundness
|
||||
|
||||
export let color: BadgeColor = 'gray-subtle'
|
||||
export let rounding: BadgeRoundness = 'full'
|
||||
export let color: BadgeColor = 'gray-subtle'
|
||||
export let rounding: BadgeRoundness = 'full'
|
||||
export let allowIconOnly: boolean = false
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<span
|
||||
class="{allowIconOnly ? 'max-md:px-1.5 max-md:py-1.5' : ''} px-2.5 py-1 {badgeRoundness[
|
||||
rounding
|
||||
]} text-xs font-medium flex items-center gap-1 ring-1 ring-inset {badgeColor[
|
||||
color
|
||||
]} {$$props.class}"
|
||||
title={label}
|
||||
class="{allowIconOnly
|
||||
? 'max-md:px-1.5 max-md:py-1.5'
|
||||
: ''} px-2.5 py-1 {badgeRoundness[
|
||||
rounding
|
||||
]} text-xs font-medium flex items-center gap-1 ring-1 ring-inset {badgeColor[
|
||||
color
|
||||
]} {clazz}"
|
||||
title={label}
|
||||
>
|
||||
<slot name="icon" />
|
||||
<span class={allowIconOnly ? 'hidden md:contents' : 'contents'}>
|
||||
<slot />
|
||||
<slot />
|
||||
</span>
|
||||
</span>
|
||||
@@ -130,6 +130,9 @@
|
||||
export let loaderWidth: number | undefined = undefined
|
||||
|
||||
export let href: string | undefined = undefined
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
@@ -155,7 +158,7 @@
|
||||
: alignment == 'left'
|
||||
? 'origin-left'
|
||||
: 'origin-right'}
|
||||
{$$props.class}"
|
||||
{clazz}"
|
||||
type={submit ? 'submit' : 'button'}
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
navigator.clipboard.writeText(src)
|
||||
}
|
||||
}
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<Material
|
||||
@@ -64,7 +67,7 @@
|
||||
<pre
|
||||
bind:this={pre}
|
||||
{...$$restProps}
|
||||
class="{$$props.class} bg-white dark:bg-zinc-900 px-4 overflow-auto max-h-96">
|
||||
class="{clazz} bg-white dark:bg-zinc-900 px-4 overflow-auto max-h-96">
|
||||
{#if htmlSrc}
|
||||
{@html htmlSrc}
|
||||
{:else if $$slots.default}
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
export let copy: boolean = true
|
||||
|
||||
let copied = false
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</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
|
||||
{$$props.class}"
|
||||
{clazz}"
|
||||
>
|
||||
<pre class="overflow-auto max-w-full whitespace-nowrap w-max">
|
||||
{value}
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
import { slide } from 'svelte/transition'
|
||||
|
||||
export let open: boolean = false
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div {...$$restProps} class={$$props.class}>
|
||||
<div {...$$restProps} class={clazz}>
|
||||
<button on:click={() => (open = !open)} class="w-full">
|
||||
<slot name="summary" {open} />
|
||||
</button>
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
|
||||
export let group: string = generateID()
|
||||
export let row: boolean = true
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 max-w-full">
|
||||
<div
|
||||
class="flex {row
|
||||
? 'flex-row flex-wrap'
|
||||
: 'flex-col'} gap-4 {$$props.class || ''}"
|
||||
>
|
||||
<div class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz}">
|
||||
<slot {group} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -13,9 +13,12 @@
|
||||
|
||||
$: previewURLs =
|
||||
preview && files ? Array.from(files).map(URL.createObjectURL) : undefined
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 {$$props.class}">
|
||||
<div class="flex flex-col gap-1 {clazz}">
|
||||
{#if $$slots.label || label}
|
||||
<Label for={id} text={label}>
|
||||
<slot name="label" />
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
export let title: string | undefined
|
||||
export let title: string | undefined
|
||||
|
||||
const dispatcher = createEventDispatcher<{ submit: SubmitEvent }>()
|
||||
const dispatcher = createEventDispatcher<{ submit: SubmitEvent }>()
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<form
|
||||
on:submit={(e) => dispatcher('submit', e)}
|
||||
{...$$restProps}
|
||||
class="flex flex-col gap-4 {$$props.class}"
|
||||
on:submit={(e) => dispatcher('submit', e)}
|
||||
{...$$restProps}
|
||||
class="flex flex-col gap-4 {clazz}"
|
||||
>
|
||||
{#if title || $$slots.title}
|
||||
{#if $$slots.title}
|
||||
<slot name="title" />
|
||||
{:else if title}
|
||||
<h1 class="text-2xl font-bold">{title}</h1>
|
||||
{/if}
|
||||
{/if}
|
||||
<slot />
|
||||
{#if title || $$slots.title}
|
||||
{#if $$slots.title}
|
||||
<slot name="title" />
|
||||
{:else if title}
|
||||
<h1 class="text-2xl font-bold">{title}</h1>
|
||||
{/if}
|
||||
{/if}
|
||||
<slot />
|
||||
</form>
|
||||
@@ -1,21 +1,24 @@
|
||||
<script lang="ts">
|
||||
let forID: string | undefined = undefined
|
||||
export { forID as for }
|
||||
/**
|
||||
* The `text` prop will take precedence over the slot.
|
||||
*/
|
||||
export let text: string | undefined = undefined
|
||||
let forID: string | undefined = undefined
|
||||
export { forID as for }
|
||||
/**
|
||||
* The `text` prop will take precedence over the slot.
|
||||
*/
|
||||
export let text: string | undefined = undefined
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
this={forID ? 'label' : 'span'}
|
||||
{...$$restProps}
|
||||
for={forID}
|
||||
class="text-sm text-slate-800 dark:text-zinc-200 font-medium w-full {$$props.class || ''}"
|
||||
this={forID ? 'label' : 'span'}
|
||||
{...$$restProps}
|
||||
for={forID}
|
||||
class="text-sm text-slate-800 dark:text-zinc-200 font-medium w-full {clazz ||
|
||||
''}"
|
||||
>
|
||||
{#if text}
|
||||
{text}
|
||||
{:else if $$slots.default}
|
||||
<slot />
|
||||
{/if}
|
||||
{#if text}
|
||||
{text}
|
||||
{:else if $$slots.default}
|
||||
<slot />
|
||||
{/if}
|
||||
</svelte:element>
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
export let group: string = generateID()
|
||||
export let row: boolean = false
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<div
|
||||
class="flex {row
|
||||
? 'flex-row flex-wrap'
|
||||
: 'flex-col'} gap-4 {$$props.class || ''}"
|
||||
class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz || ''}"
|
||||
>
|
||||
<slot {group} />
|
||||
</div>
|
||||
|
||||
@@ -48,9 +48,11 @@
|
||||
contextmenu: any
|
||||
input: any
|
||||
}>()
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 {$$props.class}">
|
||||
<div class="flex flex-col gap-1 {clazz}">
|
||||
{#if $$slots.label || label}
|
||||
<Label for={id} text={label}>
|
||||
<slot name="label" />
|
||||
@@ -67,7 +69,7 @@
|
||||
shadow
|
||||
]} {buttonColor.secondary} appearance-none transition-colors rounded-lg text-sm
|
||||
w-full min-w-full cursor-pointer pr-6 {buttonColor.secondary}
|
||||
{$$props.class}"
|
||||
{clazz}"
|
||||
bind:value
|
||||
on:mousedown={(e) => {
|
||||
e.preventDefault()
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<script lang="ts">
|
||||
export let defaultValue: boolean = false
|
||||
export let checked: boolean = defaultValue
|
||||
|
||||
export let labelClass: string = ''
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<label class="font-normal cursor-pointer flex flex-row items-start gap-4 group {$$props.class}">
|
||||
<label class="font-normal cursor-pointer flex flex-row items-start gap-4 group {class}">
|
||||
<div
|
||||
class="w-11 h-6 rounded-full relative z-[inherit] cursor-pointer flex flex-row transition-colors shadow-sm
|
||||
{checked ? 'bg-primary-900 dark:bg-primary-100' : 'bg-slate-200 dark:bg-zinc-800'}
|
||||
@@ -20,7 +24,7 @@
|
||||
rtl:peer-checked:-translate-x-5 rtl:group-active:peer-checked:-translate-x-4"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col {$$props.labelClass}">
|
||||
<div class="flex flex-col {labelClass}">
|
||||
<slot />
|
||||
{#if $$slots.description}
|
||||
<span class="font-normal text-sm text-slate-700 dark:text-zinc-300">
|
||||
|
||||
@@ -26,9 +26,11 @@
|
||||
const borderClass = `
|
||||
border border-slate-200 dark:border-zinc-800
|
||||
`
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 {$$props.class}">
|
||||
<div class="flex flex-col gap-1 {clazz}">
|
||||
{#if $$slots.label || label}
|
||||
<Label
|
||||
for={id}
|
||||
@@ -41,7 +43,7 @@
|
||||
</Label>
|
||||
{/if}
|
||||
<div
|
||||
class="rounded-xl flex flex-col items-center text-sm bg-white dark:bg-zinc-950 {$$props.class}"
|
||||
class="rounded-xl flex flex-col items-center text-sm bg-white dark:bg-zinc-950 {clazz}"
|
||||
>
|
||||
<textarea
|
||||
{id}
|
||||
@@ -62,7 +64,7 @@
|
||||
dark:ring-zinc-200/50 transition-all text-sm w-full disabled:bg-slate-100
|
||||
disabled:cursor-not-allowed disabled:dark:bg-zinc-900 invalid:!border-red-500
|
||||
peer invalid:text-red-500 z-10
|
||||
{$$props.class || ''}"
|
||||
{clazz || ''}"
|
||||
class:rounded-b-none={$$slots.suffix}
|
||||
class:border-b-0={$$slots.suffix}
|
||||
/>
|
||||
|
||||
@@ -32,9 +32,11 @@
|
||||
const borderClass = `
|
||||
border border-slate-200 border-b-slate-300 dark:border-zinc-900 dark:border-t-zinc-800
|
||||
`
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 {$$props.class}">
|
||||
<div class="flex flex-col gap-1 {clazz}">
|
||||
{#if $$slots.label || label}
|
||||
<Label
|
||||
for={id}
|
||||
@@ -51,7 +53,7 @@
|
||||
focus-within:border-primary-900 focus-within:dark:border-primary-100 focus-within:ring-2
|
||||
ring-slate-300 dark:ring-zinc-700
|
||||
transition-colors
|
||||
rounded-lg flex flex-row items-center text-sm {$$props.class}"
|
||||
rounded-lg flex flex-row items-center text-sm {clazz}"
|
||||
>
|
||||
{#if $$slots.prefix}
|
||||
<div
|
||||
@@ -78,7 +80,7 @@
|
||||
focus:outline-none rounded-lg text-sm w-full disabled:bg-slate-100
|
||||
disabled:cursor-not-allowed disabled:dark:bg-zinc-950 invalid:!border-red-500
|
||||
peer invalid:text-red-500 z-10
|
||||
{$$props.class || ''}"
|
||||
{clazz || ''}"
|
||||
class:rounded-l-none={$$slots.prefix}
|
||||
class:border-l-0={$$slots.prefix && inlineAffixes}
|
||||
class:rounded-r-none={$$slots.suffix}
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
export let color: Color = 'default'
|
||||
|
||||
export let element: string = 'div'
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
@@ -64,7 +66,7 @@
|
||||
{roundedClass[rounding]}
|
||||
{colorClass[color]}
|
||||
text-sm
|
||||
{$$props.class}
|
||||
{clazz}
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
flip(),
|
||||
]
|
||||
export let strategy: Strategy = 'absolute'
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<Popover
|
||||
@@ -34,7 +36,7 @@
|
||||
{...$$restProps}
|
||||
bind:open
|
||||
popoverClass="backdrop-blur-xl rounded-xl w-full max-w-[280px]"
|
||||
class={$$props.class}
|
||||
class={clazz}
|
||||
>
|
||||
<slot name="target" slot="target" />
|
||||
<div
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
export let alignment: ButtonAlignment = 'left'
|
||||
export let href: string | undefined = undefined
|
||||
export let disabled: boolean = false
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<Button
|
||||
@@ -19,7 +21,7 @@
|
||||
? 'opacity-70 pointer-events-none cursor-not-allowed'
|
||||
: ''} {color == 'tertiary'
|
||||
? 'hover:dark:bg-zinc-800/70'
|
||||
: ''} duration-100 {$$props.class}"
|
||||
: ''} duration-100 {clazz}"
|
||||
{alignment}
|
||||
{href}
|
||||
{disabled}
|
||||
|
||||
@@ -62,6 +62,10 @@
|
||||
floatingRef(node)
|
||||
}
|
||||
}
|
||||
|
||||
export let popoverClass: string = ''
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<svelte:body
|
||||
@@ -92,9 +96,7 @@
|
||||
}}
|
||||
role="menu"
|
||||
type="button"
|
||||
class="{canUseContents
|
||||
? 'contents text-left'
|
||||
: 'w-max h-max'} {$$props.class}"
|
||||
class="{canUseContents ? 'contents text-left' : 'w-max h-max'} {clazz}"
|
||||
bind:this={el}
|
||||
use:customFloatingRef
|
||||
>
|
||||
@@ -106,7 +108,7 @@
|
||||
<Portal class="z-[150]">
|
||||
<div
|
||||
transition:scale={{ duration: 200, start: 0.96, easing: backOut }}
|
||||
class="z-[150] {$$props.popoverClass}"
|
||||
class="z-[150] {popoverClass}"
|
||||
use:customFloatingContent
|
||||
use:focusTrap
|
||||
>
|
||||
|
||||
@@ -1,34 +1,37 @@
|
||||
<script lang="ts">
|
||||
import { browser } from '$app/environment'
|
||||
import { browser } from '$app/environment'
|
||||
|
||||
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
|
||||
import { onMount, onDestroy, createEventDispatcher } from 'svelte'
|
||||
let slottedElements: HTMLDivElement, portal: HTMLDivElement
|
||||
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
|
||||
import { onMount, onDestroy, createEventDispatcher } from 'svelte'
|
||||
let slottedElements: HTMLDivElement, portal: HTMLDivElement
|
||||
|
||||
const dispatch = createEventDispatcher<{ mounted: void }>()
|
||||
const dispatch = createEventDispatcher<{ mounted: void }>()
|
||||
|
||||
onMount(() => {
|
||||
if (!browser) return
|
||||
portal = document?.createElement('div')
|
||||
if (portal) portal.className = 'portal-mount'
|
||||
document?.body.appendChild(portal)
|
||||
portal?.appendChild(slottedElements)
|
||||
dispatch('mounted')
|
||||
})
|
||||
onMount(() => {
|
||||
if (!browser) return
|
||||
portal = document?.createElement('div')
|
||||
if (portal) portal.className = 'portal-mount'
|
||||
document?.body.appendChild(portal)
|
||||
portal?.appendChild(slottedElements)
|
||||
dispatch('mounted')
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
portal.remove()
|
||||
})
|
||||
onDestroy(() => {
|
||||
portal.remove()
|
||||
})
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
</script>
|
||||
|
||||
<div class="portal-initial-mount-point">
|
||||
<div bind:this={slottedElements} class="portal-content {$$props.class || ''}">
|
||||
<slot />
|
||||
</div>
|
||||
<div bind:this={slottedElements} class="portal-content {clazz || ''}">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.portal-initial-mount-point {
|
||||
display: none;
|
||||
}
|
||||
.portal-initial-mount-point {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user