forked from coracle/flotilla
Add sticky submit buttons to settings pages
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user