Open History to see the last commit
1import { Check } from "lucide-react";
2
3import type { Note } from "@/fixtures";
4import { parseNoteBody } from "@/lib/notes/note-body";
5import { cn } from "@/lib/utils";
6
7interface NoteContentProps {
8 note: Note;
9 /** `mac` uses desktop type sizes, `ios` the larger iPhone ones. */
10 variant: "mac" | "ios";
11}
12
13/** Renders a note the way the Notes editor does: Title style first line, then blocks. */
14export function NoteContent({ note, variant }: NoteContentProps) {
15 const blocks = parseNoteBody(note.body);
16 const ios = variant === "ios";
17
18 return (
19 <div className={cn(ios ? "text-[17px] leading-[1.45]" : "text-[13.5px] leading-[1.5]")}>
20 <h1
21 className={cn(
22 "font-bold tracking-[-0.01em]",
23 ios ? "mb-1.5 text-[28px] leading-tight" : "mb-1 text-[22px] leading-tight",
24 )}
25 >
26 {note.title}
27 </h1>
28 {blocks.map((block, index) => {
29 switch (block.type) {
30 case "heading":
31 return (
32 <h2
33 key={index}
34 className={cn("font-bold", ios ? "mt-3 text-[20px]" : "mt-2.5 text-[17px]")}
35 >
36 {block.text}
37 </h2>
38 );
39 case "bullet":
40 return (
41 <p key={index} className="flex gap-2 pl-1">
42 <span aria-hidden>•</span>
43 <span>{block.text}</span>
44 </p>
45 );
46 case "checklist":
47 return (
48 <p
49 key={index}
50 className={cn("flex items-center", ios ? "gap-3 py-1" : "gap-2 py-px")}
51 >
52 <ChecklistCircle checked={block.checked} large={ios} />
53 <span className={cn(block.checked && "text-mac-text-secondary line-through")}>
54 {/* Read-only for now; phase 2 turns these into real, labelled checkboxes. */}
55 <span className="sr-only">{block.checked ? "Done: " : "To do: "}</span>
56 {block.text}
57 </span>
58 </p>
59 );
60 case "paragraph":
61 return <p key={index}>{block.text}</p>;
62 }
63 })}
64 </div>
65 );
66}
67
68function ChecklistCircle({ checked, large }: { checked: boolean; large: boolean }) {
69 return (
70 <span
71 aria-hidden
72 className={cn(
73 "grid shrink-0 place-items-center rounded-full",
74 large ? "size-[24px]" : "size-[16px]",
75 checked
76 ? "bg-notes-accent text-white"
77 : "border-[1.5px] border-[#b5b5b8] dark:border-[#5c5c60]",
78 )}
79 >
80 {checked && <Check className="size-[65%]" strokeWidth={3} />}
81 </span>
82 );
83}