Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
"splash": {
"image": "./assets/splash-icon.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
"backgroundColor": "#0c0c0e"
},
"ios": {
"supportsTablet": true
"supportsTablet": true,
"bundleIdentifier": "app.netlify.kasane"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
"backgroundColor": "#0c0c0e"
},
"edgeToEdgeEnabled": true,
"predictiveBackGestureEnabled": false
Expand All @@ -29,7 +30,31 @@
"output": "single"
},
"scheme": "kasane",
"plugins": ["expo-router", "expo-font"],
"plugins": [
"expo-router",
"expo-font",
[
"expo-alternate-app-icons",
[
{
"name": "Split",
"ios": "./assets/icons/icon-split.png",
"android": {
"foregroundImage": "./assets/icons/icon-split-foreground.png",
"backgroundColor": "#5cdfff"
}
},
{
"name": "Light",
"ios": "./assets/icons/icon-light.png",
"android": {
"foregroundImage": "./assets/icons/icon-light-foreground.png",
"backgroundColor": "#f5f5f5"
}
}
]
]
],
"experiments": {
"typedRoutes": true,
"tsconfigPaths": true
Expand Down
8 changes: 6 additions & 2 deletions app/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { AppIconPicker } from "@/components/AppIconPicker";
import { Page } from "@/components/Page";
import { canChangeAppIcon } from "@/state/appIcon";

export default function SettingsScreen() {
return (
<Page
eyebrow="Account"
title="Settings"
blurb="Settings are coming soon."
/>
blurb={canChangeAppIcon ? undefined : "Settings are coming soon."}
>
{canChangeAppIcon && <AppIconPicker />}
</Page>
);
}
Binary file modified assets/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-light-foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-split-foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-split.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/splash-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions e2e/side-menu.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { expect, test, type Page } from "@playwright/test";

/**
* The navigation drawer, end to end against the real export. Everything is
* found by accessible name, so a lost `accessibilityLabel` fails here too.
*/

const openMenu = async (page: Page): Promise<void> => {
await page.goto("/");
await page.getByRole("button", { name: "Open menu" }).click();
await expect(page.getByText("Menu", { exact: true })).toBeVisible();
};

test.describe("side menu", () => {
test("opens from the header and lists every destination", async ({
page,
}) => {
await openMenu(page);
await expect(page.getByRole("link", { name: "All mapped" })).toBeVisible();
await expect(page.getByRole("link", { name: "My shows" })).toBeVisible();
await expect(page.getByRole("link", { name: "Settings" })).toBeVisible();
});

test("closes from its close button", async ({ page }) => {
await openMenu(page);
await page.getByRole("button", { name: "Close menu" }).last().click();
await expect(page.getByText("Menu", { exact: true })).toBeHidden();
});

test("closes when the scrim is pressed", async ({ page }) => {
await openMenu(page);
await page
.getByRole("button", { name: "Close menu" })
.first()
.click({
// The drawer covers the scrim's left edge, so press well to its right.
position: { x: 600, y: 300 },
});
await expect(page.getByText("Menu", { exact: true })).toBeHidden();
});

test("navigates to a destination and closes", async ({ page }) => {
await openMenu(page);
await page.getByRole("link", { name: "Settings" }).click();
await expect(page).toHaveURL(/\/settings$/);
await expect(page.getByText("Menu", { exact: true })).toBeHidden();
});
});
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"format": "oxfmt",
"format:check": "oxfmt --check",
"system-check": "run-s typecheck format:check lint lint:actions spellcheck test build:web",
"icons:render": "bun scripts/render-icons.ts",
"prepare": "husky",
"desktop:init": "tauri init",
"desktop:dev": "tauri dev",
Expand All @@ -40,6 +41,7 @@
"@tanstack/react-query": "5.103.1",
"@tanstack/react-query-persist-client": "5.103.1",
"expo": "57.0.23",
"expo-alternate-app-icons": "11.0.0",
"expo-constants": "57.0.18",
"expo-font": "57.0.4",
"expo-linking": "57.0.10",
Expand Down
169 changes: 169 additions & 0 deletions scripts/render-icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// Renders every icon in `assets/` from the logo's definition below, so the
// images are never edited by hand. Needs network access for the Noto Sans JP
// glyph and the Playwright Chromium from `bun run e2e:install`.
//
// bun run icons:render
import { mkdirSync } from "node:fs";
import { dirname, join } from "node:path";
import { chromium } from "@playwright/test";
import { COLOR } from "@/theme";

const OUT_DIR = "assets";
const GLYPH = "重";
const FONT_FAMILY = "Noto Sans JP";
const FONT_URL =
"https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@900&display=swap";
// The glyph sits low in its em box; this lifts it to the optical centre.
const LIFT_EM = -0.038;
const FULL = 1024;

const CYAN = COLOR.sideAnime;
const CORAL = COLOR.sideManga;
const WHITE = COLOR.textPrimary;
const BLACK = COLOR.background;

const SPLIT_FILL = `linear-gradient(135deg, ${CYAN} 0%, ${CYAN} 40%, ${WHITE} 40%, ${WHITE} 60%, ${CORAL} 60%, ${CORAL} 100%)`;
const SPLIT_GROUND = `linear-gradient(135deg, ${CYAN} 0%, ${CYAN} 50%, ${CORAL} 50%, ${CORAL} 100%)`;

type Frame = { size: number; background: string; radius: number; mark: string };
type Icon = Frame & { file: string };
type Overlap = { px: number; shift: number };

const lifted = (style: string) =>
`<span style="display:inline-block;transform:translateY(${LIFT_EM}em);${style}">${GLYPH}</span>`;

/** The primary mark: one glyph filled with the three colours on the diagonal. */
const layeredMark = (px: number) =>
lifted(
`font-size:${px}px;color:transparent;background-image:${SPLIT_FILL};-webkit-background-clip:text;background-clip:text`,
);

const solidMark = (px: number) => lifted(`font-size:${px}px;color:${BLACK}`);

/** Two offset glyphs, black where they overlap. */
const overlapMark = ({ px, shift }: Overlap) => {
const near = FULL / 2 - shift;
const far = FULL / 2 + shift;
const at = (xy: number) =>
`x="${xy}" y="${xy}" text-anchor="middle" dominant-baseline="central"`;
return `<svg viewBox="0 0 ${FULL} ${FULL}" width="${FULL}" height="${FULL}" style="font-size:${px}px">
<defs><clipPath id="near"><text ${at(near)}>${GLYPH}</text></clipPath></defs>
<g transform="translate(0,${LIFT_EM * px})">
<text ${at(near)} fill="${CYAN}">${GLYPH}</text>
<text ${at(far)} fill="${CORAL}">${GLYPH}</text>
<text ${at(far)} fill="${BLACK}" clip-path="url(#near)">${GLYPH}</text>
</g>
</svg>`;
};

const TRANSPARENT = "transparent";

// Android masks an adaptive foreground to roughly its middle two thirds, so
// the foreground marks are drawn smaller than their full-bleed counterparts.
const ICONS: readonly Icon[] = [
{
file: "icon.png",
size: FULL,
background: BLACK,
radius: 0,
mark: layeredMark(640),
},
{
file: "adaptive-icon.png",
size: FULL,
background: TRANSPARENT,
radius: 0,
mark: layeredMark(420),
},
{
file: "splash-icon.png",
size: FULL,
background: TRANSPARENT,
radius: 0,
mark: layeredMark(560),
},
// The mark alone, cropped close, for the in-app header.
{
file: "logo-mark.png",
size: 512,
background: TRANSPARENT,
radius: 0,
mark: layeredMark(540),
},
{
file: "favicon.png",
size: 256,
background: BLACK,
radius: 56,
mark: layeredMark(168),
},
{
file: "icons/icon-split.png",
size: FULL,
background: SPLIT_GROUND,
radius: 0,
mark: solidMark(600),
},
{
file: "icons/icon-split-foreground.png",
size: FULL,
background: SPLIT_GROUND,
radius: 0,
mark: solidMark(400),
},
{
file: "icons/icon-light.png",
size: FULL,
background: WHITE,
radius: 0,
mark: overlapMark({ px: 600, shift: 28 }),
},
{
file: "icons/icon-light-foreground.png",
size: FULL,
background: TRANSPARENT,
radius: 0,
mark: overlapMark({ px: 390, shift: 18 }),
},
];

const html = ({ size, background, radius, mark }: Frame) =>
`<!doctype html><html lang="ja"><head><meta charset="utf-8">
<link rel="stylesheet" href="${FONT_URL}">
<style>html,body{margin:0;background:transparent}body{font-family:'${FONT_FAMILY}',sans-serif;font-weight:900;line-height:1}</style>
</head><body><div style="width:${size}px;height:${size}px;background:${background};border-radius:${radius}px;display:grid;place-items:center;overflow:hidden">${mark}</div></body></html>`;

const browser = await chromium.launch();

// One page at a time: every icon waits on the same web font, and a shared
// browser keeps it cached after the first.
await ICONS.reduce(async (previous, icon) => {
await previous;
const path = join(OUT_DIR, icon.file);
mkdirSync(dirname(path), { recursive: true });
const page = await browser.newPage({
viewport: { width: icon.size, height: icon.size },
deviceScaleFactor: 1,
});
await page.setContent(html(icon), { waitUntil: "networkidle" });
const hasFont = await page.evaluate(
async ({ family, glyph }) => {
const font = `900 100px '${family}'`;
await document.fonts.load(font, glyph);
return document.fonts.check(font, glyph);
},
{ family: FONT_FAMILY, glyph: GLYPH },
);
if (!hasFont) {
throw new Error(`${FONT_FAMILY} did not load; ${icon.file} not rendered`);
}
await page.screenshot({
path,
omitBackground: icon.background === TRANSPARENT,
clip: { x: 0, y: 0, width: icon.size, height: icon.size },
});
await page.close();
console.log(`rendered ${path}`);
}, Promise.resolve());

await browser.close();
Loading
Loading