commit
Move to lucide
diff --git a/bun.lock b/bun.lock
index d452120..c52cba6 100644
--- a/bun.lock
+++ b/bun.lock
@@ -5,8 +5,8 @@
"": {
"name": "dough-git",
"dependencies": {
- "@phosphor-icons/core": "^2.1.1",
"hono": "^4.13.8",
+ "lucide-static": "^1.49.0",
"openid-client": "^6.8.8",
},
"devDependencies": {
@@ -16,8 +16,6 @@
},
},
"packages": {
- "@phosphor-icons/core": ["@phosphor-icons/[email protected]", "", {}, "sha512-v4ARvrip4qBCImOE5rmPUylOEK4iiED9ZyKjcvzuezqMaiRASCHKcRIuvvxL/twvLpkfnEODCOJp5dM4eZilxQ=="],
-
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.4.2" } }, "sha512-GimotNn7+ZV0uVArItBbriZsR1oNf0+WTzPkdcFrzShI7k2norL0uzEaJT8T33dWr7O/c9ZDuAFQrctKCi72oQ=="],
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g=="],
@@ -68,6 +66,8 @@
"jose": ["[email protected]", "", {}, "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw=="],
+ "lucide-static": ["[email protected]", "", {}, "sha512-gSjtl7bR2v26oDInh2Wua1PrF2BRRXl9inhnLWcFfnRqRShmgZvlFRisPHqTfU7kxsuZU8ThNjAFotbInrzKow=="],
+
"oauth4webapi": ["[email protected]", "", {}, "sha512-8N28E+a/oxfXWBgOMt+ZP/JUf/XR+IFbvkAEPP3gznXOMv9BpAAwiIj0TFNz3tGTPc0ZQ8zmWBNgN1nAys0gng=="],
"openid-client": ["[email protected]", "", { "dependencies": { "jose": "^6.2.12", "oauth4webapi": "^3.8.8" } }, "sha512-ZsucJA5Ad04Uv7YN4ql+s4GXNmb9uAYQwyJTsJx7CH/MX3JZioLE2pVKi1SC+YrbSLA4Px3Gi30dMjgOZtb6pA=="],
diff --git a/package.json b/package.json
index 6674ebb..9e5c819 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,8 @@
"test": "bun test/run.ts"
},
"dependencies": {
- "@phosphor-icons/core": "^2.1.1",
"hono": "^4.13.8",
+ "lucide-static": "^1.49.0",
"openid-client": "^6.8.8"
},
"devDependencies": {
diff --git a/public/style.css b/public/style.css
index bceae5b..1b37492 100644
--- a/public/style.css
+++ b/public/style.css
@@ -177,8 +177,6 @@ input[type="checkbox"] {
display: inline-block;
vertical-align: middle;
flex-shrink: 0;
- fill: currentColor;
- shape-rendering: crispEdges;
}
/* Site chrome */
@@ -187,7 +185,7 @@ input[type="checkbox"] {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
- gap: 1rem;
+ gap: 1rem;can we make
padding: 0.75rem 1.25rem;
border-bottom: 1px solid var(--border);
background: var(--bg-raised);
diff --git a/src/icons.ts b/src/icons.ts
index d311a04..4d53240 100644
--- a/src/icons.ts
+++ b/src/icons.ts
@@ -5,58 +5,44 @@
import { readFileSync } from "node:fs";
import { createRequire } from "node:module";
-export type IconWeight =
- | "thin"
- | "light"
- | "regular"
- | "bold"
- | "fill"
- | "duotone";
+// Stroke width in rendered pixels, kept constant at every size
+// (lucide's absoluteStrokeWidth behaviour)
+const STROKE_WIDTH = 2.25;
+const GRID = 24;
const require = createRequire(import.meta.url);
-const cache = new Map<string, { viewBox: string; body: string }>();
+const cache = new Map<string, string>();
-// "house" + "bold" -> "@phosphor-icons/core/bold/house-bold.svg"
-function assetPath(name: string, weight: IconWeight): string {
- const fileName = weight === "regular" ? name : `${name}-${weight}`;
- return `@phosphor-icons/core/${weight}/${fileName}.svg`;
+// "house" -> "lucide-static/icons/house.svg"
+function assetPath(name: string): string {
+ return `lucide-static/icons/${name}.svg`;
}
-function parse(
- name: string,
- weight: IconWeight,
-): { viewBox: string; body: string } {
- const cacheKey = `${name}:${weight}`;
- const cached = cache.get(cacheKey);
+function parse(name: string): string {
+ const cached = cache.get(name);
if (cached !== undefined) return cached;
let source: string;
try {
- source = readFileSync(require.resolve(assetPath(name, weight)), "utf8");
+ source = readFileSync(require.resolve(assetPath(name)), "utf8");
} catch {
- throw new Error(`icon: unknown phosphor icon "${name}" (${weight})`);
+ throw new Error(`icon: unknown lucide icon "${name}"`);
}
- const viewBox = /viewBox="([^"]+)"/.exec(source)?.[1] ?? "0 0 256 256";
+ // Skip the licence comment and the <svg ...> open tag
+ const open = source.indexOf("<svg");
const body = source
- .slice(source.indexOf(">") + 1, source.lastIndexOf("</svg>"))
- .replace(/\s*\n\s*/g, "")
+ .slice(source.indexOf(">", open) + 1, source.lastIndexOf("</svg>"))
+ .replace(/\s*\n\s*/g, " ")
.replace(/>\s+</g, "><")
.trim();
- const parsed = {
- viewBox,
- body,
- };
- cache.set(cacheKey, parsed);
- return parsed;
+ cache.set(name, body);
+ return body;
}
-export function icon(
- name: string,
- size = 16,
- weight: IconWeight = "regular",
-): string {
- const { viewBox, body } = parse(name, weight);
- return `<svg class="icon" viewBox="${viewBox}" width="${size}" height="${size}" fill="currentColor" aria-hidden="true">${body}</svg>`;
-}
\ No newline at end of file
+export function icon(name: string, size = 16): string {
+ const body = parse(name);
+ const stroke = +((STROKE_WIDTH * GRID) / size).toFixed(3);
+ return `<svg class="icon" viewBox="0 0 ${GRID} ${GRID}" width="${size}" height="${size}" fill="none" stroke="currentColor" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`;
+}
diff --git a/src/markdown.ts b/src/markdown.ts
index 9494c63..2ac6dce 100644
--- a/src/markdown.ts
+++ b/src/markdown.ts
@@ -377,8 +377,8 @@ const ALERT_ICON: Record<string, string> = {
note: "info",
tip: "lightbulb",
important: "flag",
- warning: "warning-diamond",
- caution: "warning-octagon",
+ warning: "triangle-alert",
+ caution: "octagon-alert",
frozen: "snowflake",
aside: "wind",
};
diff --git a/src/views.ts b/src/views.ts
index 6aa9e24..92d8909 100644
--- a/src/views.ts
+++ b/src/views.ts
@@ -115,11 +115,11 @@ function layout(opts: {
: "";
const nav = opts.user
? `<a class="nav-link" href="/new">${icon("plus")}new</a>
- <a class="nav-link" href="/settings">${icon("gear")}settings</a>
+ <a class="nav-link" href="/settings">${icon("settings")}settings</a>
<form method="post" action="/auth/logout" class="nav-form">
- <button type="submit" class="nav-link nav-button">${icon("sign-out")}logout</button>
+ <button type="submit" class="nav-link nav-button">${icon("log-out")}logout</button>
</form>`
- : `<a class="nav-link" href="/auth/login">${icon("sign-in")}login</a>`;
+ : `<a class="nav-link" href="/auth/login">${icon("log-in")}login</a>`;
const description = metaText(opts.description || config.description);
const url = esc(config.baseUrl + (opts.path ?? ""));
@@ -378,8 +378,8 @@ ${ownerTabs(opts.owner, "repos")}
function repoNav(owner: string, name: string, active: string, q: string): string {
const b = base(owner, name);
return tabs(active, [
- ["summary", "summary", "article", `${b}/${q}`],
- ["log", "log", "git-commit", `${b}/log${q}`],
+ ["summary", "summary", "newspaper", `${b}/${q}`],
+ ["log", "log", "git-commit-horizontal", `${b}/log${q}`],
["tree", "tree", "folder", `${b}/tree${q}`],
]);
}
@@ -430,14 +430,14 @@ ${renderMarkdown(opts.readme.text)}
}
const manage = isOwner
- ? ` <h2 class="section-title">${icon("gear")}manage</h2>
+ ? ` <h2 class="section-title">${icon("settings")}manage</h2>
<div class="tabs">
<form method="post" action="${b}/visibility">
<input type="hidden" name="public" value="${opts.isPublic ? "" : "on"}">
<button type="submit">${icon(opts.isPublic ? "lock" : "lock-open")}make ${opts.isPublic ? "private" : "public"}</button>
</form>
<form method="post" action="${b}/delete" data-confirm="Delete ${esc(title)}? It moves to Recently Deleted.">
- <button type="submit">${icon("trash")}delete repository</button>
+ <button type="submit">${icon("trash-2")}delete repository</button>
</form>
</div>
${collaboratorSection(b, opts.collaborators ?? [])}`
@@ -446,10 +446,10 @@ ${collaboratorSection(b, opts.collaborators ?? [])}`
let descriptionForm = "";
if (opts.canPush) {
descriptionForm = ` <form method="post" action="${b}/description" class="box row">
- <label class="label with-icon" for="repo-description">${icon("note")}description</label>
+ <label class="label with-icon" for="repo-description">${icon("sticky-note")}description</label>
<input id="repo-description" class="grow" type="text" name="description" maxlength="300"
value="${esc(opts.rawDescription)}" placeholder="what this repository is for">
- <button type="submit">${icon("floppy-disk")}save</button>
+ <button type="submit">${icon("save")}save</button>
</form>`;
} else if (opts.rawDescription) {
descriptionForm = ` <p class="muted">${esc(opts.rawDescription)}</p>`;
@@ -483,7 +483,7 @@ ${manage}`;
}
function kindIcon(kind: MirrorKind): string {
- return icon(kind === "github" ? "github-logo" : "git-branch");
+ return icon(kind === "github" ? "globe" : "git-branch");
}
function mirrorSection(
@@ -520,7 +520,7 @@ function mirrorSection(
if (canCheck && links.some((l) => !l.isPrivate)) {
rows.push(` <form method="post" action="${b}/mirrors/check">
- <button type="submit">${icon("arrow-clockwise")}check now</button>
+ <button type="submit">${icon("refresh-cw")}check now</button>
</form>`);
}
@@ -548,11 +548,11 @@ ${MIRROR_KINDS.map(field).join("\n")}
<p class="muted">Give the <code>user/repo</code> on ${esc(MIRROR_KINDS.map(mirrorHost).join(" or "))} — not a full URL.
Mark a mirror <em>private</em> to skip status checks — they are anonymous, so a private
mirror would otherwise always look unreachable. Clear a field to remove it.</p>
- <button type="submit">${icon("floppy-disk")}save mirrors</button>
+ <button type="submit">${icon("save")}save mirrors</button>
</form>`
: "";
- return ` <h2 class="section-title">${icon("hard-drives")}external mirrors</h2>
+ return ` <h2 class="section-title">${icon("hard-drive")}external mirrors</h2>
${list}
${form}`;
}
@@ -561,15 +561,15 @@ const MIRROR_LABELS: Record<string, { label: string; glyph: string; cls: string
synced: { label: "Up to date", glyph: "check", cls: "good" },
ahead: { label: "Mirror behind", glyph: "arrow-up", cls: "warn" },
behind: { label: "Local behind", glyph: "arrow-down", cls: "warn" },
- diverged: { label: "Diverged", glyph: "warning-diamond", cls: "bad" },
- out_of_sync: { label: "Out of sync", glyph: "warning-diamond", cls: "bad" },
+ diverged: { label: "Diverged", glyph: "triangle-alert", cls: "bad" },
+ out_of_sync: { label: "Out of sync", glyph: "triangle-alert", cls: "bad" },
denied: { label: "Private or missing", glyph: "lock", cls: "warn" },
missing: { label: "Repository missing", glyph: "x", cls: "bad" },
};
const UNKNOWN_STATE = {
label: "Unavailable",
- glyph: "question",
+ glyph: "circle-help",
cls: "bad",
};
@@ -699,7 +699,7 @@ export function logPage(opts: {
const rows = opts.commits.map(
(cm) => ` <tr>
<td class="mono">${fmtDate(cm.time)}</td>
- <td>${icon("git-commit", 13)} <a href="${b}/commit/${esc(cm.hash)}${q}">${esc(cm.subject)}</a></td>
+ <td>${icon("git-commit-horizontal", 13)} <a href="${b}/commit/${esc(cm.hash)}${q}">${esc(cm.subject)}</a></td>
<td class="muted">${esc(cm.author)}</td>
<td class="mono">${esc(cm.hash.slice(0, 10))}</td>
</tr>`,
@@ -829,7 +829,7 @@ export function commitPage(opts: {
const body = ` <h1 class="page-title">${esc(cm.subject)}</h1>
${repoNav(opts.owner, opts.name, "log", q)}
<dl class="commit-meta">
- <dt class="with-icon">${icon("git-commit", 13)}commit</dt><dd class="mono">${esc(cm.hash)}</dd>
+ <dt class="with-icon">${icon("git-commit-horizontal", 13)}commit</dt><dd class="mono">${esc(cm.hash)}</dd>
<dt class="with-icon">${icon("user", 13)}author</dt><dd>${esc(cm.author)} <${esc(cm.email)}></dd>
<dt class="with-icon">${icon("clock", 13)}date</dt><dd>${fmtDate(cm.time)}</dd>
</dl>
@@ -856,7 +856,7 @@ function settingsLayout(opts: {
const nav = tabs(opts.active, [
["account", "account", "user", "/settings"],
["tokens", "tokens", "key", "/settings/tokens"],
- ["deleted", "recently deleted", "trash", "/settings/deleted"],
+ ["deleted", "recently deleted", "trash-2", "/settings/deleted"],
]);
return layout({
title: opts.title,
@@ -940,7 +940,7 @@ export function settingsPage(opts: {
const clear = s.discordWebhook
? ` <form method="post" action="/settings/discord" data-confirm="Remove the Discord webhook? Events will stop being announced.">
<input type="hidden" name="url" value="">
- <button type="submit">${icon("trash")}remove webhook</button>
+ <button type="submit">${icon("trash-2")}remove webhook</button>
</form>`
: "";
@@ -951,7 +951,7 @@ export function settingsPage(opts: {
const body = `${opts.saved ? ` <p class="good">saved.</p>` : ""}
- <h2 class="section-title">${icon("discord-logo")}discord notifications</h2>
+ <h2 class="section-title">${icon("message-circle")}discord notifications</h2>
<p class="muted">Announces repositories being created and deleted, and commits being
pushed. Only repositories you own are announced, and only to this webhook.</p>
<section class="box">
@@ -961,12 +961,12 @@ ${webhookError}
<label class="label with-icon" for="discord-url">${icon("link")}webhook</label>
<input id="discord-url" class="grow" type="url" name="url" autocomplete="off"
placeholder="https://discord.com/api/webhooks/…">
- <button type="submit">${icon("floppy-disk")}save</button>
+ <button type="submit">${icon("save")}save</button>
</form>
${clear}
</section>
- <h2 class="section-title">${icon("sliders")}preferences</h2>
+ <h2 class="section-title">${icon("sliders-horizontal")}preferences</h2>
<form method="post" action="/settings/prefs" class="box">
<p><label><input type="checkbox" name="default_private"${on(s.defaultPrivate)}>
New repositories start private</label></p>
@@ -978,7 +978,7 @@ ${clear}
Check mirror status automatically when viewing a repository</label>
<br><span class="muted">Off means mirrors are only checked when you press
<em>check now</em>.</span></p>
- <button type="submit">${icon("floppy-disk")}save preferences</button>
+ <button type="submit">${icon("save")}save preferences</button>
</form>
<h2 class="section-title">${icon("user")}account</h2>
@@ -1025,13 +1025,13 @@ export function deletedPage(opts: {
<td>
<form method="post" action="/settings/deleted/restore">
<input type="hidden" name="entry" value="${esc(e.entry)}">
- <button type="submit">${icon("arrow-counter-clockwise")}restore</button>
+ <button type="submit">${icon("rotate-ccw")}restore</button>
</form>
</td>
<td>
<form method="post" action="/settings/deleted/purge" data-confirm="Permanently delete ${esc(e.name)}? This destroys the git data and cannot be undone.">
<input type="hidden" name="entry" value="${esc(e.entry)}">
- <button type="submit">${icon("trash")}delete permanently</button>
+ <button type="submit">${icon("trash-2")}delete permanently</button>
</form>
</td>
</tr>`;
@@ -1042,7 +1042,7 @@ export function deletedPage(opts: {
? `Deleted repositories are kept for ${opts.retentionDays} days, then purged the next time you open this page.`
: `Deleted repositories are kept indefinitely — nothing is purged unless you do it here.`;
- const body = ` <h2 class="section-title">${icon("trash")}recently deleted</h2>
+ const body = ` <h2 class="section-title">${icon("trash-2")}recently deleted</h2>
<p class="muted">${esc(retention)} A deleted repository keeps its name reserved, so
nothing new can take it until it is restored or purged.</p>
${table(["repository", "deleted", "by", "retention", "", ""], rows, "nothing deleted")}`;
diff --git a/test/icons.test.mjs b/test/icons.test.mjs
index 59dfb38..967731d 100644
--- a/test/icons.test.mjs
+++ b/test/icons.test.mjs
@@ -12,43 +12,50 @@ function check(label, cond) {
const names = [
"git-branch",
- "git-commit",
+ "git-commit-horizontal",
"git-merge",
"folder",
"folder-plus",
+ "file",
"file-text",
- "article",
- "note",
- "label",
+ "newspaper",
+ "sticky-note",
+ "tag",
"lock",
- "unlock",
+ "lock-open",
"user",
"users",
"user-plus",
- "user-x",
+ "user-minus",
"key",
- "gear",
- "sliders",
- "login",
- "logout",
- "home",
+ "settings",
+ "sliders-horizontal",
+ "log-in",
+ "log-out",
+ "house",
"link",
- "discord",
- "github",
- "cloud-server",
+ "message-circle",
+ "globe",
+ "hard-drive",
"download",
"upload",
- "reload",
- "undo",
+ "refresh-cw",
+ "rotate-ccw",
"save",
- "trash",
+ "trash-2",
"plus",
- "close",
+ "x",
"check",
"clock",
"hourglass",
- "warning-diamond",
- "circle-question",
+ "triangle-alert",
+ "octagon-alert",
+ "circle-help",
+ "info",
+ "lightbulb",
+ "flag",
+ "snowflake",
+ "wind",
"arrow-up",
"arrow-down",
"arrow-left",
@@ -58,7 +65,7 @@ const names = [
for (const name of names) {
const svg = icon(name);
check(`${name} renders one svg`, (svg.match(/<svg /g) ?? []).length === 1);
- check(`${name} has at least one path`, svg.includes("<path "));
+ check(`${name} has a drawable shape`, /<(path|circle|rect|line|polyline|polygon|ellipse) /.test(svg));
}
check(
@@ -83,7 +90,15 @@ check(
);
check(
"colour is inherited, not hard-coded",
- !icon("git-branch").includes("fill="),
+ icon("git-branch").includes('stroke="currentColor"') && !/#[0-9a-f]{3,6}/i.test(icon("git-branch")),
+);
+check(
+ "stroke width is 2.25px at the default size",
+ icon("folder").includes('stroke-width="3.375"'),
+);
+check(
+ "stroke width stays 2.25px at other sizes",
+ icon("folder", 24).includes('stroke-width="2.25"') && icon("folder", 12).includes('stroke-width="4.5"'),
);
let threw = false;