Skip to content
Merged
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
5 changes: 2 additions & 3 deletions apps/ios/app/settings.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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" }));
Expand Down Expand Up @@ -215,7 +214,7 @@ export default function Settings({ part }: { part?: Part }) {
{section(tr("sections.account"))}
<View style={card}>
<View style={[styles.account, { borderBottomColor: t.tint }]}>
<View style={[styles.avatar, { backgroundColor: t.avatar }]}><Text maxFontSizeMultiplier={scale.badge} style={[font.semibold, { color: t.ink, fontSize: 13 }]}>{initials}</Text></View>
<View style={[styles.avatar, { backgroundColor: t.brand }]}><Text maxFontSizeMultiplier={scale.badge} style={[font.semibold, { color: t.onBrand, fontSize: 15 }]}>{initial(profile?.name, profile?.email)}</Text></View>
<View style={{ flex: 1, minWidth: 0 }}>
<Text style={[font.semibold, { color: t.ink, fontSize: 15 }]}>{profile?.name || tr("yourAccount")}</Text>
<Text style={[font.regular, { color: t.ink2, fontSize: 13 }]}>{profile?.email ?? session?.email ?? ""}</Text>
Expand Down
9 changes: 3 additions & 6 deletions apps/ios/components/ItemsScreen.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Expand Down Expand Up @@ -182,8 +179,8 @@ export function ItemsScreen({ status }: { status: "inbox" | "later" }) {
<Icon d={ICONS.plus} color={t.ink} />
</Pressable>
<Pressable onPress={() => router.push("/settings")} accessibilityRole="button" accessibilityLabel={tr("items.settings")} style={styles.headerButton}>
<View style={[styles.avatar, { backgroundColor: t.avatar }]}>
<Text maxFontSizeMultiplier={scale.badge} style={[font.semibold, { color: t.ink, fontSize: 12 }]}>{avatarOf(me.data?.name, me.data?.email)}</Text>
<View style={[styles.avatar, { backgroundColor: t.brand }]}>
<Text maxFontSizeMultiplier={scale.badge} style={[font.semibold, { color: t.onBrand, fontSize: 13 }]}>{initial(me.data?.name, me.data?.email)}</Text>
</View>
</Pressable>
</View>
Expand Down
4 changes: 2 additions & 2 deletions apps/ios/lib/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/AppShell.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 2 additions & 1 deletion apps/web/components/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -22,7 +23,7 @@ export function AppShell({ user, counts, timezone, children }: { user: SessionUs
<RailNav counts={counts} />
<div className={styles.me}>
<span className={styles.avatar} aria-hidden="true">
{display.slice(0, 2).toUpperCase()}
{initial(user.name, user.email)}
</span>
<span className={styles.meName}>{display}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/format.ts
Original file line number Diff line number Diff line change
@@ -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}`;
11 changes: 10 additions & 1 deletion packages/shared-schemas/src/format.test.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -16,6 +16,15 @@ test.each([
expect(when(d.toISOString(), now)).toBe(expected);
});

test.each([
["Aoife Byrne", "[email protected]", "A"],
[" ", "[email protected]", "N"],
[null, "é[email protected]", "É"],
[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"],
Expand Down
3 changes: 3 additions & 0 deletions packages/shared-schemas/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export function rowMeta(item: Item, now = new Date()): string {

const KNOWN: Record<string, string> = { "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\./, "") : "";
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading