Skip to content

Open source CapCut alternative.

TypeScript

fix(site): dim note paper in dark mode

taejs27510d19922a
diff --git a/.claude/skills/ui-quality/references/checks.md b/.claude/skills/ui-quality/references/checks.md
index 6b44908f..177b7b9f 100644
--- a/.claude/skills/ui-quality/references/checks.md
+++ b/.claude/skills/ui-quality/references/checks.md
@@ -8,7 +8,7 @@ The site theme lives in [globals.css](../../../../site/src/app/globals.css). `ba
The root uses the system preference until an explicit `.light` or `.dark` theme is set. Product `.app-surface` pages select `--app-background`, while public light pages use the sand background. Cold-load both kinds of surface. Check explicit light on a dark system and explicit dark on a light system when touching theme selection; exercise a preference change while the page is open.
-`ink`, `cream`, and `coral` are fixed brand colors. Pair fixed pastel cards with their intended ink. The note paper in [NoteComposer](../../../../site/src/cut/components/NoteComposer.tsx) keeps `NOTE_INK`; note text samples select `paper` or `dark` from [noteMarkdown](../../../../site/src/cut/lib/noteMarkdown.ts) according to their menu surface. A dark-themed menu can sit above a light note.
+`ink`, `cream`, and `coral` are fixed brand colors. Pair fixed pastel cards with their intended ink. [Note paper](../../../../site/src/cut/components/notePaper.css) retains stored palette indices, uses muted card tints in dark mode, and adapts named text colors. Verify the sheet, tiles, and portaled menus.
Use [Button](../../../../site/src/components/ui/button.tsx), Input, Dialog, Popover, and DropdownMenu from the same UI directory. They carry focus, invalid, disabled, expanded, portal, and positioning behavior. Compose with `cn` and Tailwind responsive variants. Feature CSS belongs beside its owner; inline styles carry genuinely runtime values, such as data-derived CSS variables.
diff --git a/site/src/cut/components/NoteBodyPreview.tsx b/site/src/cut/components/NoteBodyPreview.tsx
index 5f977ff9..dbb933a5 100644
--- a/site/src/cut/components/NoteBodyPreview.tsx
+++ b/site/src/cut/components/NoteBodyPreview.tsx
@@ -1,4 +1,4 @@
-import { Fragment } from "react";
+import { Fragment, type CSSProperties } from "react";
import { NOTE_TEXT_COLORS, parseNoteBody, type NoteBlock, type NoteRun } from "@/cut/lib/noteMarkdown";
import { cn } from "@/lib/utils";
@@ -38,7 +38,7 @@ export function NoteBodyPreview({ body, lines, className }: { body: string; line
function Runs({ block }: { block: NoteBlock }) {
return block.runs.map((r: NoteRun, i) => {
- const color = r.marks.color ? NOTE_TEXT_COLORS.find((c) => c.id === r.marks.color)?.paper : undefined;
+ const color = r.marks.color ? NOTE_TEXT_COLORS.find((c) => c.id === r.marks.color) : undefined;
const styled = r.marks.bold || r.marks.italic || r.marks.underline || r.marks.strike || color;
if (!styled) return <Fragment key={i}>{r.text}</Fragment>;
return (
@@ -49,7 +49,8 @@ function Runs({ block }: { block: NoteBlock }) {
r.marks.italic && "italic",
r.marks.underline && r.marks.strike ? "[text-decoration-line:underline_line-through]" : r.marks.underline ? "underline" : r.marks.strike && "line-through",
)}
- style={color ? { color } : undefined}
+ data-color={color?.id}
+ style={color ? { color: `var(--note-text-ink, ${color.paper})`, "--note-text-paper": color.paper, "--note-text-dark": color.dark } as CSSProperties : undefined}
>
{r.text}
</span>
diff --git a/site/src/cut/components/NoteComposer.tsx b/site/src/cut/components/NoteComposer.tsx
index 2a470e59..e1f8d96a 100644
--- a/site/src/cut/components/NoteComposer.tsx
+++ b/site/src/cut/components/NoteComposer.tsx
@@ -19,8 +19,7 @@ import { NOTE_COLORS, noteColor, type CutNoteLabel } from "@/cut/lib/notes";
import { NOTE_LABELS_MAX } from "@/cut/lib/types";
import { cn } from "@/lib/utils";
-// The note paper's ink, matching the iOS app.
-const NOTE_INK = "#201a0d";
+import "./notePaper.css";
// The rich text editor loads with the first note opened, off the list's own
// bundle.
@@ -200,17 +199,13 @@ export function NoteComposer({
aria-modal="true"
aria-label={draft.title.trim() || "Untitled note"}
{...KEEP_EVENTS}
- className="fixed inset-0 z-50 flex flex-col font-system antialiased"
- style={{ backgroundColor: paper.background, color: NOTE_INK }}
+ className="note-paper fixed inset-0 z-50 flex flex-col font-system antialiased"
+ style={{ "--note-paper-background": paper.background, "--note-accent": paper.accent } as React.CSSProperties}
>
- <header
- className="flex shrink-0 items-center gap-2 px-6 py-3"
- style={{ backgroundColor: paper.background }}
- >
+ <header className="flex shrink-0 items-center gap-2 px-6 py-3">
<Button
variant="ghost"
- className="hover:bg-black/5 hover:text-current"
- style={{ color: NOTE_INK }}
+ className="hover:bg-black/5 hover:text-current dark:hover:bg-white/5"
onClick={onClose}
>
<ArrowLeft data-icon="inline-start" />{" "}
@@ -223,8 +218,7 @@ export function NoteComposer({
<Button
variant="ghost"
aria-label="Note color"
- className="hover:bg-black/5 hover:text-current"
- style={{ color: NOTE_INK }}
+ className="hover:bg-black/5 hover:text-current dark:hover:bg-white/5"
/>
}
>
@@ -255,7 +249,7 @@ export function NoteComposer({
<Button
variant="ghost"
aria-label="Delete note"
- className="text-destructive hover:bg-black/5 hover:text-destructive"
+ className="text-destructive hover:bg-black/5 hover:text-destructive dark:hover:bg-white/5"
onClick={onDelete}
>
<Trash2 data-icon="inline-start" /> Delete
@@ -274,7 +268,6 @@ export function NoteComposer({
value={draft.title}
placeholder="Untitled"
className="resize-none overflow-hidden bg-transparent text-4xl leading-tight font-semibold tracking-tight outline-none placeholder:text-current placeholder:opacity-60"
- style={{ color: NOTE_INK }}
onChange={(e) => onChange({ ...draft, title: e.target.value.replace(/\n/g, "") })}
onKeyDown={(e) => {
if (e.key === "Enter") {
@@ -289,7 +282,7 @@ export function NoteComposer({
{worn.map((l) => (
<button
key={l.id}
- className="group flex cursor-pointer items-center gap-1 rounded-full bg-black/10 px-2.5 py-1 text-xs font-medium hover:bg-black/15"
+ className="group flex cursor-pointer items-center gap-1 rounded-full bg-black/10 px-2.5 py-1 text-xs font-medium hover:bg-black/15 dark:bg-white/10 dark:hover:bg-white/15"
aria-label={`Remove label ${l.name}`}
onClick={() => toggleLabel(l.id)}
>
@@ -301,7 +294,7 @@ export function NoteComposer({
<PopoverTrigger
render={
<button
- className="flex cursor-pointer items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium opacity-70 hover:bg-black/10 hover:opacity-80"
+ className="flex cursor-pointer items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium opacity-70 hover:bg-black/10 hover:opacity-80 dark:hover:bg-white/10"
aria-label="Add label"
/>
}
@@ -323,7 +316,7 @@ export function NoteComposer({
</div>
<NoteBodyEditor
body={draft.body}
- ink={NOTE_INK}
+ ink="currentColor"
onChange={(text) => onChange({ ...draftRef.current, body: text })}
onEditor={(editor) => (body.current = editor)}
/>
diff --git a/site/src/cut/components/NotesView.tsx b/site/src/cut/components/NotesView.tsx
index ff054f08..dbbc160a 100644
--- a/site/src/cut/components/NotesView.tsx
+++ b/site/src/cut/components/NotesView.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useEffect, useImperativeHandle, useRef, useState, type Ref } from "react";
+import { useEffect, useImperativeHandle, useRef, useState, type Ref, type CSSProperties } from "react";
import { useSearchParams } from "next/navigation";
import { useQueryClient, type QueryClient } from "@tanstack/react-query";
import { FolderPlus, Loader2, Plus, StickyNote, Trash2 } from "lucide-react";
@@ -39,8 +39,7 @@ import { LIBRARY_SQUARE } from "./LibraryCard";
import { NoteComposer, noteChanged, type NoteDraft } from "./NoteComposer";
import { NoteBodyPreview } from "./NoteBodyPreview";
-// The note paper's ink, matching the iOS app.
-const NOTE_INK = "#201a0d";
+import "./notePaper.css";
// A dragged selection of notes, the same shape the library and the projects
// home carry: a JSON array of ids under this page's own MIME type.
@@ -743,17 +742,17 @@ export function NotesView({ library, ref }: Props = {}) {
onDragStart={(e) => onCardDragStart(e, n.id)}
onDragEnd={clearRefDrag}
className={cn(
- "flex cursor-pointer flex-col gap-1.5 text-left shadow-sm",
+ "note-paper flex cursor-pointer flex-col gap-1.5 text-left shadow-sm",
// A note is a file like the rest: the same square a sound
// tile is, here and in the Library.
"overflow-hidden rounded-xl p-3",
)}
style={{
- backgroundColor: noteColor(n.colorIndex).background,
- color: NOTE_INK,
+ "--note-paper-background": noteColor(n.colorIndex).background,
+ "--note-accent": noteColor(n.colorIndex).accent,
width: LIBRARY_SQUARE,
height: LIBRARY_SQUARE,
- }}
+ } as CSSProperties}
onClick={(e) => {
if (!additiveClick(e)) {
openNote(n);
@@ -765,13 +764,13 @@ export function NotesView({ library, ref }: Props = {}) {
>
{/* Clear of the actions button that takes the corner on hover. */}
{n.title && <div className="truncate pr-6 text-[13px] font-semibold">{n.title}</div>}
- <NoteBodyPreview body={n.body} lines={5} className="text-[12px] opacity-80" />
+ <NoteBodyPreview body={n.body} lines={5} className="text-[12px] opacity-80 dark:opacity-100" />
{worn.length > 0 && (
<div className="mt-auto flex flex-wrap gap-1 pt-1.5">
{worn.map((name) => (
<span
key={name}
- className="rounded-full bg-black/10 px-2 py-0.5 text-[11px] font-medium"
+ className="rounded-full bg-black/10 px-2 py-0.5 text-[11px] font-medium dark:bg-white/10"
>
{name}
</span>
diff --git a/site/src/cut/components/notePaper.css b/site/src/cut/components/notePaper.css
new file mode 100644
index 00000000..84208d2a
--- /dev/null
+++ b/site/src/cut/components/notePaper.css
@@ -0,0 +1,22 @@
+@reference "../../app/globals.css";
+
+/* Stored paper colors stay shared with iOS; dark paper keeps a quiet tint. */
+.note-paper {
+ background-color: var(--note-paper-background);
+ color: #201a0d;
+}
+
+.note-paper [data-color] {
+ --note-text-ink: var(--note-text-paper);
+}
+
+@variant dark {
+ .note-paper {
+ background-color: color-mix(in srgb, var(--card) 94%, var(--note-accent) 6%);
+ color: var(--card-foreground);
+ }
+
+ .note-paper [data-color] {
+ --note-text-ink: color-mix(in srgb, var(--note-text-dark) 75%, white 25%);
+ }
+}
diff --git a/site/src/cut/components/notePaper.test.tsx b/site/src/cut/components/notePaper.test.tsx
new file mode 100644
index 00000000..6c63e2ec
--- /dev/null
+++ b/site/src/cut/components/notePaper.test.tsx
@@ -0,0 +1,54 @@
+import { expect, test } from "bun:test";
+import { readFileSync } from "node:fs";
+import postcss from "postcss";
+import { renderToStaticMarkup } from "react-dom/server";
+import { parseHTML } from "linkedom";
+import { DOMSerializer } from "@tiptap/pm/model";
+import { getSchema } from "@tiptap/core";
+import StarterKit from "@tiptap/starter-kit";
+import { NOTE_COLORS, noteColor } from "@/cut/lib/notes";
+import { NOTE_TEXT_COLORS, parseNoteBody } from "@/cut/lib/noteMarkdown";
+import { docOf, TextColor } from "@/cut/lib/noteDoc";
+import { NoteBodyPreview } from "./NoteBodyPreview";
+
+// Saved palette indices keep their paper colors while CSS adapts the surface.
+test("note palette indices retain the shared iOS colors", () => {
+ expect(NOTE_COLORS.map((c) => [c.name, c.background])).toEqual([
+ ["Butter", "#faefb6"], ["Blush", "#fbd8d4"], ["Sky", "#d5e8fb"],
+ ["Mint", "#d9f3d6"], ["Lilac", "#e6dcf7"],
+ ]);
+ expect(noteColor(-1)).toBe(NOTE_COLORS[4]);
+ expect(noteColor(5)).toBe(NOTE_COLORS[0]);
+});
+
+test("dark note paper pairs a muted card tint with its foreground", () => {
+ const css = postcss.parse(readFileSync(new URL("./notePaper.css", import.meta.url), "utf8"));
+ const dark = new Map<string, string>();
+ css.walkAtRules("variant", (rule) => {
+ if (rule.params === "dark") {
+ rule.walkDecls((decl) => { dark.set(decl.prop, decl.value); });
+ }
+ });
+ expect(dark.get("background-color")).toBe("color-mix(in srgb, var(--card) 94%, var(--note-accent) 6%)");
+ expect(dark.get("color")).toBe("var(--card-foreground)");
+ expect(dark.get("--note-text-ink")).toBe("color-mix(in srgb, var(--note-text-dark) 75%, white 25%)");
+});
+
+test("editor and tile text colors retain named marks and theme palettes", () => {
+ const schema = getSchema([StarterKit.configure({ link: false }), TextColor]);
+ const serializer = DOMSerializer.fromSchema(schema);
+ for (const color of NOTE_TEXT_COLORS) {
+ const body = `<span color="${color.id}">Readable color</span>`;
+ const { document } = parseHTML("<html><body></body></html>");
+ const node = schema.nodeFromJSON(docOf(parseNoteBody(body)));
+ const container = document.createElement("div");
+ container.appendChild(serializer.serializeFragment(node.content, { document }));
+ const preview = parseHTML(renderToStaticMarkup(<NoteBodyPreview body={body} lines={2} />)).document;
+ for (const span of [container.querySelector("[data-color]"), preview.querySelector("[data-color]")]) {
+ expect(span?.getAttribute("data-color")).toBe(color.id);
+ expect(span?.getAttribute("style")).toContain("var(--note-text-ink,");
+ expect(span?.getAttribute("style")).toContain(color.paper);
+ expect(span?.getAttribute("style")).toContain(color.dark);
+ }
+ }
+});
diff --git a/site/src/cut/lib/noteDoc.ts b/site/src/cut/lib/noteDoc.ts
index fbde0a82..7d0a462c 100644
--- a/site/src/cut/lib/noteDoc.ts
+++ b/site/src/cut/lib/noteDoc.ts
@@ -198,8 +198,7 @@ function cutLine(tr: Transaction, pos: number): number | null {
return base + before;
}
-/** A named text color. The name is what the body stores; the ink is the
- * paper's. */
+/** A named text color. The stored name carries paper and dark display inks. */
export const TextColor = Mark.create({
name: "textColor",
addAttributes() {
@@ -207,10 +206,13 @@ export const TextColor = Mark.create({
color: {
default: null,
parseHTML: (el) => el.getAttribute("data-color"),
- renderHTML: (attrs) => ({
- "data-color": attrs.color,
- style: `color: ${NOTE_TEXT_COLORS.find((c) => c.id === attrs.color)?.paper ?? "inherit"}`,
- }),
+ renderHTML: (attrs) => {
+ const color = NOTE_TEXT_COLORS.find((c) => c.id === attrs.color);
+ return {
+ "data-color": attrs.color,
+ style: color ? `color: var(--note-text-ink, ${color.paper}); --note-text-paper: ${color.paper}; --note-text-dark: ${color.dark}` : undefined,
+ };
+ },
},
};
},