The app's own mark: assets/logoym.png becomes the icon, the brand, and the Start button
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s

Every icon the app ships now comes from one source image, generated rather than drawn:
frontend/scripts/build-app-icons.mjs writes public/icon-512.png (declared "any maskable"
in the manifest, hence an opaque square), public/icon-180.png (iOS home screen and
favicon), public/logo.png (transparent, for the UI) and resources/icon.png (the
@capacitor/assets source for the native shells).

The file was a PNG despite its .jpeg name — it has a real alpha channel — so it is
assets/logoym.png now. It is the file the owner dropped in, and the icons are derived
from it, which is what keeps the PWA icon, the home-screen icon, the in-app mark and the
native icon from ever drifting apart.

The emblem is dark green (its most common colour is #031808, its accents are greens too)
with transparent corners, which decides two things. The icon squares are filled with that
same dark green and the mark is centred at 88% of the canvas: the corners blend into it,
the maskable safe circle stays clean, and a transparent icon can't disappear on a dark
home screen. And the tab bar's Start button keeps the accent as a RING instead of a fill —
on the old lime disc the emblem would have read as a dark blob. The ring still marks the
primary action, and it still turns orange with the pulse while a session is running, with
the label underneath saying Start / Resume / Workout, so nothing that button communicated
was lost by swapping its glyph for the mark.

Login, the mobile onboarding and the boot placeholder in App.jsx showed the dumbbell glyph
as a stand-in for the brand; they all show the mark now, so the app cannot flash a
different logo on its way in. Three now-unused Icon imports go with it.

Icons are written as 256-colour palettes: measured against the full RGBA versions the mean
per-channel error is 1.5/255, invisible, and the files are ~2.5× smaller (161 KB for
everything the browser downloads, against 532 KB of source). Transparency survives it as
the palette's own alpha entries — verified, not assumed.

docs/MOBILE.md says how to regenerate and why resources/icon.svg is now inert
(@capacitor/assets tries .png before .svg, so the new icon.png wins), and that comment is
repeated in the SVG itself so nobody edits the file that no longer decides anything.
This commit is contained in:
dsantillan committed 2026-09-23 10:41:33 -04:00
1 parent ba37ef8a44
commit c150101232
14 files changed
+146 -25

No files matched your search

+74
View File
@@ -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))