misc: Organize components

This commit is contained in:
Xyphyn committed 2023-07-03 12:35:49 -07:00
1 parent a5460a03b4
commit 7d3f29d9eb
17 files changed
+24 -22

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import { Color } from '$lib/ui/colors.js'
export let color: Color = Color.secondary
export let loading = false
const dispatch = createEventDispatcher()
</script>
<button
on:click={(e) => dispatch('click', e)}
class="px-3 py-1.5 rounded-md {color} text-sm transition-all"
>
<div
class="flex flex-row items-center justify-center gap-2"
class:opacity-0={loading}
>
<slot name="icon" />
<slot />
</div>
<div class="mx-auto my-auto" class:hidden={!loading}>loading...</div>
</button>
+15
View File
@@ -0,0 +1,15 @@
<script lang="ts">
import { Color } from '$lib/ui/colors.js'
export let color: Color = Color.secondary
export let href = ''
</script>
<a
{href}
class="px-2 py-1 rounded-md {color} flex flex-row items-center
justify-center text-sm transition-all"
>
<slot name="icon" />
<slot />
</a>
@@ -0,0 +1,36 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
type T = $$Generic
export let options: T[]
export let optionNames: string[] = []
export let selected: T
export let separate = false
let clazz = ''
export { clazz as class }
const dispatcher = createEventDispatcher<{ select: T }>()
$: {
dispatcher('select', selected)
}
</script>
<div
class="flex overflow-hidden flex-row items-center w-max rounded-md {separate
? 'gap-2'
: ''}"
>
{#each options as option, index}
<button
class="px-3 py-2 text-sm
transition-colors {separate ? 'rounded-full' : ''}
{selected == option
? 'bg-black text-white dark:bg-white dark:text-black\
hover:bg-zinc-900 hover:dark:bg-zinc-300'
: 'bg-slate-100 dark:bg-zinc-900 hover:bg-slate-200 hover:dark:bg-zinc-800'} {clazz}
"
on:click={() => (selected = option)}
>
{optionNames[index] || option}
</button>
{/each}
</div>
<slot {selected} />