A note was still a rectangle with a strip and a footer, so it read as another technology with an amber accent. Give it its own silhouette instead: warm paper fill, chunky dashed border, a vertical NOTE rail in place of the classification strip, a folded top-right corner, no corner brackets and no readout footer, with the published/internal state moved into the body. The differences that matter at fit-view zoom are the fill and the dashed edge, since the text is illegible there and colour is all that separates the two node kinds. Documents the contract in the tech-tree AGENTS.md so it does not get harmonised back to tech-card chrome.
94 lines
3.8 KiB
TypeScript
94 lines
3.8 KiB
TypeScript
"use client";
|
|
|
|
import type { Node, NodeProps } from "@xyflow/react";
|
|
import React from "react";
|
|
|
|
import type { TreeNote } from "./types";
|
|
|
|
export type NoteNodeData = {
|
|
note: TreeNote;
|
|
/** Editor-only controls are handled by the canvas; the card stays read-only. */
|
|
connectable?: boolean;
|
|
};
|
|
|
|
export type NoteNodeModel = Node<NoteNodeData, "noteCard">;
|
|
|
|
/**
|
|
* Memo card for canvas annotations.
|
|
*
|
|
* Deliberately a different silhouette from a technology card, not just a
|
|
* different accent colour: no classification strip, no readout footer, no
|
|
* corner brackets, a dashed amber border, a warm paper-tinted fill and a
|
|
* vertical rail label. At fit-view zoom (where the text is illegible) the warm
|
|
* tint and dashed edge are what separate it from the near-black tech cards; up
|
|
* close the vertical NOTE rail and folded corner do. It has no handles either,
|
|
* so it can never become a prerequisite endpoint.
|
|
*/
|
|
export function NoteNodeCard({ data, selected }: NodeProps<NoteNodeModel>) {
|
|
const { note } = data;
|
|
|
|
return (
|
|
<div data-testid={`tech-note-${note.id}`} className="relative h-full w-full">
|
|
<div
|
|
className={`relative flex h-full w-full overflow-hidden border border-dashed bg-[#1b1409]/95 backdrop-blur-sm transition-colors ${
|
|
selected
|
|
? "border-amber-300 shadow-[0_0_20px_rgba(251,191,36,0.22)]"
|
|
: "border-amber-400/55 hover:border-amber-300/80"
|
|
}`}
|
|
>
|
|
{/* Folded corner: the page-coloured triangle reads as a peeled note,
|
|
which no technology card has. */}
|
|
<span
|
|
aria-hidden
|
|
className="pointer-events-none absolute top-0 right-0 size-3.5 bg-[#05070a]"
|
|
style={{ clipPath: "polygon(100% 0%, 0% 0%, 100% 100%)" }}
|
|
/>
|
|
|
|
{/* Vertical rail label instead of a horizontal classification strip */}
|
|
<div className="flex w-[22px] shrink-0 flex-col items-center justify-between border-r border-dashed border-amber-400/40 bg-amber-400/10 py-2">
|
|
<span className="font-mono text-[8px] tracking-[0.25em] text-amber-200/70 uppercase [writing-mode:vertical-rl]">
|
|
Note
|
|
</span>
|
|
<span
|
|
aria-hidden
|
|
className={`size-1.5 shrink-0 rounded-full ${
|
|
note.showOnFrontend
|
|
? "bg-emerald-300/80 shadow-[0_0_6px_rgba(110,231,183,0.55)]"
|
|
: "bg-amber-300/50"
|
|
}`}
|
|
/>
|
|
</div>
|
|
|
|
{/* Body: the title keeps a fixed two-line slot and the detail text takes
|
|
whatever height is left, so a long title can never clip the body to
|
|
nothing (the card height is fixed by the canvas). */}
|
|
<div className="flex min-h-0 min-w-0 flex-1 flex-col px-3 py-2">
|
|
<div className="line-clamp-2 shrink-0 text-[13px] leading-tight font-semibold text-amber-50">
|
|
{note.title}
|
|
</div>
|
|
{note.body.trim() ? (
|
|
<p className="mt-1 min-h-0 flex-1 overflow-hidden text-[10px] leading-snug whitespace-pre-wrap text-amber-100/55">
|
|
{note.body}
|
|
</p>
|
|
) : (
|
|
<p className="mt-1 shrink-0 leading-none font-mono text-[8px] tracking-widest text-amber-100/25 uppercase">
|
|
No details
|
|
</p>
|
|
)}
|
|
<div className="mt-1 flex shrink-0 items-center gap-1.5">
|
|
<span
|
|
className={`font-mono text-[8px] leading-none tracking-widest uppercase ${
|
|
note.showOnFrontend ? "text-emerald-300/80" : "text-amber-200/40"
|
|
}`}
|
|
>
|
|
{note.showOnFrontend ? "Published" : "Internal"}
|
|
</span>
|
|
<span className="font-mono text-[8px] leading-none tracking-widest text-amber-200/25 uppercase">
|
|
// Annotation
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|