diff --git a/app/app.js b/app/app.js index e53966d..eb7368c 100644 --- a/app/app.js +++ b/app/app.js @@ -13,6 +13,7 @@ const BODYPARTS = [...new Set(EXDB.map(e => e.bp))].sort(); const KEY = 'gym_state_v1'; const DEF = { unit: 'kg', restSec: 90, sound: true, + theme: 'dark', accent: 'lime', // appearance β€” synced with the profile bodyweight: [], // {d:'YYYY-MM-DD', w:Number, t:ms} routines: [], // {id, name, emoji, ex:[{id, sets, reps, weight}]} week: {}, // weekday(0-6, JS getDay) -> routineId @@ -485,7 +486,15 @@ function bindCharts(root) { ============================================================ */ let elapsedInt = null; function nav(hash) { location.hash = hash; } -function route() { renderView(); updateTabbar(); } +const ACCENTS = { lime: '#a3e635', sky: '#38bdf8', orange: '#fb923c', violet: '#a78bfa', pink: '#f472b6', red: '#f87171', teal: '#2dd4bf', gold: '#fbbf24' }; +function applyPrefs() { + const de = document.documentElement; + de.dataset.theme = S.theme === 'light' ? 'light' : 'dark'; + de.dataset.accent = ACCENTS[S.accent] ? S.accent : 'lime'; + const meta = document.querySelector('meta[name="theme-color"]'); + if (meta) meta.content = de.dataset.theme === 'light' ? '#f2f4f7' : '#0c0e12'; +} +function route() { applyPrefs(); renderView(); updateTabbar(); } function renderView() { const h = (location.hash || '#home').slice(1); // re-rendering the same view (range chips, toggles, …) keeps the scroll position; @@ -535,7 +544,7 @@ function updateTabbar() { ============================================================ */ function viewLogin(app) { app.innerHTML = ` -
+
πŸ‹οΈ

GymLog

Your workouts. Your weights. Your profile.
@@ -647,6 +656,7 @@ function viewHome(app) {
Tap a day to plan or move a session
+
${S.active ? `

Workout in progress

@@ -691,6 +701,7 @@ function viewHome(app) {
${bwSpark}
` : `
No entries yet β€” log your weight to start the curve. It's also asked automatically before every workout.
`}
+
This week
${wThisWeek}${plannedPerWeek ? ' / ' + plannedPerWeek : ''}
@@ -705,6 +716,7 @@ function viewHome(app) {
${[...S.workouts].reverse().slice(0, 3).map(workoutItem).join('')}
` : ''} +
`; $('#btn-settings').onclick = () => nav('#settings'); @@ -817,8 +829,10 @@ function viewPlan(app) { app.innerHTML = `

Plan

Your weekly routine
+

Week schedule

-
${dayRows}
+
${dayRows}
+

Routines

@@ -832,6 +846,7 @@ function viewPlan(app) { β€Ί
`).join('')}
` : `
πŸ“‹
No routines yet.
Create one or load the starter plan.
`} +
`; app.querySelectorAll('[data-day]').forEach(el => el.addEventListener('click', () => dayAssignSheet(+el.dataset.day))); @@ -863,6 +878,7 @@ function viewRoutineEdit(app, rid) { const r = S.routines.find(x => x.id === rid); if (!r) { nav('#plan'); return; } app.innerHTML = ` +
@@ -886,6 +902,7 @@ function viewRoutineEdit(app, rid) {
+
`; $('#btn-back').onclick = () => nav('#plan'); @@ -1043,6 +1060,7 @@ function viewWorkout(app) { const todayR = effectiveRoutine(todayISO()); const todayOvr = S.dayPlan[todayISO()] !== undefined; app.innerHTML = ` +

Start workout

${DAYN[today]} β€” ${todayR ? 'today is ' + esc(todayR.name) : 'rest day, but no one’s stopping you'}
${todayR ? `
@@ -1063,6 +1081,7 @@ function viewWorkout(app) {
${!S.routines.length ? `
` : ''} +
`; app.querySelectorAll('[data-start]').forEach(el => el.addEventListener('click', () => startFlow(el.dataset.start))); $('#btn-free').onclick = () => startFlow(null); @@ -1094,6 +1113,7 @@ function renderActive(app) { const entry = A.entries[cur]; app.innerHTML = ` +
${esc(A.name)}
@@ -1112,6 +1132,7 @@ function renderActive(app) {
+
`; // elapsed ticker @@ -1424,6 +1445,7 @@ function viewStats(app) { ${heatmapHTML()}
+

Body weight

@@ -1447,6 +1469,7 @@ function viewStats(app) {
Best set weight per workout Β· Best ever: ${fmtNum(bestWeightFor(statsEx))} ${S.unit}
` : '
Finish your first workout to see strength curves here. πŸ“ˆ
'}
+
${S.workouts.length ? `
@@ -1557,6 +1580,7 @@ function exerciseDetailSheet(ex) { ============================================================ */ function viewSettings(app) { app.innerHTML = ` +

Settings

@@ -1574,6 +1598,23 @@ function viewSettings(app) { ` : '
Passkeys not supported in this browser.
'}`}
+
+

Appearance Β· synced with your profile

+
+ Theme +
+ + +
+
+
+
Accent color
+
${Object.entries(ACCENTS).map(([k, c]) => + ``).join('')} +
+
+
+

Units & timer

@@ -1611,6 +1652,7 @@ function viewSettings(app) {
πŸ“± In Safari: Share β†’ Add to Home Screen to install GymLog as a full-screen app. All data stays on this device (localStorage) β€” export a backup now and then!
GymLog Β· exercise data: hasaneyldrm/exercises-dataset (CC)
+
`; $('#btn-back').onclick = () => nav('#home'); @@ -1623,6 +1665,8 @@ function viewSettings(app) { toast('Welcome back, ' + u.name + ' πŸ’ͺ'); } catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') toast(e.message || 'Sign-in failed'); } }; + app.querySelectorAll('[data-theme-set]').forEach(c => c.addEventListener('click', () => { S.theme = c.dataset.themeSet; save(); route(); })); + app.querySelectorAll('[data-accent-set]').forEach(c => c.addEventListener('click', () => { S.accent = c.dataset.accentSet; save(); route(); })); app.querySelectorAll('[data-unit]').forEach(c => c.addEventListener('click', () => { S.unit = c.dataset.unit; save(); route(); })); $('#set-rest').addEventListener('change', ev => { S.restSec = +ev.target.value; save(); }); $('#set-sound').onclick = () => { S.sound = !S.sound; save(); route(); }; diff --git a/app/index.html b/app/index.html index 41800ef..36b522f 100644 --- a/app/index.html +++ b/app/index.html @@ -13,7 +13,7 @@ - +
πŸ‹οΈ
@@ -45,7 +45,7 @@
- - + + diff --git a/app/style.css b/app/style.css index d5e8449..764a1b0 100644 --- a/app/style.css +++ b/app/style.css @@ -7,6 +7,21 @@ --r:16px; --pad:16px; --sab:env(safe-area-inset-bottom,0px); --sat:env(safe-area-inset-top,0px); } +/* light theme (per-account setting, synced) */ +:root[data-theme="light"]{ + --bg:#f2f4f7; --bg2:#e7eaef; --card:#ffffff; --card2:#eef0f4; + --line:#d9dee6; --txt:#171b22; --mut:#5b6474; --dim:#98a0af; +} +/* accent palettes (per-account setting) */ +:root[data-accent="sky"]{--acc:#38bdf8;--acc2:#0ea5e9} +:root[data-accent="orange"]{--acc:#fb923c;--acc2:#f97316} +:root[data-accent="violet"]{--acc:#a78bfa;--acc2:#8b5cf6} +:root[data-accent="pink"]{--acc:#f472b6;--acc2:#ec4899} +:root[data-accent="red"]{--acc:#f87171;--acc2:#ef4444} +:root[data-accent="teal"]{--acc:#2dd4bf;--acc2:#14b8a6} +:root[data-accent="gold"]{--acc:#fbbf24;--acc2:#f59e0b} +:root{--accT:color-mix(in srgb, var(--acc) 16%, transparent)} + *{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent} html{font-size:16px} body{ @@ -55,6 +70,9 @@ a{color:var(--acc)} #tabbar{position:fixed;left:0;right:0;bottom:0;z-index:50; background:rgba(16,18,24,.88);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px); border-top:1px solid var(--line); +} +:root[data-theme="light"] #tabbar{background:rgba(255,255,255,.86)} +#tabbar{ display:flex;justify-content:space-around;align-items:flex-end; padding:8px 6px calc(8px + var(--sab))} #tabbar button{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px; @@ -195,9 +213,9 @@ a{color:var(--acc)} .hm-grid{display:flex;gap:3px} .hm-col{display:flex;flex-direction:column;gap:3px} .hm-c{width:11px;height:11px;border-radius:3px;background:var(--bg2);flex:none} -.hm-c.l1{background:#33451b} -.hm-c.l2{background:#527221} -.hm-c.l3{background:#7aa629} +.hm-c.l1{background:#33451b;background:color-mix(in srgb, var(--acc) 28%, var(--bg2))} +.hm-c.l2{background:#527221;background:color-mix(in srgb, var(--acc) 52%, var(--bg2))} +.hm-c.l3{background:#7aa629;background:color-mix(in srgb, var(--acc) 76%, var(--bg2))} .hm-c.l4{background:var(--acc)} .hm-c.today{outline:1.5px solid var(--txt);outline-offset:-1.5px} .hm-c.future{opacity:.28} @@ -229,3 +247,30 @@ a{color:var(--acc)} .capitalize{text-transform:capitalize} h4.sec{font-size:.8rem;text-transform:uppercase;letter-spacing:.08em;color:var(--mut);margin:20px 0 10px;font-weight:700} .steps-list{padding-left:20px;color:var(--mut);font-size:.9rem;line-height:1.55;display:flex;flex-direction:column;gap:8px} + +/* accent swatches (settings) */ +.swatches{display:flex;gap:10px;flex-wrap:wrap} +.swatch{width:36px;height:36px;border-radius:50%;border:3px solid transparent;flex:none} +.swatch.on{border-color:var(--txt)} + +/* ---------- desktop (β‰₯1000px): wide dashboard layout ---------- */ +.cols{display:block} +@media (min-width:1000px){ + #app{max-width:1080px;padding-top:28px} + .cols{display:grid;grid-template-columns:1fr 1fr;gap:14px;align-items:start} + .cols>*{min-width:0} + #app .list{display:grid;grid-template-columns:1fr 1fr;gap:10px} + #modal-root .list,.narrow .list{display:flex;flex-direction:column} + .narrow{max-width:640px;margin:0 auto} + .tiles{grid-template-columns:repeat(4,1fr)} + .cols .tiles{grid-template-columns:1fr 1fr} + #tabbar{left:50%;right:auto;bottom:14px;transform:translateX(-50%);width:560px; + border:1px solid var(--line);border-radius:22px;padding:8px 10px 10px} + #tabbar button.start{margin-top:-30px} + /* margin centering (not transform) β€” JS drag animates transform:translateY */ + .sheet{left:50%;right:auto;margin-left:-320px;width:640px;border-radius:22px 22px 0 0} + .center{width:360px} + #timer{left:50%;right:auto;margin-left:-260px;width:520px;bottom:110px} + .exmedia img{height:400px} + .hm-wrap{display:flex;flex-direction:column;align-items:center} +} diff --git a/app/sw.js b/app/sw.js index 6f5c1ab..008f3eb 100644 --- a/app/sw.js +++ b/app/sw.js @@ -1,6 +1,6 @@ /* GymLog service worker β€” network-first for app shell, cache-first for media */ -const CACHE = 'gymlog-v7'; -const SHELL = ['./', 'index.html', 'style.css?v=7', 'app.js?v=7', 'data.js?v=7', 'manifest.json']; +const CACHE = 'gymlog-v8'; +const SHELL = ['./', 'index.html', 'style.css?v=8', 'app.js?v=8', 'data.js?v=8', 'manifest.json']; self.addEventListener('install', e => { e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)).then(() => self.skipWaiting()));