status/gui/dashboard/settings.svelte

99 lines
2.1 KiB
Svelte
Raw Normal View History

<script>
import Modal from './modal.svelte';
2023-02-24 09:07:08 +00:00
import { ringBell, settings } from './lib';
let open = false;
let showCopyCheck = false;
2023-02-23 10:03:15 +00:00
let copyButton;
2023-02-23 10:03:15 +00:00
function openModal() {
open = true;
copyButton?.focus();
}
function copy() {
if (typeof navigator.clipboard?.writeText === 'function') {
navigator.clipboard.writeText(JSON.stringify($settings));
showCopyCheck = true;
setTimeout(() => showCopyCheck = false, 2000);
}
}
2023-02-23 10:03:15 +00:00
function keydown(event) {
if ((event.key === ',') && (event.metaKey || event.ctrlKey)) {
event.preventDefault();
openModal();
}
}
</script>
2023-02-23 10:03:15 +00:00
<svelte:window on:keydown={keydown} />
<button class="settings" on:click={openModal}>
2022-07-15 15:10:52 +00:00
Settings
</button>
<Modal title="Settings" bind:open>
<div class="mb">
2023-02-23 10:03:15 +00:00
<button on:click={copy} class="btn copy" bind:this={copyButton}>
Copy settings to clipboard
{#if showCopyCheck}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 405.27 405.27">
<path d="M393.4 124.42 179.6 338.21a40.57 40.57 0 0 1-57.36 0L11.88 227.84a40.56 40.56 0 0 1 57.35-57.37l81.7 81.7 185.1-185.1a40.57 40.57 0 0 1 57.37 57.36z"/>
</svg>
{/if}
</button>
2023-02-24 09:07:08 +00:00
<button on:click={ringBell} class="btn">
Test bell
</button>
</div>
<label>
Color theme
<select bind:value={$settings.theme}>
<option value="dark">Dark</option>
<option value="light">Light</option>
</select>
</label>
2022-10-28 13:16:04 +00:00
<label>
Enable animations
<input type="checkbox" bind:checked={$settings.animate} />
</label>
<label>
Columns
2022-07-18 09:40:44 +00:00
<input type="number" bind:value={$settings.cols} width="10" />
</label>
<label>
Rows
2022-07-18 09:40:44 +00:00
<input type="number" bind:value={$settings.rows} width="10" />
</label>
<label>
Font size (REMs)
<input type="number" bind:value={$settings.fontSize} width="10" step="0.1" />
</label>
</Modal>
<style>
button.settings {
opacity: 0.4;
color: var(--body-fg);
2022-07-15 15:10:52 +00:00
padding: 0;
display: grid;
}
button.settings:hover {
opacity: 0.9;
}
button.copy svg {
2023-02-24 09:07:08 +00:00
fill: currentColor;
height: 1rem;
width: 1rem;
2023-02-24 09:07:08 +00:00
margin-left: 0.5rem;
}
</style>