Smoking habit tracker

refactor(settings): display mode should be a radio selector #6

Open io-industries.dev
Open opened by io-industries.dev

refactor(settings): display mode should be a radio selector #

Area: Settings · Display · Mode · pages/settings.vue Type: a11y / ui debt Priority: p2

Summary #

The Display → Mode control (statistics / reduce) is currently a button group with aria-pressed. It should be a native radio group.

Current behavior #

pages/settings.vue:181-190:

<div class="data-row">
  <span id="label-mode">{{ t('settings.mode') }}</span>
  <div role="group" aria-labelledby="label-mode">
    <button :aria-pressed="settings.mode==='statistics'" @click="updateSettings('mode','statistics')">…</button>
    <button :aria-pressed="settings.mode==='reduce'" @click="updateSettings('mode','reduce')">…</button>
  </div>
</div>
  • Not keyboard-navigable via arrow keys, not a true radio semantic, screen readers announce as buttons not radios.
  • Visual → from .link-action::after leaks into this control.
  • t('settings.mode_description') is outside the group.

Expected behavior #

Replace with a native radio group:

<fieldset class="data-row">
  <legend id="label-mode" class="data-row-label">{{ t('settings.mode') }}</legend>
  <div class="flex gap-4">
    <label class="flex items-center gap-2 text-xs">
      <input type="radio" name="mode" value="statistics" :checked="settings.mode==='statistics'" @change="updateSettings('mode','statistics')">
      {{ t('settings.statistics') }}
    </label>
    <label class="flex items-center gap-2 text-xs">
      <input type="radio" name="mode" value="reduce" :checked="settings.mode==='reduce'" @change="updateSettings('mode','reduce')">
      {{ t('settings.reduce') }}
    </label>
  </div>
</fieldset>
<p class="section-subtitle">{{ t('settings.mode_description') }}</p>
  • PATCH /api/v2/settings { mode } on change (existing updateSettings('mode', …)).
  • Style radios to match marathon design: flattened rounded-none, accent-primary, 44px hit area if needed — reuse marathon-components.css or DaisyUI radio with rounded-none.
  • Keyboard: arrow keys switch, Tab focuses group.
  • Keep dailyGoal conditional row (v-if="settings.mode==='reduce'") working.

Files to touch #

  • pages/settings.vue:181-192 — mode block

Acceptance criteria #

How to test #

  1. Open Settings → Display → inspect Mode → should be radios.
  2. Toggle via click and via keyboard arrows → verify dailyGoal row appears/disappears for reduce.
  3. Reload → selection persists.
Sign up or Sign in to add to the discussion.