misc: redesign switches
This commit is contained in:
1 parent
00f2a80a05
commit
6f442eceab
2 files changed
+19
-13
No files matched your search
@@ -1,10 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy'
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
|
|
||||||
import { createEventDispatcher } from 'svelte'
|
|
||||||
type T = $$Generic
|
type T = $$Generic
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -16,6 +12,7 @@
|
|||||||
class?: string
|
class?: string
|
||||||
buttonClazz?: string
|
buttonClazz?: string
|
||||||
children?: import('svelte').Snippet<[any]>
|
children?: import('svelte').Snippet<[any]>
|
||||||
|
onselect?: (item: T) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -27,12 +24,11 @@
|
|||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
buttonClazz = '',
|
buttonClazz = '',
|
||||||
children,
|
children,
|
||||||
|
onselect,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ select: T }>()
|
$effect(() => {
|
||||||
|
onselect?.(selected)
|
||||||
run(() => {
|
|
||||||
dispatcher('select', selected)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
let containerClass = `
|
let containerClass = `
|
||||||
@@ -68,11 +64,22 @@
|
|||||||
`
|
`
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={containerClass}>
|
<div
|
||||||
|
class="border rounded-full border-slate-200 dark:border-zinc-800 bg-slate-50 dark:bg-zinc-950 p-1 flex items-center gap-1"
|
||||||
|
>
|
||||||
{#each options as option, index}
|
{#each options as option, index}
|
||||||
|
{@const slctd = selected == option}
|
||||||
<button
|
<button
|
||||||
class={buttonClass(selected == option)}
|
class={[
|
||||||
onclick={preventDefault(() => (selected = option))}
|
'px-3 py-1 rounded-full text-sm font-medium transition-colors duration-75',
|
||||||
|
slctd
|
||||||
|
? 'bg-primary-900 dark:bg-primary-100 text-slate-50 dark:text-zinc-900'
|
||||||
|
: 'dark:bg-zinc-900/75 bg-white',
|
||||||
|
]}
|
||||||
|
onclick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
selected = option
|
||||||
|
}}
|
||||||
disabled={disabled[index] ?? false}
|
disabled={disabled[index] ?? false}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
options={[false, true]}
|
options={[false, true]}
|
||||||
selected={data.unreadOnly ?? true}
|
selected={data.unreadOnly ?? true}
|
||||||
optionNames={[$t('filter.location.all'), $t('filter.unread')]}
|
optionNames={[$t('filter.location.all'), $t('filter.unread')]}
|
||||||
on:select={(e) =>
|
onselect={(e) => searchParam(page.url, 'unreadOnly', e.toString(), 'page')}
|
||||||
searchParam(page.url, 'unreadOnly', e.detail.toString(), 'page')}
|
|
||||||
/>
|
/>
|
||||||
{#if data.applications && data.applications.length > 0}
|
{#if data.applications && data.applications.length > 0}
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
|
|||||||
Reference in new issue
Block a user