diff --git a/assets/logoym.png b/assets/logoym.png new file mode 100644 index 0000000..d85985f Binary files /dev/null and b/assets/logoym.png differ diff --git a/docs/MOBILE.md b/docs/MOBILE.md index 0914281..3480dc2 100644 --- a/docs/MOBILE.md +++ b/docs/MOBILE.md @@ -67,16 +67,32 @@ into both native projects — re-run it after every web-code change before build ## App icons & splash screens -`frontend/resources/icon.svg` is the 1024×1024 source (the app's dumbbell glyph on the -app background). Generate all platform assets from it on a machine with the tooling: +`frontend/resources/icon.png` (1024×1024) is the source: the app's brand image from +`assets/logoym.png`, centred on the emblem's own dark green so the square is fully opaque — a +maskable icon may not be transparent. It is **generated**, not hand-drawn, so replacing the brand +image means regenerating every icon the app ships, in one step: ```sh cd frontend -npx @capacitor/assets generate --iconBackgroundColor '#0c0e12' --splashBackgroundColor '#0c0e12' +node scripts/build-app-icons.mjs ``` -(If the generator won't take the SVG directly, export it to `resources/icon.png` at -1024×1024 first — any image tool can do it.) +That writes `resources/icon.png` plus the three the web app serves: `public/icon-512.png` (declared +`any maskable` in the manifest, hence the opaque background), `public/icon-180.png` (iOS home screen +and favicon) and `public/logo.png` (transparent, for the tab bar's Start button, the login screen +and the boot placeholder). Change `ICON_BG` in that script to re-skin all of them at once. + +Then generate the platform assets from it: + +```sh +cd frontend +npx @capacitor/assets generate --splashBackgroundColor '#0c0e12' +``` + +The icon's background colour is already baked into `icon.png`, so only the splash needs one here. +`resources/icon.svg` is the vector drawing of the dumbbell glyph the app used before it had this +mark: nothing generates from it any more (`@capacitor/assets` prefers `.png` over `.svg` in the same +directory — see the extension order in its `loadInputAsset`), and it is kept only as that drawing. ## Distribution — deliberately no app stores diff --git a/frontend/public/icon-180.png b/frontend/public/icon-180.png index cded821..32ee64f 100644 Binary files a/frontend/public/icon-180.png and b/frontend/public/icon-180.png differ diff --git a/frontend/public/icon-512.png b/frontend/public/icon-512.png index f269a3d..195d909 100644 Binary files a/frontend/public/icon-512.png and b/frontend/public/icon-512.png differ diff --git a/frontend/public/logo.png b/frontend/public/logo.png new file mode 100644 index 0000000..d85f28c Binary files /dev/null and b/frontend/public/logo.png differ diff --git a/frontend/resources/icon.png b/frontend/resources/icon.png new file mode 100644 index 0000000..b1aa2d1 Binary files /dev/null and b/frontend/resources/icon.png differ diff --git a/frontend/resources/icon.svg b/frontend/resources/icon.svg index 161ad0e..39b8de2 100644 --- a/frontend/resources/icon.svg +++ b/frontend/resources/icon.svg @@ -1,7 +1,8 @@ - + diff --git a/frontend/scripts/build-app-icons.mjs b/frontend/scripts/build-app-icons.mjs new file mode 100644 index 0000000..4f4b10d --- /dev/null +++ b/frontend/scripts/build-app-icons.mjs @@ -0,0 +1,74 @@ +/* build-app-icons.mjs — derive every icon the app ships from one source image. + * + * The source is assets/logoym.png (a PNG despite its old .jpeg name; it has a real alpha channel, + * with the emblem's corners transparent). Everything else here is generated, so the app icon, the + * iOS home-screen icon, the in-app brand mark and the Capacitor source icon can never drift apart + * from each other or from the file the owner actually dropped in assets/. + * + * Run it after replacing the source: + * + * cd frontend && node scripts/build-app-icons.mjs + * + * `sharp` comes with @capacitor/assets (a devDependency here), which is the only reason it is + * available without adding a dependency of our own — see CONTRIBUTING.md on that. + * + * THE ONE DESIGN DECISION: the emblem is dark green (its most common colour is #031808, its light + * accents are greens too), and its corners are transparent. So a transparent icon would disappear + * on a dark home screen, and a white one would put a white card behind an already-square logo. The + * canvases below are filled with the emblem's OWN darkest green and the logo is centred at 88% of + * the square: the corners it does not cover blend into it, the maskable safe circle stays clean, + * and the icon reads as one piece at 180 px. Change ICON_BG to re-skin all of them at once. + */ +import sharp from 'sharp' +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' + +// sharp takes paths, not file: URLs — hence fileURLToPath here and in icon() below. +const SRC = fileURLToPath(new URL('../../assets/logoym.png', import.meta.url)) +const PUB = new URL('../public/', import.meta.url) +const RES = new URL('../resources/', import.meta.url) + +/** The emblem's own dominant colour (sampled from the source), used to fill the icon squares. */ +const ICON_BG = '#031808' +/** Fraction of the canvas the emblem occupies. The maskable safe circle is 80% of the square, and + * the emblem's own corners are transparent, so slightly past it costs nothing and gains size. */ +const ICON_FIT = 0.88 +/** Longest side of the in-app mark. Displayed at 52 px (tab bar) and ~88 px (login), so 256 covers + * a 3× screen twice over; anything larger is bytes nobody looks at. */ +const MARK_PX = 256 +/* Every PNG here is written as a 256-colour palette. Measured against the full RGBA version the + * mean per-channel error is 1.5/255 — invisible — for a file about 2.5× smaller: the emblem is + * greens on greens, which is exactly what a palette is good at. The transparency survives as the + * palette's own alpha entries (checked: the corners really are alpha 0.) */ +const PNG = { palette: true, colours: 256, compressionLevel: 9, effort: 10 } + +const logo = sharp(SRC).ensureAlpha().trim() + +/** One opaque square with the emblem centred in it. */ +async function icon(size, out) { + const inner = Math.round(size * ICON_FIT) + const placed = await logo.clone().resize(inner, inner, { fit: 'inside' }).png().toBuffer() + await sharp({ create: { width: size, height: size, channels: 4, background: ICON_BG } }) + .composite([{ input: placed, gravity: 'centre' }]) + .png(PNG) + .toFile(fileURLToPath(out)) + console.log(` ${out.pathname.split('/').slice(-2).join('/')} ${size}x${size} bg ${ICON_BG}`) +} + +console.log('generating app icons from assets/logoym.png') + +// The two the web app ships: icon-512 is declared "any maskable" in manifest.json (hence the +// opaque background and the centred emblem), icon-180 is the iOS home screen and the favicon. +await icon(512, new URL('icon-512.png', PUB)) +await icon(180, new URL('icon-180.png', PUB)) + +// The in-app brand mark: transparent, so it sits on the page's own background. Used by the tab +// bar's Start button, the login screen and the boot placeholder. +await logo.clone().resize(MARK_PX, MARK_PX, { fit: 'inside' }).png(PNG) + .toFile(fileURLToPath(new URL('logo.png', PUB))) +const mark = readFileSync(fileURLToPath(new URL('logo.png', PUB))) +console.log(` public/logo.png transparent ${(mark.length / 1024).toFixed(1)} KB`) + +// The Capacitor source icon for the native shells (docs/MOBILE.md: `npx @capacitor/assets +// generate` reads resources/). Kept opaque and 1024 wide, which is what that tool wants. +await icon(1024, new URL('icon.png', RES)) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 29243d2..e28aed4 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -14,7 +14,6 @@ import { installChipDrag } from './lib/hchips.js' import { syncPushSubscription } from './lib/push.js' import { MOBILE } from './lib/mobile.js' import { startFlow } from './sheets.jsx' -import Icon from './components/Icon.jsx' import TabBar from './components/TabBar.jsx' import ErrorBoundary from './components/ErrorBoundary.jsx' import Modals from './components/Modals.jsx' @@ -137,8 +136,10 @@ function Shell() { const authed = user || isGuest if (!ready && !authed) return (
-
- + {/* The mark, dimmed, as the boot placeholder — the same image the login screen shows, so + the app never flashes a different logo on its way in. */} +
+
) diff --git a/frontend/src/components/TabBar.jsx b/frontend/src/components/TabBar.jsx index c0ecc9c..2c84a2c 100644 --- a/frontend/src/components/TabBar.jsx +++ b/frontend/src/components/TabBar.jsx @@ -41,7 +41,10 @@ export default function TabBar({ onStart }) { tab it is and stays lit (#29); anywhere else it brings you back to the exercise you were on — the marker is kept in S.active.cur and never moves on its own (#21). */} diff --git a/frontend/src/components/TabBar.test.jsx b/frontend/src/components/TabBar.test.jsx index ed4b5e8..f57bc19 100644 --- a/frontend/src/components/TabBar.test.jsx +++ b/frontend/src/components/TabBar.test.jsx @@ -55,4 +55,15 @@ describe('the tab bar', () => { expect(clicked).toContain('/stats') expect(clicked).toContain('/library') }) + + it('puts the app\'s own mark in the raised button, not a glyph', () => { + mount() + const disc = tabs()[2].querySelector('.cir') + const img = disc?.querySelector('img') + // Relative src on purpose: the app is served from wherever it is served from (base './' plus a + // hash router keeps the document at that root), so an absolute /logo.png would miss a subpath. + expect(img?.getAttribute('src')).toBe('logo.png') + expect(disc.querySelector('.icn')).toBeNull() + expect(img.getAttribute('alt')).toBe('') + }) }) diff --git a/frontend/src/index.css b/frontend/src/index.css index b69e451..1aca342 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -361,21 +361,28 @@ h4.sec{ #tabbar button.on{color:var(--acc)} #tabbar button.on .icn{--icon-stroke:2;color:inherit;opacity:1} #tabbar button.start{margin-top:-24px} +/* The disc carries the app's own mark (public/logo.png, generated from assets/logoym.png by + scripts/build-app-icons.mjs) instead of a glyph, so it keeps the accent as a RING rather than as + a fill: the emblem is dark green, and on a lime disc it would read as a dark blob. The ring is + what still marks this as the primary action against the dark bar, and it turns orange while a + session is running — the state the old play glyph carried, alongside the label underneath. + The fill is the emblem's own darkest green, so the corners it does not cover blend into it. */ #tabbar button.start .cir{ - width:52px;height:52px;border-radius:50%;background:var(--acc);color:var(--on-acc); + width:52px;height:52px;border-radius:50%;background:#031808; + border:2px solid var(--acc); display:flex;align-items:center;justify-content:center;position:relative; box-shadow:0 6px 18px -4px color-mix(in srgb,var(--acc) 55%,transparent); - transition:transform var(--fast) var(--ease); + transition:transform var(--fast) var(--ease),border-color var(--fast); } #tabbar button.start:active .cir{transform:scale(.93)} -#tabbar button.start .cir .icn{font-size:26px;--icon-stroke:2;color:inherit;opacity:1} +/* Rounded on the rather than clipped with `overflow:hidden` on the disc: the recording pulse + is a ::after on .cir that scales out past it, and clipping the disc would clip that too. */ +#tabbar button.start .cir img{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block} #tabbar button.start span{color:var(--acc);font-weight:600} -/* `.cir` is itself a , so the label rules above and below reach it too and - outrank the `.cir` block — which is how the running state ended up painting an - orange play glyph onto an orange disc. Both states restate their own colour. - The disc is orange in either theme, so its glyph is black, not `--on-acc`. */ -#tabbar button.start .cir{color:var(--on-acc)} -#tabbar button.start.rec .cir{background:var(--orange);color:#000;box-shadow:0 6px 18px -4px color-mix(in srgb,var(--orange) 55%,transparent)} +/* `.cir` is itself a , so the label rule above reaches it as well. Nothing inside it reads + colour any more (the mark is an image), but the ring and the pulse are painted from the state + classes, which is why they restate themselves here. */ +#tabbar button.start.rec .cir{border-color:var(--orange);box-shadow:0 6px 18px -4px color-mix(in srgb,var(--orange) 55%,transparent)} #tabbar button.start.rec span{color:var(--orange)} #tabbar button.start.rec .cir::after{ content:'';position:absolute;inset:0;border-radius:50%; @@ -383,6 +390,14 @@ h4.sec{ } @keyframes ping{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.45);opacity:0}} +/* --- the app's mark, wherever it stands for the app itself ------------------------------- + Login, the mobile onboarding and the boot placeholder in App.jsx all show this one image, so + the app never flashes a different logo on its way in. Sized by width and centred; the source + is the transparent PNG (public/logo.png, generated by scripts/build-app-icons.mjs), so it sits + on whatever background the screen already has rather than carrying a plate of its own. */ +.brand{display:block;width:88px;height:auto;margin:0 auto} +.brand.boot{width:56px;opacity:.85} + /* NOTE on every backdrop-filter pair in this file: the -webkit- line comes first and the standard property last, which is the order a prefixed/standard pair wants — whichever is written last wins in the cascade, and that should be the standard name. diff --git a/frontend/src/views/Login.jsx b/frontend/src/views/Login.jsx index ad6af01..b42fcfd 100644 --- a/frontend/src/views/Login.jsx +++ b/frontend/src/views/Login.jsx @@ -6,7 +6,6 @@ import { t } from '../lib/i18n.js' import { DEMO, REPO } from '../lib/demo.js' import { guestAllowed } from '../lib/guest.js' import { useState, useRef, useEffect } from 'react' -import Icon from '../components/Icon.jsx' import { Button } from '../components/ui.jsx' import { askAddDeviceData } from '../sheets.jsx' @@ -56,7 +55,9 @@ export default function Login() { catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') useUI.getState().toast(e.message || t('Sign-in failed')) } } const head = <> -
+ {/* The app's mark rather than the dumbbell glyph it used to show: assets/logoym.png is the + brand now, and public/logo.png is the transparent copy of it the app ships. */} +

KuentaGYM

const wrap = { display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: '78vh', textAlign: 'center' } diff --git a/frontend/src/views/MobileOnboarding.jsx b/frontend/src/views/MobileOnboarding.jsx index 4df762e..c0280e9 100644 --- a/frontend/src/views/MobileOnboarding.jsx +++ b/frontend/src/views/MobileOnboarding.jsx @@ -5,7 +5,6 @@ import { useState, useRef, useEffect } from 'react' import { useStore } from '../store/useStore.js' import { useUI } from '../store/useUI.js' import { t } from '../lib/i18n.js' -import Icon from '../components/Icon.jsx' import { Button } from '../components/ui.jsx' import { askAddDeviceData } from '../sheets.jsx' @@ -41,7 +40,7 @@ export function ConnectSheet({ close }) { export default function MobileOnboarding() { const { chooseLocalMode } = useStore() const head = <> -
+

KuentaGYM

const wrap = { display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: '78vh', textAlign: 'center' }