Vue kit: UiCheckbox for the Visual, voice, Data Library and welcome checkboxes

UiCheckbox is a label wrapping a native checkbox and its words; trailing
puts the box after them, as the Visual panel's rows have it. v-model shows
the value and emits the checked state, and change is emitted with its event;
without a modelValue the box is the browser's own, as the welcome card's
"Don't show this again" is. restore puts the box back to modelValue once a
change has rendered without the owner taking it, which is what the voice
panel's v-checked directive did for a refused preference. Attributes go to
the label; inputId and inputAttrs to the box.

checkbox.css holds the centred flex row, moved out of the two labels that
hold only a checkbox (first-run.css, library.css) and loaded before them.
Each box keeps its skin's size, margin and accent colour. checkboxes.test.mjs
fails if a view writes a checkbox by hand; Story Explore's filters are not
converted yet.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-19 01:05:12 -08:00
1 parent 52dd576769
commit 2d7b7be890
18 files changed
+385 -41

No files matched your search

+7 -7
View File
@@ -3,6 +3,7 @@ import { storeToRefs } from 'pinia';
import { computed, nextTick, useTemplateRef, watch } from 'vue';
import { formatNumber, t, tn } from '../../../i18n/index.js';
import UiButton from '../../kit/UiButton.vue';
import UiCheckbox from '../../kit/UiCheckbox.vue';
import UiCloseButton from '../../kit/UiCloseButton.vue';
import UiSelect from '../../kit/UiSelect.js';
import {
@@ -153,14 +154,13 @@ const onDialogClick = (event) => {
@update:model-value="controls?.setFamily($event)"
/>
</label>
<label class="data-library-check">
<input
type="checkbox"
:checked="view.filter.availableOnly"
@change="controls?.setAvailableOnly($event.target.checked)"
/>
<UiCheckbox
class="data-library-check"
:model-value="view.filter.availableOnly"
@update:model-value="controls?.setAvailableOnly($event)"
>
<span>{{ t('Only what this instance serves') }}</span>
</label>
</UiCheckbox>
</div>
<div class="data-library-toolbar">
<p class="data-library-status" role="status" aria-live="polite">
+7 -9
View File
@@ -11,6 +11,7 @@ import UiSegmented from '../../kit/UiSegmented.vue';
import UiSlider from '../../kit/UiSlider.js';
import { useDisplayStore } from '../../stores/display.js';
import UiButton from '../../kit/UiButton.vue';
import UiCheckbox from '../../kit/UiCheckbox.vue';
import UiSelect from '../../kit/UiSelect.js';
import { StyleParameterRows } from '../../styleParameters.js';
import VisualPresets from './VisualPresets.vue';
@@ -182,11 +183,10 @@ const allocationOptions = computed(() => [
</div>
</Teleport>
<div class="pp-toggle-group">
<label class="pp-toggle-btn pp-scope-toggle" :title="t('Scope — the circular viewport mask')">
<UiCheckbox class="pp-toggle-btn pp-scope-toggle" :title="t('Scope — the circular viewport mask')" input-id="scope-toggle" trailing :model-value="scopeOn" @update:model-value="act('setScopeEnabled', $event)">
<span class="pp-icon material-symbols-outlined" aria-hidden="true">adjust</span>
<span class="pp-label">{{ t('Scope') }}</span>
<input type="checkbox" id="scope-toggle" @change="act('setScopeEnabled', $event.target.checked)" :checked="scopeOn" />
</label>
</UiCheckbox>
<div class="pp-slider-row visible" id="scope-slider-row">
<span class="pp-slider-mini-label">{{ t('Feather') }}</span>
<UiSlider class="pp-slider" id="scope-feather-slider" @update:model-value="act('setScopeFeather', $event)" min="0" max="200" :model-value="scopeFeather" :disabled="!scopeOn" :aria-label="t('Scope edge feather')" :title="t('Scope edge feather as a percentage of the keyhole radius')" />
@@ -211,11 +211,10 @@ const allocationOptions = computed(() => [
</div>
<!-- Sky: only where the renderer has a sky to set. -->
<div v-if="sky" class="pp-toggle-group" id="sky-group">
<label v-for="row in skyRows" :key="row.key" class="pp-toggle-btn pp-scope-toggle" :id="`sky-${row.key}-row`">
<UiCheckbox v-for="row in skyRows" :key="row.key" class="pp-toggle-btn pp-scope-toggle" :id="`sky-${row.key}-row`" :input-id="`sky-${row.key}-toggle`" trailing :model-value="sky.switches[row.key]" @update:model-value="act('setSkySwitch', row.key, $event)">
<span class="pp-icon material-symbols-outlined" aria-hidden="true">{{ row.icon }}</span>
<span class="pp-label">{{ row.label }}</span>
<input type="checkbox" :id="`sky-${row.key}-toggle`" @change="act('setSkySwitch', row.key, $event.target.checked)" :checked="sky.switches[row.key]" />
</label>
</UiCheckbox>
<div class="pp-slider-row visible" id="sky-milkyway-row">
<span class="pp-slider-mini-label">{{ t('Milky Way') }}</span>
<UiSlider class="pp-slider" id="sky-milkyway-slider" @update:model-value="act('setSkyMilkyWay', $event)" min="0" max="100" :model-value="sky.milkyWay" :aria-label="t('Milky Way')" />
@@ -225,11 +224,10 @@ const allocationOptions = computed(() => [
<!-- Groups the application adds (store `publishGroup`). -->
<div v-for="group in groups" :key="group.id" class="pp-toggle-group" :id="`${group.id}-group`">
<template v-for="row in group.rows" :key="row.id">
<label v-if="row.kind === 'toggle'" class="pp-toggle-btn pp-scope-toggle" :title="row.title">
<UiCheckbox v-if="row.kind === 'toggle'" class="pp-toggle-btn pp-scope-toggle" :title="row.title" :input-id="`${group.id}-${row.id}-toggle`" trailing :model-value="row.checked" @update:model-value="row.onChange?.($event)">
<span v-if="row.icon" class="pp-icon material-symbols-outlined" aria-hidden="true">{{ row.icon }}</span>
<span class="pp-label">{{ row.label }}</span>
<input type="checkbox" :id="`${group.id}-${row.id}-toggle`" @change="row.onChange?.($event.target.checked)" :checked="row.checked" />
</label>
</UiCheckbox>
<div v-else-if="row.kind === 'note'" class="pp-slider-row visible" :id="`${group.id}-${row.id}`">
<span class="pp-slider-mini-label">{{ row.text }}</span>
</div>
+6 -12
View File
@@ -9,6 +9,7 @@ import VoiceVisualizer from './VoiceVisualizer.vue';
import ChatPanel from './ChatPanel.vue';
import PanelLayoutButtons from './PanelLayoutButtons.vue';
import UiButton from '../../kit/UiButton.vue';
import UiCheckbox from '../../kit/UiCheckbox.vue';
import UiCloseButton from '../../kit/UiCloseButton.vue';
import UiSelect from '../../kit/UiSelect.js';
@@ -19,16 +20,9 @@ defineProps({ view: { type: Object, required: true } });
const { controls } = storeToRefs(useVoiceStore());
const emit = (name, ...args) => controls.value?.emit(name, ...args);
// A value the owner may restore after a refused change; written on every
// render, as the owner's own writes were.
const vChecked = {
mounted(el, { value }) {
el.checked = value;
},
updated(el, { value }) {
if (el.checked !== value) el.checked = value;
},
};
// The Voice Preview box's note, as one object, so the panel's other renders
// do not render the box again.
const previewBoxAttrs = { 'aria-describedby': 'gev-voice-preview-note' };
// The minutes field holds a draft until it changes: write it only when its
// owner does, not on every render (the waveform renders each frame).
const vOwnedValue = {
@@ -127,11 +121,11 @@ const frameStyle = (panel) => ({
</label>
<p class="gev-voice-settings-note">{{ t('The selected AI provider is shared by voice and chat.') }}</p>
<div id="gev-settings-chat">
<label class="gev-voice-preference gev-voice-preference-toggle"><input id="gev-chat-quick" type="checkbox" v-checked="view.chat.quickChecked" @change="emit('chat-quick-change', $event.target.checked)" /><span>{{ t('Show quick commands') }}</span></label>
<UiCheckbox class="gev-voice-preference gev-voice-preference-toggle" input-id="gev-chat-quick" restore :model-value="view.chat.quickChecked" @update:model-value="emit('chat-quick-change', $event)"><span>{{ t('Show quick commands') }}</span></UiCheckbox>
<p>{{ t('Chat replies are silent. No microphone access is needed.') }}</p>
</div>
<div id="gev-settings-voice">
<label class="gev-voice-preference gev-voice-preference-toggle"><input id="gev-voice-preview-enabled" type="checkbox" aria-describedby="gev-voice-preview-note" v-checked="view.preferences.previewChecked" @change="emit('preview-change', $event.target.checked)" /><span>{{ t('Show Voice Preview') }}</span></label>
<UiCheckbox class="gev-voice-preference gev-voice-preference-toggle" input-id="gev-voice-preview-enabled" :input-attrs="previewBoxAttrs" restore :model-value="view.preferences.previewChecked" @update:model-value="emit('preview-change', $event)"><span>{{ t('Show Voice Preview') }}</span></UiCheckbox>
<p id="gev-voice-preview-note" class="gev-voice-settings-note">{{ view.preferences.previewNote }}</p>
<div class="gev-voice-timeout-group">
<label class="gev-voice-preference gev-voice-setting-title" for="gev-voice-timeout-select">{{ t('Voice inactivity timeout') }}</label>