Files
photon-tbw/src/routes/settings/ToggleSetting.svelte
T
Xylight 76c581123a fix: Fix lint errors (#559)
* cleanup: postactions styling

* misc: fix first round of errors

* pkg: remove vitest

* fix: fix lint errors stage 2

* fix: fix lint errors stage 3

* fix: fix lint errors, stage 3

* misc: update eslint rules to warn for writable derived
2025-06-09 16:34:06 -07:00

83 lines
2.0 KiB
Svelte

<script lang="ts">
import { t } from '$lib/i18n/translations'
import { Badge, Switch } from 'mono-svelte'
import {
ComputerDesktop,
DevicePhoneMobile,
DeviceTablet,
Icon,
} from 'svelte-hero-icons'
interface Props {
title: string
description?: string | undefined
checked?: boolean
beta?: boolean
supportedPlatforms?: {
desktop: boolean
tablet: boolean
mobile: boolean
}
}
let {
title,
description = undefined,
checked = $bindable(false),
beta = false,
supportedPlatforms = {
desktop: true,
tablet: true,
mobile: true,
},
}: Props = $props()
</script>
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
{#if Object.values(supportedPlatforms).some(v => v == false) || beta}
<div class="flex items-center gap-2 flex-wrap">
{#if beta}
<Badge>Beta</Badge>
{/if}
{#if Object.values(supportedPlatforms).some(v => v == false)}
{#if supportedPlatforms.desktop}
<Badge>
{#snippet icon()}
<Icon src={ComputerDesktop} micro size="14" />
{/snippet}
{$t('settings.desktop')}
</Badge>
{/if}
{#if supportedPlatforms.tablet}
<Badge>
{#snippet icon()}
<Icon src={DeviceTablet} micro size="14" />
{/snippet}
{$t('settings.tablet')}
</Badge>
{/if}
{#if supportedPlatforms.mobile}
<Badge>
{#snippet icon()}
<Icon src={DevicePhoneMobile} micro size="14" />
{/snippet}
{$t('settings.mobile')}
</Badge>
{/if}
{/if}
</div>
{/if}
<Switch
bind:checked
class="flex-row-reverse items-center w-full"
labelClass="flex-1 mr-auto"
>
<h1 class="font-medium text-base">{title}</h1>
{#if description}
<p class="text-slate-600 dark:text-zinc-400 text-sm">
{description}
</p>
{/if}
</Switch>
</div>