Add sticky submit buttons to settings pages

This commit is contained in:
Jon Staab
2026-02-02 09:51:36 -08:00
parent 38c0a9d403
commit 4480132c74
13 changed files with 43 additions and 78 deletions
+4 -17
View File
@@ -1,28 +1,19 @@
<script lang="ts">
import cx from "classnames"
import {sleep, equals, remove} from "@welshman/lib"
import {displayRelayUrl} from "@welshman/util"
import {sleep} from "@welshman/lib"
import {Capacitor} from "@capacitor/core"
import {Badge} from "@capawesome/capacitor-badge"
import CloseCircle from "@assets/icons/close-circle.svg?dataurl"
import {preventDefault} from "@lib/html"
import Icon from "@lib/components/Icon.svelte"
import Spinner from "@lib/components/Spinner.svelte"
import Button from "@lib/components/Button.svelte"
import RoomName from "@app/components/RoomName.svelte"
import {pushToast} from "@app/util/toast"
import {Push, clearBadges} from "@app/util/notifications"
import {notificationSettings, userSettingsValues, splitRoomId} from "@app/core/state"
import {publishSettings} from "@app/core/commands"
import {notificationSettings} from "@app/core/state"
const reset = () => {
settings = {...notificationSettings.get()}
}
const removeMutedRoom = (id: string) => {
muted_rooms = remove(id, muted_rooms)
}
const onsubmit = preventDefault(async () => {
loading = true
@@ -46,10 +37,6 @@
}
}
if (!equals(muted_rooms, $userSettingsValues.muted_rooms)) {
publishSettings($state.snapshot({...$userSettingsValues, muted_rooms}))
}
notificationSettings.set(settings)
pushToast({message: "Your settings have been saved!"})
@@ -60,7 +47,6 @@
let loading = $state(false)
let settings = $state({...notificationSettings.get()})
let muted_rooms = $state($userSettingsValues.muted_rooms)
</script>
<form class="content column gap-4" {onsubmit}>
@@ -105,7 +91,8 @@
<input type="checkbox" class="toggle toggle-primary" bind:checked={settings.messages} />
</div>
</div>
<div class="mt-4 flex flex-row items-center justify-between gap-4">
<div
class="card2 bg-alt sticky -bottom-3 shadow-md flex flex-row items-center justify-between gap-4">
<Button class="btn btn-neutral" onclick={reset} disabled={loading}>Discard Changes</Button>
<Button type="submit" class="btn btn-primary" disabled={loading}>
<Spinner {loading}>Save Changes</Spinner>
+27 -22
View File
@@ -87,6 +87,28 @@
</div>
{/snippet}
</Field>
</div>
<div class="card2 bg-alt col-4 shadow-md">
<strong class="text-lg">Accessibility</strong>
<Field>
{#snippet label()}
<p>Font size</p>
{/snippet}
{#snippet secondary()}
<p>{Math.round(settings.font_size * 100)}%</p>
{/snippet}
{#snippet input()}
<input
class="range range-primary"
type="range"
min="0.8"
max="1.3"
step="0.05"
bind:value={settings.font_size} />
{/snippet}
</Field>
</div>
<div class="card2 bg-alt col-4 shadow-md">
<strong class="text-lg">Editor Settings</strong>
<FieldInline>
{#snippet label()}
@@ -123,27 +145,10 @@
<p>Choose a media server type and url for files you upload to {PLATFORM_NAME}.</p>
{/snippet}
</Field>
<strong class="text-lg">Accessibility</strong>
<Field>
{#snippet label()}
<p>Font size</p>
{/snippet}
{#snippet secondary()}
<p>{Math.round(settings.font_size * 100)}%</p>
{/snippet}
{#snippet input()}
<input
class="range range-primary"
type="range"
min="0.8"
max="1.3"
step="0.05"
bind:value={settings.font_size} />
{/snippet}
</Field>
<div class="mt-4 flex flex-row items-center justify-between gap-4">
<Button class="btn btn-neutral" onclick={reset}>Discard Changes</Button>
<Button type="submit" class="btn btn-primary">Save Changes</Button>
</div>
</div>
<div
class="card2 bg-alt sticky -bottom-3 shadow-md flex flex-row items-center justify-between gap-4">
<Button class="btn btn-neutral" onclick={reset}>Discard Changes</Button>
<Button type="submit" class="btn btn-primary">Save Changes</Button>
</div>
</form>
+5 -4
View File
@@ -50,9 +50,10 @@
Allow {PLATFORM_NAME} to collect anonymous usage data.
</p>
</div>
<div class="mt-4 flex flex-row items-center justify-between gap-4">
<Button class="btn btn-neutral" onclick={reset}>Discard Changes</Button>
<Button type="submit" class="btn btn-primary">Save Changes</Button>
</div>
</div>
<div
class="card2 bg-alt sticky -bottom-3 shadow-md flex flex-row items-center justify-between gap-4">
<Button class="btn btn-neutral" onclick={reset}>Discard Changes</Button>
<Button type="submit" class="btn btn-primary">Save Changes</Button>
</div>
</form>
+2 -3
View File
@@ -1,12 +1,11 @@
<script lang="ts">
import {readable, derived as _derived} from "svelte/store"
import {readable} from "svelte/store"
import {onMount, onDestroy} from "svelte"
import {page} from "$app/stores"
import type {Readable} from "svelte/store"
import type {MakeNonOptional} from "@welshman/lib"
import {now, int, append, remove, formatTimestampAsDate, ago, MINUTE} from "@welshman/lib"
import {now, int, formatTimestampAsDate, ago, MINUTE} from "@welshman/lib"
import type {TrustedEvent, EventContent} from "@welshman/util"
import {throttled} from "@welshman/store"
import {
makeEvent,
makeRoomMeta,