Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Settings: a rainbow swatch after the presets picks your own accent colour

Duarte Santos0884cff5b0ec
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 1f7cab562..1823faa1c 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1685,6 +1685,16 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}
.swatch{width:32px;height:32px;border-radius:50%;flex:none;position:relative;transition:transform var(--fast)}
.swatch:active{transform:scale(.9)}
.swatch.on::after{content:'';position:absolute;inset:-4px;border-radius:50%;box-shadow:0 0 0 2px var(--label)}
+/* The user's own colour (Settings → Accent color): a rainbow ring until there is one, then filled
+ with it. The native colour input lies over it, invisible, so the tap lands on the input itself. */
+.swatch-own{display:inline-flex;align-items:center;justify-content:center;font-size:15px;--icon-stroke:2.4}
+.swatch-own.unset{
+ background:radial-gradient(circle,var(--surface) 0 52%,transparent 54%),
+ conic-gradient(#ff453a,#ff9f0a,#ffd60a,#30d158,#40c8e0,#0a84ff,#bf5af2,#ff375f,#ff453a);
+ color:var(--label-2);
+}
+.swatch-input{position:absolute;inset:0;width:100%;height:100%;opacity:0;border:0;padding:0;margin:0;border-radius:50%;cursor:pointer;-webkit-appearance:none;appearance:none}
+.swatch-note{margin-top:-4px}
/* --- supersets --- */
.ss-label{
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 1388ffeea..451381609 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {
// has to be taught is a number nobody reads. What the numbers stood for is asserted above.
// If the hash fails, review the changed keys and wording before accepting a new one. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('9158547c74fd92bfe714f164605189a4679cd95c8d34724b4daa09cb36779659')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('7ef67d57197521110494281c17de3950176f0db14769a9e953b2e9bff47db8af')
})
test('does not leak European Portuguese UI terms', () => {
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index 59de5e58c..3e9f76389 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -1980,4 +1980,10 @@ export default {
'Swipe on sets': 'السحب على المجموعات',
'Left deletes, right copies': 'لليمين حذف، لليسار نسخ',
'Options: copy, remove': 'خيارات: نسخ، إزالة',
+ 'Your own color': 'لونك الخاص',
+ 'Pick your own color': 'اختر لونك الخاص',
+ 'Change your own color': 'غيّر لونك الخاص',
+ 'A touch lighter in dark mode, so you can still read it.': 'أفتح قليلًا في الوضع الداكن حتى تبقى قراءته سهلة.',
+ 'A touch darker in light mode, so you can still read it.': 'أغمق قليلًا في الوضع الفاتح حتى تبقى قراءته سهلة.',
+ 'custom color picker': 'لون خاص مخصص منتقي الألوان',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 227e69cbc..972d7aeb0 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1947,4 +1947,10 @@ export default {
'Swipe on sets': 'Wischen auf Sätzen',
'Left deletes, right copies': 'Links löscht, rechts kopiert',
'Options: copy, remove': 'Optionen: kopieren, entfernen',
+ 'Your own color': 'Deine eigene Farbe',
+ 'Pick your own color': 'Eigene Farbe auswählen',
+ 'Change your own color': 'Eigene Farbe ändern',
+ 'A touch lighter in dark mode, so you can still read it.': 'Im dunklen Modus etwas heller, damit du sie noch lesen kannst.',
+ 'A touch darker in light mode, so you can still read it.': 'Im hellen Modus etwas dunkler, damit du sie noch lesen kannst.',
+ 'custom color picker': 'eigene Farbe benutzerdefiniert Farbwähler Farbauswahl',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index d8d72ee20..18d06dbc9 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'Deslizar en las series',
'Left deletes, right copies': 'Izquierda borra, derecha copia',
'Options: copy, remove': 'Opciones: copiar, quitar',
+ 'Your own color': 'Tu propio color',
+ 'Pick your own color': 'Elige tu propio color',
+ 'Change your own color': 'Cambia tu propio color',
+ 'A touch lighter in dark mode, so you can still read it.': 'Un pelín más claro en modo oscuro, para que se siga leyendo.',
+ 'A touch darker in light mode, so you can still read it.': 'Un pelín más oscuro en modo claro, para que se siga leyendo.',
+ 'custom color picker': 'color propio personalizado selector de color',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 6056afdd3..b4b9341ca 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'Glisser sur les séries',
'Left deletes, right copies': 'Gauche supprime, droite copie',
'Options: copy, remove': 'Options : copier, supprimer',
+ 'Your own color': 'Ta propre couleur',
+ 'Pick your own color': 'Choisis ta propre couleur',
+ 'Change your own color': 'Change ta propre couleur',
+ 'A touch lighter in dark mode, so you can still read it.': 'Un poil plus claire en mode sombre, pour rester lisible.',
+ 'A touch darker in light mode, so you can still read it.': 'Un poil plus foncée en mode clair, pour rester lisible.',
+ 'custom color picker': 'couleur perso personnalisée sélecteur nuancier',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 762287183..5d08178b4 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'सेट पर स्वाइप',
'Left deletes, right copies': 'बाएँ हटाता है, दाएँ कॉपी करता है',
'Options: copy, remove': 'विकल्प: कॉपी, हटाएँ',
+ 'Your own color': 'आपका अपना रंग',
+ 'Pick your own color': 'अपना रंग चुनें',
+ 'Change your own color': 'अपना रंग बदलें',
+ 'A touch lighter in dark mode, so you can still read it.': 'डार्क मोड में थोड़ा हल्का, ताकि पढ़ने में आए।',
+ 'A touch darker in light mode, so you can still read it.': 'लाइट मोड में थोड़ा गहरा, ताकि पढ़ने में आए।',
+ 'custom color picker': 'अपना रंग कस्टम रंग चुनने वाला',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 35060e21e..23f52e503 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1930,4 +1930,10 @@ export default {
'Swipe on sets': 'Húzás a sorozatokon',
'Left deletes, right copies': 'Balra töröl, jobbra másol',
'Options: copy, remove': 'Lehetőségek: másolás, eltávolítás',
+ 'Your own color': 'Saját színed',
+ 'Pick your own color': 'Válassz saját színt',
+ 'Change your own color': 'Saját szín módosítása',
+ 'A touch lighter in dark mode, so you can still read it.': 'Sötét módban kicsit világosabb, hogy olvasható maradjon.',
+ 'A touch darker in light mode, so you can still read it.': 'Világos módban kicsit sötétebb, hogy olvasható maradjon.',
+ 'custom color picker': 'saját szín egyéni színválasztó',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 79e9a9368..cd67d80a2 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'Scorri sulle serie',
'Left deletes, right copies': 'Sinistra elimina, destra copia',
'Options: copy, remove': 'Opzioni: copia, rimuovi',
+ 'Your own color': 'Il tuo colore',
+ 'Pick your own color': 'Scegli il tuo colore',
+ 'Change your own color': 'Cambia il tuo colore',
+ 'A touch lighter in dark mode, so you can still read it.': 'Un filo più chiaro in modalità scura, così resta leggibile.',
+ 'A touch darker in light mode, so you can still read it.': 'Un filo più scuro in modalità chiara, così resta leggibile.',
+ 'custom color picker': 'colore personalizzato proprio selettore colore',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 9f6b1e563..f9174ab3a 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': '세트 스와이프',
'Left deletes, right copies': '왼쪽은 삭제, 오른쪽은 복사',
'Options: copy, remove': '옵션: 복사, 삭제',
+ 'Your own color': '나만의 색상',
+ 'Pick your own color': '나만의 색상 고르기',
+ 'Change your own color': '나만의 색상 바꾸기',
+ 'A touch lighter in dark mode, so you can still read it.': '다크 모드에서는 잘 보이도록 살짝 밝게 표시돼요.',
+ 'A touch darker in light mode, so you can still read it.': '라이트 모드에서는 잘 보이도록 살짝 어둡게 표시돼요.',
+ 'custom color picker': '나만의 색상 사용자 지정 색상 선택기',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 349cc75e1..31b0d698a 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'Przesuwanie serii',
'Left deletes, right copies': 'W lewo usuwa, w prawo kopiuje',
'Options: copy, remove': 'Opcje: kopiuj, usuń',
+ 'Your own color': 'Twój własny kolor',
+ 'Pick your own color': 'Wybierz własny kolor',
+ 'Change your own color': 'Zmień własny kolor',
+ 'A touch lighter in dark mode, so you can still read it.': 'Odrobinę jaśniejszy w trybie ciemnym, żeby dało się go przeczytać.',
+ 'A touch darker in light mode, so you can still read it.': 'Odrobinę ciemniejszy w trybie jasnym, żeby dało się go przeczytać.',
+ 'custom color picker': 'własny kolor niestandardowy próbnik wybór koloru',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index dd1d99e94..840e29c05 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1192,6 +1192,11 @@ export const PT_BR_OVERRIDES = {
'Too late, that one’s gone': 'Tarde demais, já era',
'Psst: swipe a set. Left deletes, right copies.': 'Psiu: deslize uma série. Esquerda exclui, direita copia.',
'Left deletes, right copies': 'Esquerda exclui, direita copia',
+ 'Your own color': 'Sua própria cor',
+ 'Pick your own color': 'Escolha sua própria cor',
+ 'Change your own color': 'Mude sua própria cor',
+ 'A touch lighter in dark mode, so you can still read it.': 'Um pouco mais clara no modo escuro, para você continuar lendo.',
+ 'A touch darker in light mode, so you can still read it.': 'Um pouco mais escura no modo claro, para você continuar lendo.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 4ed2329eb..6f23fdd90 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'Deslizar nas séries',
'Left deletes, right copies': 'Esquerda elimina, direita copia',
'Options: copy, remove': 'Opções: copiar, remover',
+ 'Your own color': 'A tua própria cor',
+ 'Pick your own color': 'Escolhe a tua própria cor',
+ 'Change your own color': 'Muda a tua própria cor',
+ 'A touch lighter in dark mode, so you can still read it.': 'Um pouco mais clara no modo escuro, para continuares a ler.',
+ 'A touch darker in light mode, so you can still read it.': 'Um pouco mais escura no modo claro, para continuares a ler.',
+ 'custom color picker': 'cor própria personalizada seletor de cor',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index b404d5704..6cb163a37 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1931,4 +1931,10 @@ export default {
'Swipe on sets': 'Свайп по подходам',
'Left deletes, right copies': 'Влево удаляет, вправо копирует',
'Options: copy, remove': 'Действия: копировать, удалить',
+ 'Your own color': 'Свой цвет',
+ 'Pick your own color': 'Выбрать свой цвет',
+ 'Change your own color': 'Изменить свой цвет',
+ 'A touch lighter in dark mode, so you can still read it.': 'В тёмной теме чуть светлее, чтобы его было видно.',
+ 'A touch darker in light mode, so you can still read it.': 'В светлой теме чуть темнее, чтобы его было видно.',
+ 'custom color picker': 'свой цвет пользовательский палитра выбор цвета',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index f74488274..8b1908931 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1938,4 +1938,10 @@ export default {
'Swipe on sets': 'ปัดบนเซ็ต',
'Left deletes, right copies': 'ซ้ายลบ ขวาคัดลอก',
'Options: copy, remove': 'ตัวเลือก: คัดลอก, ลบ',
+ 'Your own color': 'สีของคุณเอง',
+ 'Pick your own color': 'เลือกสีของคุณเอง',
+ 'Change your own color': 'เปลี่ยนสีของคุณเอง',
+ 'A touch lighter in dark mode, so you can still read it.': 'ในโหมดมืดจะสว่างขึ้นนิดหน่อย จะได้ยังอ่านออก',
+ 'A touch darker in light mode, so you can still read it.': 'ในโหมดสว่างจะเข้มขึ้นนิดหน่อย จะได้ยังอ่านออก',
+ 'custom color picker': 'สีเอง กำหนดเอง ตัวเลือกสี',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 3b4ba9f80..0be26e57e 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': 'Setlerde kaydırma',
'Left deletes, right copies': 'Sola silir, sağa kopyalar',
'Options: copy, remove': 'Seçenekler: kopyala, kaldır',
+ 'Your own color': 'Kendi rengin',
+ 'Pick your own color': 'Kendi rengini seç',
+ 'Change your own color': 'Kendi rengini değiştir',
+ 'A touch lighter in dark mode, so you can still read it.': 'Karanlık modda biraz daha açık, hâlâ okunabilsin diye.',
+ 'A touch darker in light mode, so you can still read it.': 'Aydınlık modda biraz daha koyu, hâlâ okunabilsin diye.',
+ 'custom color picker': 'kendi renk özel renk seçici',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index 733a4e63f..85b23c7d3 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -1924,4 +1924,10 @@ export default {
'Swipe on sets': 'Свайп по підходах',
'Left deletes, right copies': 'Ліворуч видаляє, праворуч копіює',
'Options: copy, remove': 'Дії: копіювати, видалити',
+ 'Your own color': 'Свій колір',
+ 'Pick your own color': 'Вибрати свій колір',
+ 'Change your own color': 'Змінити свій колір',
+ 'A touch lighter in dark mode, so you can still read it.': 'У темній темі трохи світліший, щоб його було видно.',
+ 'A touch darker in light mode, so you can still read it.': 'У світлій темі трохи темніший, щоб його було видно.',
+ 'custom color picker': 'свій колір власний палітра вибір кольору',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index 4bed58755..e5b69fc2a 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -1920,4 +1920,10 @@ export default {
'Swipe on sets': '在組上滑動',
'Left deletes, right copies': '左滑刪除,右滑複製',
'Options: copy, remove': '選項:複製、刪除',
+ 'Your own color': '你自己的顏色',
+ 'Pick your own color': '選擇你自己的顏色',
+ 'Change your own color': '更改你自己的顏色',
+ 'A touch lighter in dark mode, so you can still read it.': '深色模式下會稍微調亮一點,讓你看得清楚。',
+ 'A touch darker in light mode, so you can still read it.': '淺色模式下會稍微調暗一點,讓你看得清楚。',
+ 'custom color picker': '自訂顏色 自己的顏色 取色器 調色盤',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 2b391cfc7..77a8c9573 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1927,4 +1927,10 @@ export default {
'Swipe on sets': '在组上滑动',
'Left deletes, right copies': '左滑删除,右滑复制',
'Options: copy, remove': '选项:复制、删除',
+ 'Your own color': '你自己的颜色',
+ 'Pick your own color': '选择你自己的颜色',
+ 'Change your own color': '更改你自己的颜色',
+ 'A touch lighter in dark mode, so you can still read it.': '深色模式下会稍微调亮一点,好让你看得清。',
+ 'A touch darker in light mode, so you can still read it.': '浅色模式下会稍微调暗一点,好让你看得清。',
+ 'custom color picker': '自定义颜色 自己的颜色 取色器 调色板',
}
diff --git a/frontend/src/views/Settings.accent.test.jsx b/frontend/src/views/Settings.accent.test.jsx
new file mode 100644
index 000000000..3f0ff6d4c
--- /dev/null
+++ b/frontend/src/views/Settings.accent.test.jsx
@@ -0,0 +1,135 @@
+// @vitest-environment happy-dom
+import React, { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import Settings from './Settings.jsx'
+import { searchSettings } from './settings-pages.js'
+import { setRestAccent } from '../lib/rest-alert.js'
+
+globalThis.IS_REACT_ACT_ENVIRONMENT = true
+
+const mocks = vi.hoisted(() => {
+ const state = { S: null }
+ state.snapshot = () => ({
+ S: state.S,
+ user: null,
+ update: mut => {
+ const next = structuredClone(state.S)
+ mut(next)
+ state.S = next
+ },
+ replaceState: vi.fn(), setUser: vi.fn(), pullState: vi.fn(), pushState: vi.fn(),
+ signOut: vi.fn(), signOutAll: vi.fn(), resetDemo: vi.fn(), disconnectServer: vi.fn(),
+ })
+ return state
+})
+vi.mock('../store/useStore.js', () => {
+ const useStore = selector => selector ? selector(mocks.snapshot()) : mocks.snapshot()
+ useStore.getState = mocks.snapshot
+ return { useStore, DEF: { reminder: { time: '17:30' } }, hasData: () => false }
+})
+vi.mock('../store/useUI.js', () => {
+ const snap = () => ({ toast: vi.fn(), openSheet: vi.fn() })
+ const useUI = selector => selector ? selector(snap()) : snap()
+ useUI.getState = snap
+ return { useUI }
+})
+vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))
+vi.mock('../lib/api.js', () => ({
+ api: vi.fn(), webauthnOK: () => false, passkeyLogin: vi.fn(), passkeyRegister: vi.fn(), IS_ANDROID: false,
+}))
+vi.mock('../lib/push.js', () => ({ pushSupported: () => false, enablePush: vi.fn(), disablePush: vi.fn(), sendTestPush: vi.fn() }))
+vi.mock('../lib/wakelock.js', () => ({ wakeLockSupported: () => false }))
+vi.mock('../lib/mobile.js', () => ({ MOBILE: false, isAndroid: () => Promise.resolve(false), shareExport: vi.fn(), syncReminder: vi.fn() }))
+vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null }))
+vi.mock('../sheets.jsx', () => ({
+ starterPlanSheet: vi.fn(), confirmSheet: vi.fn(), importFromApp: vi.fn(),
+ importFromHevy: vi.fn(), equipmentProfileSheet: vi.fn(),
+}))
+
+// The Settings view reads the build-time version constant at render time.
+globalThis.__APP_VERSION__ ??= 'test'
+
+vi.mock('../lib/rest-alert.js', () => ({ setRestAccent: vi.fn() }))
+
+let host, root
+beforeEach(() => {
+ mocks.S = { unit: 'kg', theme: 'dark', accent: 'lime', workouts: [], routines: [], exWeights: {} }
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ setRestAccent.mockClear()
+})
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+})
+
+const mount = () => act(() => root.render(<Settings page="look" />))
+const own = () => host.querySelector('.swatch-own')
+const picker = () => host.querySelector('.swatch-own input[type="color"]')
+// React listens for 'input' on a colour field; set the value the way the browser does.
+const pick = value => act(() => {
+ const input = picker()
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(input, value)
+ input.dispatchEvent(new Event('input', { bubbles: true }))
+})
+
+describe('Settings: your own accent colour', () => {
+ it('starts as a rainbow swatch that opens the colour picker', () => {
+ mount()
+ expect(own().classList.contains('unset')).toBe(true)
+ expect(picker()).toBeTruthy()
+ expect(picker().getAttribute('aria-label')).toBe('Pick your own color')
+ })
+
+ it('picking a colour makes it the accent, and the row says so', () => {
+ mount()
+ pick('#FF00AA')
+ expect(mocks.S.accent).toBe('custom')
+ expect(mocks.S.accentCustom).toBe('#ff00aa')
+ expect(setRestAccent).toHaveBeenCalledWith('#ff00aa')
+ mount()
+ expect(host.querySelector('.lrow-v').textContent).toBe('Your own color')
+ expect(own().classList.contains('on')).toBe(true)
+ expect(own().style.background).toContain('#ff00aa')
+ })
+
+ it('a preset in between keeps the colour, and one tap brings it back', () => {
+ mocks.S.accent = 'custom'; mocks.S.accentCustom = '#123456'
+ mount()
+ act(() => host.querySelector('.swatch[aria-label="Blue"]').click())
+ expect(mocks.S.accent).toBe('sky')
+ expect(mocks.S.accentCustom).toBe('#123456')
+ mount()
+ expect(picker()).toBe(null) // not the accent now: a tap selects it, no picker
+ act(() => own().click())
+ expect(mocks.S.accent).toBe('custom')
+ expect(mocks.S.accentCustom).toBe('#123456')
+ mount()
+ expect(picker().getAttribute('aria-label')).toBe('Change your own color')
+ })
+
+ it('says when the colour is drawn lighter in dark mode', () => {
+ mocks.S.accent = 'custom'; mocks.S.accentCustom = '#000033'
+ mount()
+ expect(host.textContent).toContain('A touch lighter in dark mode, so you can still read it.')
+ expect(host.textContent).not.toContain('A touch darker in light mode')
+ mocks.S.accentCustom = '#0a84ff'
+ mount()
+ expect(host.querySelector('.swatch-note')).toBe(null)
+ })
+
+ it('ignores a value that is not a colour', () => {
+ mocks.S.accent = 'custom'; mocks.S.accentCustom = 'red;}'
+ mount()
+ expect(host.querySelector('.lrow-v').textContent).toBe('Green')
+ expect(own().classList.contains('unset')).toBe(true)
+ })
+
+ it('the settings search finds it', () => {
+ for (const q of ['custom color', 'own color', 'picker', 'hex']) {
+ expect(searchSettings(q, {}).map(h => h.title), q).toContain('Accent color')
+ }
+ })
+})
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index d30a8e36c..f0e235487 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -25,6 +25,7 @@ import { syncMedia, fetchToStore } from '../lib/media-sync.js'
import { getMediaStatus, subscribeMediaStatus, pendingRefCount } from '../lib/media-owed.js'
import { limitsFrom, fmtMB, MB } from '../lib/media-limits.js'
import { setRestAccent } from '../lib/rest-alert.js'
+import { CUSTOM, accentKey, adjustedIn, cleanHex, inkOn } from '../lib/accent.js'
import { checkForUpdate, downloadAndInstall } from '../lib/update.js'
import { forgetCoach } from '../lib/coach-api.js'
import { REST_MAX, REST_PAUSE_MIN, REST_PAUSE_MAX, fmtRest, fmtDuration } from '../lib/duration.js'
@@ -408,7 +409,7 @@ export default function Settings({ page = null, find = null, via = null }) {
plan: () => (mode === 'rotation' ? t('Rotation') : t('Fixed Week')) + ' · ' + shortWeekday(weekStartOf(S) === SUNDAY ? 0 : 1),
units: () => (S.unit || 'kg') + ' · ' + (LANGS[lang] || lang),
equipment: () => (S.equipFilterOn && activeProfile ? activeProfile.name : t('Everything')),
- look: () => themeLabel + ' · ' + t(ACCENT_NAMES[S.accent || 'lime'] || 'Green'),
+ look: () => themeLabel + ' · ' + accentLabel(S),
coach: () => (coachLocal?.mode === 'server' ? t('Your server') : coachLocal?.mode === 'byok' ? t('Your API key') : t('Off')),
data: () => '',
about: () => 'v' + __APP_VERSION__,
@@ -700,13 +701,8 @@ export default function Settings({ page = null, find = null, via = null }) {
<div className="lrow" style={{ flexWrap: 'wrap', rowGap: 12, paddingBottom: 14 }}>
<span className="lrow-i" style={{ '--tint': 'var(--purple)' }}><Icon name="palette" /></span>
<span className="lrow-m"><span className="lrow-t">{t('Accent color')}</span></span>
- <span className="lrow-v">{t(ACCENT_NAMES[S.accent || 'lime'] || 'Green')}</span>
- <div className="swatches" style={{ flexBasis: '100%', paddingInlineStart: 41 }}>
- {Object.entries(ACCENTS).map(([k, c]) => (
- <button key={k} className={'swatch' + ((S.accent || 'lime') === k ? ' on' : '')}
- style={{ background: c }} onClick={() => { update(s => { s.accent = k }); setRestAccent(k) }} aria-label={t(ACCENT_NAMES[k] || k)} />
- ))}
- </div>
+ <span className="lrow-v">{accentLabel(S)}</span>
+ <AccentSwatches S={S} update={update} />
</div>
{/* Purely how the muscle map is drawn; nothing else in the app reads this. */}
<Row icon="figureStrength" iconTint="var(--teal)" title={t('Body diagram')}>
@@ -1119,6 +1115,55 @@ function PushCard({ S, update, toast }) {
// Equipment profiles ("Home", "Gym", ...) — each an id/name/eq-list; the active one filters
// the Library, exercise picker, and flags routine entries that need something outside it
// (see lib/equipment.js). Purely local/synced state — no server changes needed.
+// What the chosen accent is called: a preset's colour name, or the user's own.
+function accentLabel(S) {
+ const k = accentKey(S)
+ return k === CUSTOM ? t('Your own color') : t(ACCENT_NAMES[k] || 'Green')
+}
+
+/**
+ * The presets, then one swatch for a colour of the user's own (lib/accent.js). With no colour
+ * of their own yet it is a rainbow ring, and a tap opens the system colour picker straight away.
+ * Once there is one it is filled with it: a tap picks it again (it is kept while a preset is
+ * chosen), and a tap on it while it is the accent opens the picker to change it. The picker is
+ * the native <input type="color"> laid over the swatch, so the tap that opens it is the user's
+ * own, which iOS Safari and the Android WebView both want.
+ */
+function AccentSwatches({ S, update }) {
+ const key = accentKey(S)
+ const own = cleanHex(S.accentCustom)
+ const onCustom = key === CUSTOM
+ const pickPreset = k => { update(s => { s.accent = k }); setRestAccent(k) }
+ const pickOwn = hex => {
+ const c = cleanHex(hex)
+ if (!c) return
+ update(s => { s.accent = CUSTOM; s.accentCustom = c })
+ setRestAccent(c)
+ }
+ const ownLabel = t('Your own color')
+ const notes = own && onCustom ? [
+ adjustedIn(own, 'dark') && t('A touch lighter in dark mode, so you can still read it.'),
+ adjustedIn(own, 'light') && t('A touch darker in light mode, so you can still read it.'),
+ ].filter(Boolean) : []
+ return <>
+ <div className="swatches" style={{ flexBasis: '100%', paddingInlineStart: 41 }}>
+ {Object.entries(ACCENTS).map(([k, c]) => (
+ <button key={k} className={'swatch' + (key === k ? ' on' : '')}
+ style={{ background: c }} onClick={() => pickPreset(k)} aria-label={t(ACCENT_NAMES[k] || k)} />
+ ))}
+ {own && !onCustom
+ ? <button className="swatch swatch-own" style={{ background: own }} onClick={() => pickOwn(own)} aria-label={ownLabel} />
+ : <span className={'swatch swatch-own' + (own ? ' on' : ' unset')} style={own ? { background: own, color: inkOn(own) } : undefined}>
+ {own ? <Icon name="pencil" /> : <Icon name="plus" />}
+ <input type="color" className="swatch-input" value={own || '#30d158'}
+ onChange={e => pickOwn(e.target.value)}
+ aria-label={own ? t('Change your own color') : t('Pick your own color')} />
+ </span>}
+ </div>
+ {notes.map(n => <span key={n} className="lrow-s swatch-note" style={{ flexBasis: '100%', paddingInlineStart: 41 }}>{n}</span>)}
+ </>
+}
+
function EquipmentCard({ S, update }) {
const profiles = S.equipProfiles || []
const remove = p => confirmSheet({
diff --git a/frontend/src/views/settings-pages.js b/frontend/src/views/settings-pages.js
index 4dca7cb49..7d6caee03 100644
--- a/frontend/src/views/settings-pages.js
+++ b/frontend/src/views/settings-pages.js
@@ -100,7 +100,7 @@ export const SEARCH = [
{ page: 'equipment', title: 'Add equipment profile', icon: 'plusCircle', tint: 'var(--green)', kw: 'equipment profile home gym hotel' },
// Look & Home
{ page: 'look', title: 'Theme', icon: 'moon', tint: 'var(--indigo)', kw: 'dark mode light mode theme appearance night', opts: ['Dark', 'Light', 'System'] },
- { page: 'look', title: 'Accent color', icon: 'palette', tint: 'var(--purple)', kw: 'color colour accent tint', opts: Object.values(ACCENT_NAMES) },
+ { page: 'look', title: 'Accent color', icon: 'palette', tint: 'var(--purple)', kw: 'color colour accent tint custom own picker hex rgb', opts: [...Object.values(ACCENT_NAMES), 'Your own color'], tkw: () => t('custom color picker') },
{ page: 'look', title: 'Body diagram', icon: 'figureStrength', tint: 'var(--teal)', kw: 'muscle map body male female', opts: ['Male', 'Female'] },
{ page: 'look', title: 'Gym check-in', icon: 'qr', tint: 'var(--blue)', kw: 'qr code membership card check in barcode' },
{ page: 'look', title: 'Body weight', icon: 'scale', tint: 'var(--green)', kw: 'weight card home' },