mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 16:05:58 +00:00
* fix(frontend): Add container custom css * fix(frontend): Add form custom css * fix(frontend): Add form button custom css * feat(frontend): Add css quick reset button * feat(frontend): Filter component css by usage * fix(frontend): Save state of unused component display * fix(frontend): Add pie chart custom css * fix(frontend): Add bar chart custom css * fix(frontend): Update vega lite and plotly loading * fix(frontend): Add html and timeseries custom css * fix(frontend): Add scatter chart custom css * fix(frontend): Add table custom css * fix(frontend): Revert container custom styles * fix(frontend): Add toggle custom css * fix(frontend): Add text input custom css * fix(frontend): Update * fix(frontend): Remove undefined css customizations
76 lines
1.9 KiB
Svelte
76 lines
1.9 KiB
Svelte
<script lang="ts">
|
|
import { createEventDispatcher } from 'svelte'
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
export let options: {
|
|
left?: string
|
|
right?: string
|
|
} = {}
|
|
export let checked: boolean = false
|
|
export let disabled = false
|
|
export let textClass = ''
|
|
export let textStyle = ''
|
|
|
|
export let size: 'sm' | 'xs' = 'sm'
|
|
const id = (Math.random() + 1).toString(36).substring(10)
|
|
const dispatch = createEventDispatcher()
|
|
</script>
|
|
|
|
<span class="{$$props.class} z-auto">
|
|
<label
|
|
for={id}
|
|
class="inline-flex items-center mt-2 duration-200 {disabled
|
|
? 'grayscale opacity-50'
|
|
: 'cursor-pointer'}"
|
|
>
|
|
{#if Boolean(options?.left)}
|
|
<span
|
|
class={twMerge(
|
|
'ml-2 font-medium duration-200',
|
|
disabled ? 'text-gray-500' : 'text-gray-900',
|
|
size === 'xs' ? 'text-xs' : 'text-sm',
|
|
textClass
|
|
)}
|
|
style={textStyle}
|
|
>
|
|
{options?.left}
|
|
</span>
|
|
{/if}
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
<div class="relative" on:pointerdown on:click|stopPropagation>
|
|
<input
|
|
on:focus
|
|
on:click
|
|
{disabled}
|
|
type="checkbox"
|
|
value={false}
|
|
{id}
|
|
class="sr-only peer"
|
|
bind:checked
|
|
on:change|stopPropagation={(e) => {
|
|
dispatch('change', checked)
|
|
}}
|
|
/>
|
|
<div
|
|
class="w-11 h-6 bg-gray-200 rounded-full peer peer-focus:ring-4 peer-focus:ring-blue-300
|
|
peer-checked:after:translate-x-full peer-checked:after:border-white after:content-['']
|
|
after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300
|
|
after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
|
|
/>
|
|
</div>
|
|
{#if Boolean(options?.right)}
|
|
<span
|
|
class={twMerge(
|
|
'ml-2 font-medium duration-200',
|
|
disabled ? 'text-gray-500' : 'text-gray-900',
|
|
size === 'xs' ? 'text-xs' : 'text-sm',
|
|
textClass
|
|
)}
|
|
style={textStyle}
|
|
>
|
|
{options?.right}
|
|
</span>
|
|
{/if}
|
|
</label>
|
|
</span>
|