Cards you can see through, a splash that waits, and iOS launch screens
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
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
**The transparency was there and invisible.** `--glass` was a near-black at 55% alpha, and a dark film over a dark background reads as solid no matter what the alpha says — so the cards looked exactly as opaque as before. It is 34% now, the family tint weighs a little more (14%) and the blur is 10px instead of 16: heavy blur flattens the backdrop into one colour, which hides the very thing that is supposed to show through. The opaque `@supports` fallback is gone as well. It was copied from the tab bar, where it is right — the bar floats over scrolling text — and it is wrong here: a card sits in the page flow and the only thing behind it is the aura. On any device that took that branch, the cards were solid by construction. **The splash now waits, which is what a launch screen does.** It stays until the boot is finished, with a floor of 1.1s so it can actually be read (a warm boot takes milliseconds, and a splash that lasts that long is a flicker) and a ceiling of 6s so a request that never answers cannot hold anybody behind a photograph — their workouts are already local. The mark pulses slowly while it waits, so it looks like a screen that is loading rather than a photograph that is stuck. **The long white is iOS, before any of our code runs.** The deployed HTML already carries the aura's base colour inline, so what is left is the installed web app's own launch screen: iOS paints it before the page exists, and without an `apple-touch-startup-image` that matches the device it paints nothing. Fourteen entries now cover the phone and tablet sizes the app is opened on, cropped from the same photograph (each device fetches only its own). build-app-icons.mjs fails when the sizes it generates and the sizes index.html links disagree, because a missing entry is the blank screen this exists to remove.
This commit is contained in:
1 parent
3908dc524a
commit
9e580c4794
20 files changed
+150
-41
No files matched your search
@@ -20,7 +20,7 @@
|
||||
* 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 { existsSync, readFileSync } from 'node:fs'
|
||||
import { existsSync, mkdirSync, readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
// sharp takes paths, not file: URLs — hence fileURLToPath here and in icon() below.
|
||||
@@ -116,4 +116,54 @@ if (splashMissing) {
|
||||
.toFile(fileURLToPath(new URL('splash.jpg', RES)))
|
||||
const nativeOut = readFileSync(fileURLToPath(new URL('splash.jpg', RES)))
|
||||
console.log(` resources/splash.jpg native source 2732x2732 bg ${SPLASH_BG} ${(nativeOut.length / 1024 / 1024).toFixed(1)} MB`)
|
||||
|
||||
/* --------------------------------------------------- iOS launch screens --
|
||||
*
|
||||
* An installed iOS web app paints its OWN screen before any of this code runs, and without these it
|
||||
* is a blank — the white flash on every open that no amount of CSS can touch. iOS picks the entry
|
||||
* whose media query matches the device, so each one is a differently-cropped copy of the same
|
||||
* photograph at that device's exact pixel size; a device that finds no match gets the blank back.
|
||||
*
|
||||
* Only one file is ever fetched per device, but all of them live in the repository, so this list is
|
||||
* kept to the screens the app is realistically opened on. Add a line and re-run to cover another.
|
||||
* The CSS pixels and the device-pixel-ratio here are exactly what the <link> in index.html states.
|
||||
*/
|
||||
const IOS_SIZES = [
|
||||
[375, 667, 2], [414, 736, 3], [375, 812, 3], [414, 896, 2], [414, 896, 3],
|
||||
[390, 844, 3], [393, 852, 3], [402, 874, 3], [428, 926, 3], [430, 932, 3], [440, 956, 3],
|
||||
[768, 1024, 2], [834, 1194, 2], [1024, 1366, 2]
|
||||
]
|
||||
const STARTUP = new URL('../public/startup/', import.meta.url)
|
||||
|
||||
if (!splashMissing) {
|
||||
mkdirSync(fileURLToPath(STARTUP), { recursive: true })
|
||||
let bytes = 0
|
||||
for (const [w, h, dpr] of IOS_SIZES) {
|
||||
const px = { w: w * dpr, h: h * dpr }
|
||||
const out = new URL(`${px.w}x${px.h}@${dpr}.jpg`, STARTUP)
|
||||
// `cover` rather than `contain`: a launch screen fills the screen, and the composition is
|
||||
// centred, so a crop keeps the middle of the frame and loses only sky and floor.
|
||||
await sharp(SPLASH_SRC).resize(px.w, px.h, { fit: 'cover', position: 'centre' })
|
||||
.jpeg({ quality: 72, chromaSubsampling: '4:2:0' })
|
||||
.toFile(fileURLToPath(out))
|
||||
bytes += readFileSync(fileURLToPath(out)).length
|
||||
}
|
||||
console.log(` public/startup/ iOS launch screens ${IOS_SIZES.length} sizes ${(bytes / 1024).toFixed(0)} KB total`)
|
||||
|
||||
// The <link> tags in index.html have to name the same sizes as the table above, and two lists in
|
||||
// two files is exactly the kind of thing that drifts silently: iOS matches on the media query, so
|
||||
// a size that is generated but not linked is fetched by nobody and a linked size that is not
|
||||
// generated is a 404 — and iOS answers a missing launch image with the blank screen this whole
|
||||
// section exists to remove. Cheap to check, so it is checked.
|
||||
const head = readFileSync(fileURLToPath(new URL('../index.html', import.meta.url)), 'utf8')
|
||||
const linked = [...head.matchAll(/\(device-width: (\d+)px\) and \(device-height: (\d+)px\) and \(-webkit-device-pixel-ratio: (\d+)\)/g)]
|
||||
.map(m => [Number(m[1]), Number(m[2]), Number(m[3])])
|
||||
const key = a => a.join('x')
|
||||
const missing = IOS_SIZES.filter(s => !linked.some(l => key(l) === key(s)))
|
||||
const extra = linked.filter(l => !IOS_SIZES.some(s => key(s) === key(l)))
|
||||
if (missing.length || extra.length) {
|
||||
console.error(` index.html and IOS_SIZES disagree — generated but not linked: ${missing.map(key).join(', ') || 'none'}; linked but not generated: ${extra.map(key).join(', ') || 'none'}`)
|
||||
process.exitCode = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user