diff --git a/CHANGELOG.md b/CHANGELOG.md index f84aa45..d1ab267 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,42 @@ # Changelog +## v1.2.0 โ€” 2026-07-23 + +A complete visual redesign. Same app, same data โ€” every screen redrawn. + +### A designed interface, not an assembled one + +- ๐ŸŽจ **Rebuilt design system.** One type scale carrying hierarchy through size instead of making + everything bold, a neutral surface ramp instead of saturated blue-greys, hairline separators + instead of outlined boxes, and motion that acknowledges a press rather than animating for + decoration. Light and dark are both first-class, and the eight accent colours now pick their + label colour by measured contrast โ€” the default green in light mode was failing WCAG AA on + every primary button before. +- โœ๏ธ **A hand-drawn icon set** (77 icons, single stroke weight, drawn on one 24ร—24 grid) replaces + every emoji in the interface. Emoji render differently on each platform, sit on their own + baseline and can't take a theme colour, which is what made the old UI feel stitched together. + Icons inherit the surrounding text colour and optical size. +- ๐Ÿ‹๏ธ **Routine icons.** Picking an icon for a routine now offers a grouped set โ€” strength, + equipment, cardio, recovery โ€” instead of an emoji keyboard. Routines you already made keep + their look: the old emoji are mapped forward automatically, so nothing to migrate and nothing + to redo. +- โ–ถ๏ธ **New tab bar** with a raised Start button that turns into a pulsing orange Resume while a + workout is running. +- ๐Ÿ  **Home reads as a plan for today** โ€” week strip, today's session as one tappable row, body + weight, and your streak. + +### Charts + +- ๐Ÿ“ˆ **Axis labels, gridlines and the target-weight line are visible again** in dark mode. They + were painted with colour variables that no longer existed, which silently fell back to black + on black โ€” and to no stroke at all for the lines. +- ๐Ÿ’ฌ **The hover readout stays on screen.** It used to be positioned with a fixed offset that + assumed one label width, so the first and last point pushed it under the chart's clip; it's now + placed from its measured size and kept inside the frame, dropping below the point when the + point sits high enough that the label would cover the value it reports. +- ๐Ÿ–ฑ๏ธ **It also goes away again** โ€” moving off the chart now clears the readout, crosshair and + marker, which previously stayed until you hovered somewhere else. + ## v1.1.3 โ€” 2026-07-22 Admin dashboard for self-hosters (opt-in โ€” off by default), equipment filtering, and diff --git a/frontend/package.json b/frontend/package.json index 2517c82..c28caf7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "opengym-frontend", "private": true, - "version": "1.1.3", + "version": "1.2.0", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index b1c0646..ae9e303 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,10 +1,13 @@ import { useEffect } from 'react' import { HashRouter, Routes, Route, Navigate, useNavigate, useLocation } from 'react-router-dom' import { useStore } from './store/useStore.js' +import { useUI } from './store/useUI.js' +import { bindUI } from './components/ui.jsx' import { ACCENTS } from './lib/format.js' import { setLang, useLang } from './lib/i18n.js' import { setNav } from './lib/nav.js' import { startFlow } from './sheets.jsx' +import Icon from './components/Icon.jsx' import TabBar from './components/TabBar.jsx' import Modals from './components/Modals.jsx' import Toast from './components/Toast.jsx' @@ -20,12 +23,14 @@ import Library from './views/Library.jsx' import Settings from './views/Settings.jsx' import Admin from './views/Admin.jsx' +bindUI(useUI) // lets the shared controls open sheets without importing the store at module scope + function applyPrefs(theme, accent) { const de = document.documentElement de.dataset.theme = theme === 'light' ? 'light' : 'dark' de.dataset.accent = ACCENTS[accent] ? accent : 'lime' const meta = document.querySelector('meta[name="theme-color"]') - if (meta) meta.content = de.dataset.theme === 'light' ? '#f2f4f7' : '#0c0e12' + if (meta) meta.content = de.dataset.theme === 'light' ? '#f2f2f7' : '#000000' } function Shell() { @@ -42,7 +47,13 @@ function Shell() { useEffect(() => { window.scrollTo(0, 0) }, [loc.pathname]) const authed = user || isGuest - if (!ready && !authed) return
๐Ÿ‹๏ธ
+ if (!ready && !authed) return ( +
+
+ +
+
+ ) return ( <> diff --git a/frontend/src/components/Icon.jsx b/frontend/src/components/Icon.jsx new file mode 100644 index 0000000..b3d8395 --- /dev/null +++ b/frontend/src/components/Icon.jsx @@ -0,0 +1,142 @@ +// openGym icon set โ€” hand-drawn on a 24ร—24 grid, stroke-based, single weight. +// +// Everything is one primitive with `currentColor`, so an icon inherits the +// text colour and optical size of whatever it sits in. No emoji anywhere in the +// chrome: emoji render differently on every platform, sit on their own baseline +// and can't take a theme colour, which is what made the old UI feel assembled +// rather than designed. +// +// Conventions, so a new icon never looks foreign next to an old one: +// ยท 24ร—24 viewBox, live area 3โ€ฆ21 โ€” 3px of optical padding all round +// ยท strokes only (no fills) except where a shape reads better solid (star.fill) +// ยท round caps + round joins, stroke width from --icon-stroke (1.7 default) +// ยท geometry snapped to .5 so it lands on pixel edges at 24px + +const P = { + /* ---- navigation ---- */ + house: , + calendar: <>, + chart: , + magnifier: <>, + // A real cog outline (8 teeth, generated on a circle) โ€” an earlier version drew + // radial rays and was indistinguishable from `sun` at tab-bar size. + gear: <>, + + /* ---- training ---- */ + dumbbell: <>, + barbell: , + figureRun: <>, + figureStrength: <>, + scale: <>, + flame: , + timer: <>, + clock: <>, + + /* ---- status / achievement ---- */ + trophy: <>, + medal: <>, + target: <>, + star: , + starFill: , + crown: , + bolt: , + shield: , + heart: , + rocket: <>, + sparkles: <>, + lightbulb: <>, + + /* ---- routine glyphs: what a training day actually is ---- */ + // Named after the split or the kit, because that's how people name routines + // ("Push Day", "Leg Day", "Kettlebell") โ€” an award icon says nothing about it. + arm: <>, + abs: <>, + legs: <>, + pullup: <>, + kettlebell: <>, + plate: <>, + machine: <>, + bike: <>, + swim: <>, + boxing: <>, + stretch: <>, + + /* ---- actions ---- */ + plus: , + minus: , + check: , + checkCircle: <>, + xmark: , + pencil: <>, + trash: <>, + link: <>, + play: , + pause: , + reset: <>, + bell: <>, + bellSlash: <>, + chevronRight: , + chevronLeft: , + chevronDown: , + chevronUp: , + arrowUp: , + arrowDown: , + expand: , + minimize: , + + /* ---- objects ---- */ + person: <>, + personCircle: <>, + clipboard: <>, + list: , + folder: , + globe: <>, + moon: , + sun: <>, + key: <>, + lock: <>, + download: , + upload: , + wrench: , + // checkered, not a pennant โ€” this marks "finish workout", and a 2ร—2 grid is + // what reads as a finish line at 16px + flag: <>, + chartLine: , + dot: , + history: <>, + signOut: <>, + shuffle: <>, + info: <>, +} + +// A few keys are aliases so call sites can say what they mean. +P.search = P.magnifier +P.settings = P.gear +P.exercises = P.magnifier +P.weight = P.scale +P.streak = P.flame +P.done = P.check + +export const ICON_NAMES = Object.keys(P) + +/** + * โ€” inherits font-size via `1em` sizing + * โ€” explicit pixel size + */ +export default function Icon({ name, size, className = '', style, ...rest }) { + const d = P[name] + if (!d) return null + const s = size ? { width: size, height: size } : null + return ( + + ) +} diff --git a/frontend/src/components/LineChart.jsx b/frontend/src/components/LineChart.jsx index 6b30df9..8f9302e 100644 --- a/frontend/src/components/LineChart.jsx +++ b/frontend/src/components/LineChart.jsx @@ -1,14 +1,37 @@ -import { useRef, useState } from 'react' +import { useLayoutEffect, useRef, useState } from 'react' import { fmtNum, fmtDate, MONTHS, isoOf } from '../lib/format.js' import { t } from '../lib/i18n.js' +const W = 340 // viewBox width; the svg stretches to its container, height comes from `h` + // points: [{ t: ms, y: num, d?: iso }] sorted by t. opts: { h, unit, color, axes, goal } export default function LineChart({ points, h = 150, unit = '', color = 'var(--acc)', axes = true, goal = null }) { const svgRef = useRef(null) + const wrapRef = useRef(null) + const tipRef = useRef(null) const [hover, setHover] = useState(null) // { x, y, iso, v } + // The tooltip is placed after layout, from its measured size, because the chart + // lives in an overflow-clipped box: a fixed half-width offset (what this used to + // do) hangs the label off the edge on the first and last point, and the clip then + // eats it. Reading offsetWidth here also covers translated labels, which are not + // all the same length. Writing straight to the node's style keeps this off the + // render path โ€” hover fires on every mouse move. + useLayoutEffect(() => { + const tip = tipRef.current, wrap = wrapRef.current + if (!hover || !tip || !wrap) return + const cw = wrap.clientWidth, ch = wrap.clientHeight + const tw = tip.offsetWidth, th = tip.offsetHeight + const M = 4 // breathing room against the clip + const cx = hover.x / W * cw, cy = hover.y / h * ch + tip.style.left = Math.max(M, Math.min(cw - tw - M, cx - tw / 2)) + 'px' + // Parked at the top, but dropped below the point when the point sits high + // enough that the label would cover the very value it is reporting. + tip.style.top = (cy < th + 14 ? Math.min(ch - th - M, cy + 14) : M) + 'px' + }) + if (!points || points.length === 0) return
{t('No data yet')}
- const W = 340, H = h + const H = h const P = { l: axes ? 34 : 8, r: 12, t: 10, b: axes ? 22 : 8 } const single = points.length === 1 const pts = single ? [points[0], points[0]] : points @@ -30,8 +53,8 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--a for (let v = Math.ceil(ymin / step) * step; v <= ymax + 1e-9; v += step) { const y = Y(v) gridlines.push( - - {fmtNum(v)} + + {fmtNum(v)} ) } const d0 = new Date(t0), d1 = new Date(t1) @@ -49,8 +72,8 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--a if (i % every) return const x = X(tk.t) gridlines.push( - - {tk.txt} + + {tk.txt} ) }) } @@ -72,8 +95,9 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--a } return ( -
setHover(null)} onTouchStart={onMove} onTouchMove={onMove}> @@ -82,19 +106,19 @@ export default function LineChart({ points, h = 150, unit = '', color = 'var(--a {gridlines} {goal != null && isFinite(goal) && <> - - ๐ŸŽฏ {fmtNum(goal)} + + {fmtNum(goal)} } {hover && - - + + } - {hover &&
+ {hover &&
{fmtDate(hover.iso, true)} ยท {fmtNum(hover.v)}{unit ? ' ' + unit : ''}
}
diff --git a/frontend/src/components/Media.jsx b/frontend/src/components/Media.jsx index 26456d8..57d6783 100644 --- a/frontend/src/components/Media.jsx +++ b/frontend/src/components/Media.jsx @@ -2,6 +2,7 @@ import { useState } from 'react' import { imgSrc, gifSrc } from '../lib/exercises.js' import { useStore } from '../store/useStore.js' import { t } from '../lib/i18n.js' +import Icon from './Icon.jsx' // Big autoplaying animation; tap toggles to the still frame. `compact` shrinks it (superset cards). // Custom exercises have no media โ€” the animation stays blank by design (issue #11). @@ -18,13 +19,21 @@ export default function Media({ ex, id, compact, minimizable }) { return (
setPlaying(p => !p)}> {ex.n} - {minimizable && } - {!mini && {playing ? 'โธ ' + t('tap to pause') : 'โ–ถ ' + t('tap to play')}} + {minimizable && ( + + )} + {!mini && ( + + {playing ? t('tap to pause') : t('tap to play')} + + )}
) } export function Thumb({ ex }) { - if (!ex.img) return
๐Ÿ‹๏ธ
+ if (!ex.img) return
return } diff --git a/frontend/src/components/NumField.jsx b/frontend/src/components/NumField.jsx index 6bdd63d..5add9d9 100644 --- a/frontend/src/components/NumField.jsx +++ b/frontend/src/components/NumField.jsx @@ -1,31 +1,3 @@ -import { useRef, useState } from 'react' - -// Numeric input that accepts "," as decimal separator โ€” iOS decimal keypads in many -// locales only offer a comma, and type="number" reports "" for it (value snaps to 0). -// Keeps a local string draft while focused so partial input like "33," survives typing. -export default function NumField({ value, onChange, decimal = true, ...rest }) { - const [draft, setDraft] = useState(null) - const committed = useRef(null) - // external change (e.g. โˆ’/+ buttons) while a draft is showing โ†’ drop the draft - if (draft !== null && committed.current !== value) { setDraft(null); committed.current = null } - const commit = raw => { - let s = raw.replace(/,/g, '.').replace(/[^0-9.]/g, '') - const i = s.indexOf('.') - if (i !== -1) s = decimal ? s.slice(0, i + 1) + s.slice(i + 1).replace(/\./g, '') : s.slice(0, i) - const n = s === '' || s === '.' ? 0 : Math.max(0, parseFloat(s)) - committed.current = n - setDraft(s) - onChange(n) - } - return ( - e.target.select()} - onChange={e => commit(e.target.value)} - onBlur={() => { setDraft(null); committed.current = null }} - {...rest} - /> - ) -} +// Kept as a module so existing imports keep working โ€” the implementation now +// lives in the shared control set. +export { NumberField as default } from './ui.jsx' diff --git a/frontend/src/components/RestTimer.jsx b/frontend/src/components/RestTimer.jsx index dae9e59..3c315f8 100644 --- a/frontend/src/components/RestTimer.jsx +++ b/frontend/src/components/RestTimer.jsx @@ -1,5 +1,7 @@ import { useUI } from '../store/useUI.js' import { t } from '../lib/i18n.js' +import { Button } from './ui.jsx' + export default function RestTimer() { const timer = useUI(s => s.timer) const { addRest, stopRest } = useUI() @@ -10,8 +12,8 @@ export default function RestTimer() {
{m}:{s}
- - + +
) } diff --git a/frontend/src/components/Stepper.jsx b/frontend/src/components/Stepper.jsx index 2801f82..a86c0ea 100644 --- a/frontend/src/components/Stepper.jsx +++ b/frontend/src/components/Stepper.jsx @@ -1,20 +1,3 @@ -import NumField from './NumField.jsx' - -// Number field with โˆ’/+ buttons; tapping the field selects its content so typing replaces. -export default function Stepper({ value, step = 1, onChange, decimal = true, className = '', label }) { - const set = v => onChange(Math.max(0, Math.round((v || 0) * 100) / 100)) - const inner = ( -
- - - -
- ) - if (!label) return inner - return ( -
-
{label}
- {inner} -
- ) -} +// Kept as a module so existing imports keep working โ€” the implementation now +// lives in the shared control set. +export { Stepper as default } from './ui.jsx' diff --git a/frontend/src/components/TabBar.jsx b/frontend/src/components/TabBar.jsx index dbeb0c9..156d4d7 100644 --- a/frontend/src/components/TabBar.jsx +++ b/frontend/src/components/TabBar.jsx @@ -3,13 +3,7 @@ import { useStore } from '../store/useStore.js' import { effectiveRoutine } from '../lib/history.js' import { todayISO } from '../lib/format.js' import { t } from '../lib/i18n.js' - -const ICONS = { - home: , - plan: <>, - stats: , - library: <> -} +import Icon from './Icon.jsx' export default function TabBar({ onStart }) { const nav = useNavigate() @@ -28,18 +22,22 @@ export default function TabBar({ onStart }) { } nav('/workout') } - const Icon = ({ k }) => {ICONS[k]} + const Tab = ({ k, icon, to, label }) => ( + + ) return ( ) } diff --git a/frontend/src/components/ui.jsx b/frontend/src/components/ui.jsx new file mode 100644 index 0000000..0cd6404 --- /dev/null +++ b/frontend/src/components/ui.jsx @@ -0,0 +1,293 @@ +// openGym control set. +// +// Every input in the app is built here rather than styled on top of a native +// widget. Native controls are the single loudest "unfinished" tell: a checkbox +// renders blue on iOS and grey on Android, a range slider paints its own white +// track that no theme reaches, and a e.target.select()} + onChange={e => commit(e.target.value)} + onBlur={() => { setDraft(null); committed.current = null }} + {...rest} + /> + ) +} + +// forwardRef so callers can focus it or read its value imperatively +export const TextField = forwardRef(function TextField({ className = '', ...rest }, ref) { + return +}) + +export function TextArea({ className = '', ...rest }) { + return