diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index c9d70aa..9a49fad 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -26,6 +26,7 @@ import Workout from './views/Workout.jsx' import Stats from './views/Stats.jsx' import History from './views/History.jsx' import Library from './views/Library.jsx' +import Muscles from './views/Muscles.jsx' import Settings from './views/Settings.jsx' import Admin from './views/Admin.jsx' import CoachChat from './views/CoachChat.jsx' @@ -123,6 +124,7 @@ function Shell() { } /> } /> } /> + } /> } /> {/* The Coach screens gate themselves on the instance config; the routes exist unconditionally so a deep link from a notification lands somewhere sane diff --git a/frontend/src/components/MuscleExplorer.jsx b/frontend/src/components/MuscleExplorer.jsx new file mode 100644 index 0000000..d796a3b --- /dev/null +++ b/frontend/src/components/MuscleExplorer.jsx @@ -0,0 +1,82 @@ +import { useMemo, useState } from 'react' +import { useStore } from '../store/useStore.js' +import { BODYPARTS, allExercises, equipmentOf, matchExercise } from '../lib/exercises.js' +import { bestWeightFor } from '../lib/history.js' +import { fmtNum } from '../lib/format.js' +import { MUSCLES, MUSCLE_NAME, musclesOf } from '../lib/muscles.js' +import { t, exerciseNameFor } from '../lib/i18n.js' +import BodyMap from './BodyMap.jsx' +import { Thumb } from './Media.jsx' +import Icon from './Icon.jsx' +import { Button } from './ui.jsx' +import { tappable } from '../lib/use-sheet-keyboard.js' + +// One explorer for the Library and every catalogue picker. Supplying `onPick` turns +// a result into a selection; without it the explorer behaves like the normal Library. +export default function MuscleExplorer({ onPick, onDetail, onPlan }) { + const S = useStore(s => s.S) + const [selected, setSelected] = useState(null) + const [q, setQ] = useState('') + const [bp, setBp] = useState('') + const [eq, setEq] = useState('') + const [shown, setShown] = useState(40) + const catalog = useMemo(() => allExercises(S), [S.customEx]) + const counts = useMemo(() => Object.fromEntries(MUSCLES.map(m => [m, + catalog.filter(e => musclesOf(e)[m]).length + ])), [catalog]) + const pick = muscle => { setSelected(muscle === selected ? null : muscle); setEq(''); setShown(40) } + const targeted = selected ? catalog.filter(e => musclesOf(e)[selected]) : [] + const base = targeted.filter(e => (!bp || e.bp === bp) && matchExercise(e, q)) + const eqOpts = equipmentOf(base) + const eqOn = eqOpts.includes(eq) ? eq : '' + const exercises = eqOn ? base.filter(e => e.eq === eqOn) : base + const choose = ex => onPick ? onPick(ex) : onDetail(ex) + + return <> +
+ +
+ {MUSCLES.map(m => )} +
+
+ + {!selected &&
{t('Choose a muscle to see exercises that train it.')}
} + + {selected && <> +
+

{t('Exercises for {0}', t(MUSCLE_NAME[selected]))}

+ +
+
+ { setQ(e.target.value); setShown(40) }} /> +
+
1 ? 8 : 12 }}> + + {BODYPARTS.map(b => )} +
+ {eqOpts.length > 1 &&
+ + {eqOpts.map(x => )} +
} +
+ {exercises.slice(0, shown).map(e => { + const best = bestWeightFor(S, e.id) + const primary = musclesOf(e)[selected] === 1 + return
choose(e))}> + +
{exerciseNameFor(e)}
{t(primary ? 'Primary target' : 'Also trains')} · {t(e.tg || e.bp)} · {t(e.eq)}
+ {onPick ? : <> + {best > 0 && {fmtNum(best)}} + + } +
+ })} + {exercises.length === 0 &&
{t('No match')}
} +
+ {exercises.length > shown && <>
} + } + +} diff --git a/frontend/src/index.css b/frontend/src/index.css index 9963d97..cae7c55 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -438,6 +438,7 @@ h4.sec{ } .chip:active{background:var(--surface-2)} .chip.on{background:var(--acc);color:var(--on-acc);font-weight:500} +.chip.on .dim{color:color-mix(in srgb,var(--on-acc) 62%,transparent)} /* =========================== CONTROLS ==================================== */ diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 2e75329..53a938a 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => { .sort(byCodeUnit) const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') - expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(603) + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(610) expect(inherited).toHaveLength(565) // If this fails, review the changed keys and wording before accepting a new hash. From // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index 2874b21..3e8cb9f 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -24,6 +24,13 @@ export default { 'Resume': 'Weiter', 'Stats': 'Statistik', 'Exercises': 'Übungen', + 'By muscle': 'Nach Muskel', + 'Explore muscles': 'Muskeln entdecken', + 'Choose a muscle to see exercises that train it.': 'Wähle einen Muskel, um Übungen zu sehen, die ihn trainieren.', + 'Exercises for {0}': 'Übungen für {0}', + 'Clear selection': 'Auswahl aufheben', + 'Primary target': 'Hauptmuskel', + 'Also trains': 'Trainiert auch', 'History': 'Verlauf', 'Settings': 'Einstellungen', 'Freestyle': 'Freies Training', diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index 0c4f8f0..16d3352 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Seguir', 'Stats': 'Progreso', 'Exercises': 'Ejercicios', + 'By muscle': 'Por músculo', + 'Explore muscles': 'Explorar músculos', + 'Choose a muscle to see exercises that train it.': 'Elige un músculo para ver los ejercicios que lo entrenan.', + 'Exercises for {0}': 'Ejercicios para {0}', + 'Clear selection': 'Borrar selección', + 'Primary target': 'Músculo principal', + 'Also trains': 'También trabaja', 'History': 'Historial', 'Settings': 'Ajustes', 'Freestyle': 'Libre', diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 49dd9db..2e6b4f3 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Reprendre', 'Stats': 'Stats', 'Exercises': 'Exercices', + 'By muscle': 'Par muscle', + 'Explore muscles': 'Explorer les muscles', + 'Choose a muscle to see exercises that train it.': 'Choisissez un muscle pour voir les exercices qui le sollicitent.', + 'Exercises for {0}': 'Exercices pour {0}', + 'Clear selection': 'Effacer la sélection', + 'Primary target': 'Cible principale', + 'Also trains': 'Sollicite aussi', 'History': 'Historique', 'Settings': 'Réglages', 'Freestyle': 'Libre', diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index ea3cc2d..7207eec 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -23,6 +23,13 @@ export default { 'Resume': 'जारी रखें', 'Stats': 'आँकड़े', 'Exercises': 'व्यायाम', + 'By muscle': 'मांसपेशी से', + 'Explore muscles': 'मांसपेशियाँ खोजें', + 'Choose a muscle to see exercises that train it.': 'उस मांसपेशी को प्रशिक्षित करने वाले व्यायाम देखने के लिए एक मांसपेशी चुनें।', + 'Exercises for {0}': '{0} के लिए व्यायाम', + 'Clear selection': 'चयन साफ़ करें', + 'Primary target': 'मुख्य लक्ष्य', + 'Also trains': 'यह भी प्रशिक्षित करता है', 'History': 'इतिहास', 'Settings': 'सेटिंग्स', 'Freestyle': 'फ्रीस्टाइल', diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index 7db3376..ed08bfe 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -25,6 +25,13 @@ export default { 'Resume': 'Folytatás', 'Stats': 'Statisztika', 'Exercises': 'Gyakorlatok', + 'By muscle': 'Izom szerint', + 'Explore muscles': 'Izmok felfedezése', + 'Choose a muscle to see exercises that train it.': 'Válassz izmot, hogy lásd a gyakorlatokat, amelyek edzik.', + 'Exercises for {0}': '{0} gyakorlatai', + 'Clear selection': 'Kijelölés törlése', + 'Primary target': 'Elsődleges célizom', + 'Also trains': 'Emellett edzi', 'History': 'Előzmények', 'Settings': 'Beállítások', 'Freestyle': 'Szabad edzés', diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index ea66bc5..c1f25aa 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Riprendi', 'Stats': 'Statistiche', 'Exercises': 'Esercizi', + 'By muscle': 'Per muscolo', + 'Explore muscles': 'Esplora i muscoli', + 'Choose a muscle to see exercises that train it.': 'Scegli un muscolo per vedere gli esercizi che lo allenano.', + 'Exercises for {0}': 'Esercizi per {0}', + 'Clear selection': 'Cancella selezione', + 'Primary target': 'Muscolo principale', + 'Also trains': 'Allena anche', 'History': 'Cronologia', 'Settings': 'Impostazioni', 'Freestyle': 'Libero', diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index a1834b0..cdacbea 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -23,6 +23,13 @@ export default { 'Resume': '이어하기', 'Stats': '통계', 'Exercises': '운동', + 'By muscle': '근육별', + 'Explore muscles': '근육 탐색', + 'Choose a muscle to see exercises that train it.': '운동하는 부위를 선택해 해당 근육을 훈련하는 운동을 확인하세요.', + 'Exercises for {0}': '{0} 운동', + 'Clear selection': '선택 지우기', + 'Primary target': '주요 목표', + 'Also trains': '함께 훈련', 'History': '기록', 'Settings': '설정', 'Freestyle': '자유 운동', diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index 1fd55c0..20d0dc7 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Wznów', 'Stats': 'Statystyki', 'Exercises': 'Ćwiczenia', + 'By muscle': 'Według mięśnia', + 'Explore muscles': 'Poznaj mięśnie', + 'Choose a muscle to see exercises that train it.': 'Wybierz mięsień, aby zobaczyć ćwiczenia, które go angażują.', + 'Exercises for {0}': 'Ćwiczenia na {0}', + 'Clear selection': 'Wyczyść wybór', + 'Primary target': 'Główny cel', + 'Also trains': 'Angażuje również', 'History': 'Historia', 'Settings': 'Ustawienia', 'Freestyle': 'Dowolny', diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index a6060bd..84e058f 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -627,6 +627,15 @@ export const PT_BR_OVERRIDES = { 'Point the camera at the QR code': 'Aponte a câmera para o código QR', 'Camera is not available here — import a photo or type the code instead.': 'A câmera não está disponível aqui — importe uma foto ou digite o código.', 'Camera access was denied — allow it in your browser and try again.': 'O acesso à câmera foi negado — permita-o no navegador e tente de novo.', + +// --- muscle explorer --- + 'By muscle': 'Por músculo', + 'Explore muscles': 'Explorar músculos', + 'Choose a muscle to see exercises that train it.': 'Escolha um músculo para ver os exercícios que o treinam.', + 'Exercises for {0}': 'Exercícios para {0}', + 'Clear selection': 'Limpar seleção', + 'Primary target': 'Músculo principal', + 'Also trains': 'Também trabalha', } export default { ...pt, ...PT_BR_OVERRIDES } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 7336910..a63f558 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Retomar', 'Stats': 'Estatísticas', 'Exercises': 'Exercícios', + 'By muscle': 'Por músculo', + 'Explore muscles': 'Explorar músculos', + 'Choose a muscle to see exercises that train it.': 'Escolha um músculo para ver os exercícios que o treinam.', + 'Exercises for {0}': 'Exercícios para {0}', + 'Clear selection': 'Limpar seleção', + 'Primary target': 'Alvo principal', + 'Also trains': 'Também trabalha', 'History': 'Histórico', 'Settings': 'Definições', 'Freestyle': 'Livre', diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index f296cae..aa9de8c 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Продолжить', 'Stats': 'Статистика', 'Exercises': 'Упражнения', + 'By muscle': 'По мышцам', + 'Explore muscles': 'Изучить мышцы', + 'Choose a muscle to see exercises that train it.': 'Выберите мышцу, чтобы увидеть упражнения, которые её тренируют.', + 'Exercises for {0}': 'Упражнения для {0}', + 'Clear selection': 'Очистить выбор', + 'Primary target': 'Основная мышца', + 'Also trains': 'Также тренирует', 'History': 'История', 'Settings': 'Настройки', 'Freestyle': 'Свободная', diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index 7ad3a61..2ef2469 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -25,6 +25,13 @@ export default { 'Resume': 'เล่นต่อ', 'Stats': 'สถิติ', 'Exercises': 'ท่าออกกำลังกาย', + 'By muscle': 'ตามกล้ามเนื้อ', + 'Explore muscles': 'สำรวจกล้ามเนื้อ', + 'Choose a muscle to see exercises that train it.': 'เลือกกล้ามเนื้อเพื่อดูท่าออกกำลังกายที่ฝึกกล้ามเนื้อนั้น', + 'Exercises for {0}': 'ท่าออกกำลังกายสำหรับ {0}', + 'Clear selection': 'ล้างการเลือก', + 'Primary target': 'กล้ามเนื้อหลัก', + 'Also trains': 'ฝึกกล้ามเนื้อนี้ด้วย', 'History': 'ประวัติ', 'Settings': 'ตั้งค่า', 'Freestyle': 'ฟรีสไตล์', diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 225edf1..eb97cfe 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -23,6 +23,13 @@ export default { 'Resume': 'Devam et', 'Stats': 'İstatistik', 'Exercises': 'Egzersizler', + 'By muscle': 'Kasa göre', + 'Explore muscles': 'Kasları keşfet', + 'Choose a muscle to see exercises that train it.': 'Çalıştıran egzersizleri görmek için bir kas seçin.', + 'Exercises for {0}': '{0} için egzersizler', + 'Clear selection': 'Seçimi temizle', + 'Primary target': 'Ana hedef', + 'Also trains': 'Ayrıca çalıştırır', 'History': 'Geçmiş', 'Settings': 'Ayarlar', 'Freestyle': 'Serbest', diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 4571116..084a7cd 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -23,6 +23,13 @@ export default { 'Resume': '继续', 'Stats': '统计', 'Exercises': '动作库', + 'By muscle': '按肌肉', + 'Explore muscles': '探索肌肉', + 'Choose a muscle to see exercises that train it.': '选择一块肌肉以查看训练它的动作。', + 'Exercises for {0}': '{0} 训练动作', + 'Clear selection': '清除选择', + 'Primary target': '主要目标', + 'Also trains': '同时训练', 'History': '历史', 'Settings': '设置', 'Freestyle': '自由训练', diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 8ccba30..fa846be 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -16,6 +16,7 @@ import Icon from './components/Icon.jsx' import { Button, Slider, Switch, Segmented, SelectRow, Row, TextField, MultiSelectRow } from './components/ui.jsx' import { glyphOf, GLYPH_GROUPS, DEFAULT_GLYPH } from './lib/glyphs.js' import BodyMap from './components/BodyMap.jsx' +import MuscleExplorer from './components/MuscleExplorer.jsx' import { exerciseMuscleSnapshot, loadOfWorkouts, MUSCLES, MUSCLE_NAME, normalizeMuscleGroups, hasExplicitMuscleMetadata } from './lib/muscles.js' import { parseImport, mergeImport } from './lib/import-csv.js' import { importHevyData, HevyApiError, HEVY_DEV_SETTINGS, mergeHevyRoutines } from './lib/import-hevy.js' @@ -712,6 +713,7 @@ function ExercisePicker({ onPick, close }) { const [eq, setEq] = useState('') // '' = any equipment const [showAll, setShowAll] = useState(false) const [shown, setShown] = useState(50) + const [byMuscle, setByMuscle] = useState(false) const searchRef = useRef(null) const bpStrip = useRef(null), eqStrip = useRef(null) const onSearchFocus = useSheetKeyboard(searchRef) @@ -729,8 +731,17 @@ function ExercisePicker({ onPick, close }) { const chosenCount = Object.keys(usage).length useRevealActiveChip(bpStrip, bp) useRevealActiveChip(eqStrip, eqOn) + if (byMuscle) return <> +

{t('Add exercise')}

+ +
+ + + return <> -

{t('Add exercise')}

+

{t('Add exercise')}

+ +
{/* .picker-search is what index.css keys the keyboard-aware sheet layout on: the sheet lifts above the keys and the search stays put while the list scrolls under it. */}
diff --git a/frontend/src/views/Library.jsx b/frontend/src/views/Library.jsx index 5822a78..b591abb 100644 --- a/frontend/src/views/Library.jsx +++ b/frontend/src/views/Library.jsx @@ -1,4 +1,5 @@ import { useRef, useState } from 'react' +import { useNavigate } from 'react-router-dom' import { useStore } from '../store/useStore.js' import { EXDB, BODYPARTS, allExercises, equipmentOf, matchExercise } from '../lib/exercises.js' import { activeProfile, exAvailable } from '../lib/equipment.js' @@ -12,6 +13,7 @@ import { Button } from '../components/ui.jsx' import { tappable, useRevealActiveChip } from '../lib/use-sheet-keyboard.js' export default function Library() { + const nav = useNavigate() const S = useStore(s => s.S) const [q, setQ] = useState('') const [bp, setBp] = useState('') @@ -30,7 +32,9 @@ export default function Library() { useRevealActiveChip(eqStrip, eqOn) return <> -

{t('Exercises')}

{t('{0} exercises with animations', EXDB.length)}
+

{t('Exercises')}

{t('{0} exercises with animations', EXDB.length)}
+ +
{ setQ(e.target.value); setShown(40) }} />
{profile &&
diff --git a/frontend/src/views/Muscles.jsx b/frontend/src/views/Muscles.jsx new file mode 100644 index 0000000..330a489 --- /dev/null +++ b/frontend/src/views/Muscles.jsx @@ -0,0 +1,17 @@ +import { useNavigate } from 'react-router-dom' +import { t } from '../lib/i18n.js' +import MuscleExplorer from '../components/MuscleExplorer.jsx' +import { exerciseDetailSheet, addToRoutineSheet } from '../sheets.jsx' +import Icon from '../components/Icon.jsx' + +export default function Muscles() { + const nav = useNavigate() + return <> +
+

{t('Explore muscles')}

{t('Choose a muscle to see exercises that train it.')}
+ +
+ + + +}