From ec834e4d11bc8a040f2be76596adf07f452966b3 Mon Sep 17 00:00:00 2001 From: NiallJoeMaher Date: Tue, 24 Nov 2026 07:48:26 +0000 Subject: [PATCH] The avatar is one letter on Pluck green MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was two letters cut from the name or, with no name, from the email's parts ("NC" for n…@c…), on grey. Now the first letter of the name, or of the email until there is one, on the brand green: the iPhone's Inbox and Settings, and the web's rail. One helper for all three; the grey avatar token goes. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Chg7BD2Sf1yNRFCX24or7B Signed-off-by: NiallJoeMaher --- apps/ios/app/settings.tsx | 5 ++--- apps/ios/components/ItemsScreen.tsx | 9 +++------ apps/ios/lib/theme.ts | 4 ++-- apps/web/components/AppShell.module.css | 2 +- apps/web/components/AppShell.tsx | 3 ++- apps/web/lib/format.ts | 2 +- packages/shared-schemas/src/format.test.ts | 11 ++++++++++- packages/shared-schemas/src/format.ts | 3 +++ packages/ui/src/tokens.css | 1 - 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/apps/ios/app/settings.tsx b/apps/ios/app/settings.tsx index b0f771b9..ac52addc 100644 --- a/apps/ios/app/settings.tsx +++ b/apps/ios/app/settings.tsx @@ -1,5 +1,5 @@ import { LOCALE_NAMES } from "@pluck/i18n"; -import type { AiConnection, Me, Settings as UserSettings } from "@pluck/shared-schemas"; +import { initial, type AiConnection, type Me, type Settings as UserSettings } from "@pluck/shared-schemas"; import { Refused } from "@pluck/client"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import * as Application from "expo-application"; @@ -76,7 +76,6 @@ export default function Settings({ part }: { part?: Part }) { const host = new URL(server).host; const profile = me.data; const settings = profile?.settings; - const initials = ((profile?.name || profile?.email || "?").split(/[\s@.]+/).filter(Boolean).slice(0, 2).map((w) => w[0]!.toUpperCase()).join("")) || "?"; const needsAccount = tools.error instanceof Refused && tools.error.status === 403; // Sunday first, as digestDay counts: 7 Jan 2024 was a Sunday. const days = [0, 1, 2, 3, 4, 5, 6].map((d) => format.dateTime(new Date(2024, 0, 7 + d), { weekday: "long" })); @@ -215,7 +214,7 @@ export default function Settings({ part }: { part?: Part }) { {section(tr("sections.account"))} - {initials} + {initial(profile?.name, profile?.email)} {profile?.name || tr("yourAccount")} {profile?.email ?? session?.email ?? ""} diff --git a/apps/ios/components/ItemsScreen.tsx b/apps/ios/components/ItemsScreen.tsx index 9790c8a5..e2b85dba 100644 --- a/apps/ios/components/ItemsScreen.tsx +++ b/apps/ios/components/ItemsScreen.tsx @@ -1,4 +1,4 @@ -import { isTask, type Item, type Status } from "@pluck/shared-schemas"; +import { initial, isTask, type Item, type Status } from "@pluck/shared-schemas"; import { useQueryClient } from "@tanstack/react-query"; import * as Haptics from "expo-haptics"; import { router, useFocusEffect, usePathname } from "expo-router"; @@ -18,9 +18,6 @@ import { Empty, TitledList, usePull } from "./Screen"; import { toast } from "./Toast"; import { ToolBar } from "./ToolBar"; -const avatarOf = (name?: string, email?: string) => - ((name?.trim() || email || "?").split(/[\s@.]+/).filter(Boolean).slice(0, 2).map((w) => w[0]!.toUpperCase()).join("") || "?"); - // Inbox and Later (IOSInbox board): the count, what is waiting to sync, and the rows. export function ItemsScreen({ status }: { status: "inbox" | "later" }) { const t = useTheme(); @@ -182,8 +179,8 @@ export function ItemsScreen({ status }: { status: "inbox" | "later" }) { router.push("/settings")} accessibilityRole="button" accessibilityLabel={tr("items.settings")} style={styles.headerButton}> - - {avatarOf(me.data?.name, me.data?.email)} + + {initial(me.data?.name, me.data?.email)} diff --git a/apps/ios/lib/theme.ts b/apps/ios/lib/theme.ts index a78cfc19..dda583f4 100644 --- a/apps/ios/lib/theme.ts +++ b/apps/ios/lib/theme.ts @@ -4,7 +4,7 @@ import { useColorScheme } from "react-native"; export const palettes = { light: { ground: "#F6F8F4", rail: "#EDF0EA", railActive: "#DFE4DA", tint: "#E6EBE2", selected: "#E6EBE2", surface: "#FFFFFF", field: "#EBEEE7", - chip: "#E3E8DE", avatar: "#D6DCD0", line: "#DDE2D8", lineStrong: "#CDD3C7", lineDashed: "#C3CABC", ink: "#151A13", ink2: "#525A4E", + chip: "#E3E8DE", line: "#DDE2D8", lineStrong: "#CDD3C7", lineDashed: "#C3CABC", ink: "#151A13", ink2: "#525A4E", brand: "#1E5C45", onBrand: "#F6F8F4", accent: "#34A07C", highlight: "#7FD3AE", highlightWash: "#C9EEDC", clay: "#9A5536", syncBg: "#F1E6D9", syncInk: "#7A4520", syncDot: "#9A5536", danger: "#A3341F", tiles: ["#E1E6CF", "#E6DCD6", "#DCE1E3", "#E2E6DA", "#DFE2DC", "#DDE3D9"], @@ -17,7 +17,7 @@ export const palettes = { }, dark: { ground: "#10130F", rail: "#161A14", railActive: "#252A22", tint: "#191D17", selected: "#1E221C", surface: "#191D17", field: "#191D17", - chip: "#252A22", avatar: "#252A22", line: "#2A2F27", lineStrong: "#363C33", lineDashed: "#3A4036", ink: "#ECEFE8", ink2: "#A0A898", + chip: "#252A22", line: "#2A2F27", lineStrong: "#363C33", lineDashed: "#3A4036", ink: "#ECEFE8", ink2: "#A0A898", brand: "#1E5C45", onBrand: "#F6F8F4", accent: "#34A07C", highlight: "#7FD3AE", highlightWash: "#24493A", clay: "#D08A68", syncBg: "#3A2A1C", syncInk: "#E8B88E", syncDot: "#D08A68", danger: "#E07A62", tiles: ["#263020", "#33302A", "#26292B", "#292E25", "#2A2A26", "#20251E"], diff --git a/apps/web/components/AppShell.module.css b/apps/web/components/AppShell.module.css index 38c1a34f..2d2efb64 100644 --- a/apps/web/components/AppShell.module.css +++ b/apps/web/components/AppShell.module.css @@ -16,7 +16,7 @@ .link[aria-current="page"] .count { color: var(--action-ink); } .me { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 0 8px; color: var(--ink2); } .avatar { - width: 28px; height: 28px; border-radius: 14px; background: var(--avatar); color: var(--ink); + width: 28px; height: 28px; border-radius: 14px; background: var(--brand); color: var(--on-brand); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; } .meName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } diff --git a/apps/web/components/AppShell.tsx b/apps/web/components/AppShell.tsx index efaeaaaf..1f395c64 100644 --- a/apps/web/components/AppShell.tsx +++ b/apps/web/components/AppShell.tsx @@ -3,6 +3,7 @@ import { useTranslations } from "next-intl"; import Link from "next/link"; import type { ReactNode } from "react"; import type { SessionUser } from "@/lib/auth"; +import { initial } from "@/lib/format"; import { OfflineBar, OfflineMark } from "./Offline"; import { RailNav } from "./RailNav"; import { TimezoneSync } from "./TimezoneSync"; @@ -22,7 +23,7 @@ export function AppShell({ user, counts, timezone, children }: { user: SessionUs
{display}
diff --git a/apps/web/lib/format.ts b/apps/web/lib/format.ts index 584b621e..cf56967d 100644 --- a/apps/web/lib/format.ts +++ b/apps/web/lib/format.ts @@ -1,5 +1,5 @@ // Row formatting lives in shared-schemas (the iOS app uses it too); the web-only URLs are here. -export { initials, tileIndex } from "@pluck/shared-schemas"; +export { initial, initials, tileIndex } from "@pluck/shared-schemas"; export const coverSrc = (id: string) => `/api/v1/items/${id}/cover`; export const waybackUrl = (url: string) => `https://web.archive.org/web/*/${url}`; diff --git a/packages/shared-schemas/src/format.test.ts b/packages/shared-schemas/src/format.test.ts index ca761cf4..f798d5f6 100644 --- a/packages/shared-schemas/src/format.test.ts +++ b/packages/shared-schemas/src/format.test.ts @@ -1,6 +1,6 @@ import { expect, test } from "vitest"; import type { Item } from "./items.ts"; -import { initials, listMarkWord, markWord, rowSite, tileIndex, when } from "./format.ts"; +import { initial, initials, listMarkWord, markWord, rowSite, tileIndex, when } from "./format.ts"; const now = new Date(2026, 9, 24, 15, 0); // Sat 24 Oct 2026, 15:00 @@ -16,6 +16,15 @@ test.each([ expect(when(d.toISOString(), now)).toBe(expected); }); +test.each([ + ["Aoife Byrne", "aoife@example.test", "A"], + [" ", "niall@example.test", "N"], + [null, "élan@example.test", "É"], + [undefined, undefined, "?"], +])("initial(%s, %s) is %s", (name, email, expected) => { + expect(initial(name, email)).toBe(expected); +}); + test.each([ ["YouTube", "https://www.youtube.com/watch?v=1", "YT"], ["X (formerly Twitter)", "https://x.com/a/status/1", "X"], diff --git a/packages/shared-schemas/src/format.ts b/packages/shared-schemas/src/format.ts index a96b3aee..7b005f87 100644 --- a/packages/shared-schemas/src/format.ts +++ b/packages/shared-schemas/src/format.ts @@ -69,6 +69,9 @@ export function rowMeta(item: Item, now = new Date()): string { const KNOWN: Record = { "youtube.com": "YT", "youtu.be": "YT", "x.com": "X", "twitter.com": "X", "github.com": "GH" }; +// The one letter in someone's avatar: of their name, or of their email until they give one. +export const initial = (name?: string | null, email?: string | null): string => [...(name?.trim() || email?.trim() || "?")][0]!.toUpperCase(); + // Site initials for the 40px tile when there is no cover. export function initials(siteName: string | null, url: string | null): string { const host = url ? new URL(url).hostname.replace(/^www\./, "") : ""; diff --git a/packages/ui/src/tokens.css b/packages/ui/src/tokens.css index 2f390006..4595a1e4 100644 --- a/packages/ui/src/tokens.css +++ b/packages/ui/src/tokens.css @@ -11,7 +11,6 @@ --surface: light-dark(#FFFFFF, #191D17); --field: light-dark(#EBEEE7, #191D17); --chip: light-dark(#E3E8DE, #252A22); - --avatar: light-dark(#D6DCD0, #252A22); --line: light-dark(#DDE2D8, #2A2F27); --line-strong: light-dark(#CDD3C7, #363C33); --line-dashed: light-dark(#C3CABC, #3A4036);