impr: extrapolate moderationmenu into snippet
This commit is contained in:
7 files changed
+31
-182
No files matched your search
@@ -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>
|
||||
Reference in new issue
Block a user