feat: allow disabling setting buttons
This commit is contained in:
parent
cfdb9094ce
commit
28a4590b86
3 changed files with 15 additions and 6 deletions
|
@ -4,6 +4,7 @@
|
||||||
@param setting - The setting to be toggled
|
@param setting - The setting to be toggled
|
||||||
@param inverted? - If false, the toggle syncs to the setting (toggle = on, setting = true). If true, the toggle syncs to the setting's inverse (toggle = off, setting = true).
|
@param inverted? - If false, the toggle syncs to the setting (toggle = on, setting = true). If true, the toggle syncs to the setting's inverse (toggle = off, setting = true).
|
||||||
@param tooltip - Helpful tooltip for the setting
|
@param tooltip - Helpful tooltip for the setting
|
||||||
|
@param disabled - Whether or not the setting is disabled
|
||||||
|
|
||||||
@children The setting's label
|
@children The setting's label
|
||||||
-->
|
-->
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
export let setting: keyof SettingsStoreData
|
export let setting: keyof SettingsStoreData
|
||||||
export let inverted: boolean = false
|
export let inverted: boolean = false
|
||||||
export let tooltip: string = ''
|
export let tooltip: string = ''
|
||||||
|
export let disabled: boolean = false
|
||||||
|
|
||||||
$: value = inverted ? !$settingsStore[setting] : $settingsStore[setting]
|
$: value = inverted ? !$settingsStore[setting] : $settingsStore[setting]
|
||||||
|
|
||||||
|
@ -24,4 +26,6 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Switch bind:checked={value} on:click={handleClick} {tooltip}><slot /></Switch>
|
<Switch {disabled} bind:checked={value} on:click={handleClick} {tooltip}
|
||||||
|
><slot /></Switch
|
||||||
|
>
|
||||||
|
|
|
@ -3,14 +3,19 @@
|
||||||
|
|
||||||
export let checked: boolean
|
export let checked: boolean
|
||||||
export let tooltip: string
|
export let tooltip: string
|
||||||
|
export let disabled: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex gap-2">
|
<div
|
||||||
|
class="flex gap-2"
|
||||||
|
class:brightness-75={disabled}
|
||||||
|
class:cursor-not-allowed={disabled}
|
||||||
|
>
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
<input type="checkbox" bind:checked on:click />
|
<input type="checkbox" bind:checked on:click {disabled} />
|
||||||
<span class="slider" />
|
<span class="slider" />
|
||||||
</label>
|
</label>
|
||||||
{#if tooltip !== ''}
|
{#if tooltip !== '' && !disabled}
|
||||||
<Tooltip content={tooltip} arrow={false}>
|
<Tooltip content={tooltip} arrow={false}>
|
||||||
<span class="flex-grow text-xl text-slate-100 font-medium"
|
<span class="flex-grow text-xl text-slate-100 font-medium"
|
||||||
><slot />
|
><slot />
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
{#if visible}
|
{#if visible}
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 103 124">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 103 124">
|
||||||
<g out:fade={{ duration: 200 }} opacity="0.3">
|
<g out:fade={{ duration: 200 }} opacity="0.35">
|
||||||
<path
|
<path
|
||||||
in:expand={{ duration: 400, delay: 1000, easing: quintOut }}
|
in:expand={{ duration: 400, delay: 1000, easing: quintOut }}
|
||||||
style="stroke: #ff3e00; fill: #ff3e00; stroke-width: 50;"
|
style="stroke: #ff3e00; fill: #ff3e00; stroke-width: 50;"
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
/>
|
/>
|
||||||
<path
|
<path
|
||||||
in:draw={{ duration: 1000 }}
|
in:draw={{ duration: 1000 }}
|
||||||
style="stroke:#ff3e00; stroke-width: 1.5"
|
style="stroke:#ff3e00; stroke-width: 1.75"
|
||||||
d={inner}
|
d={inner}
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
|
|
Loading…
Reference in a new issue