Comment pins
Numbered markers, open or resolved, placed over a canvas from world positions, each opening a thread.
import { CommentPin, PinLayer, editorProject, editorUnproject } from "@forgeron/ui";import { CommentPin } from "@forgeron/ui";
export default function Default() {
return (
<div style={{ display: "flex", gap: 24, alignItems: "center", padding: "8px 0 14px" }}>
<div style={{ position: "relative", width: 28, height: 28 }}>
<CommentPin number={1} />
</div>
<div style={{ position: "relative", width: 28, height: 28 }}>
<CommentPin number={12} unread />
</div>
<div style={{ position: "relative", width: 28, height: 28 }}>
<CommentPin number={3} state="resolved" />
</div>
<div style={{ position: "relative", width: 28, height: 28 }}>
<CommentPin number={4} active />
</div>
</div>
);
}import { Button, PinLayer, type EditorPinData } from "@forgeron/ui";
import { useState } from "react";
const pins: EditorPinData[] = [
{ id: "p1", x: 80, y: 90, author: "Léa", preview: "Can the title be bigger?", unread: true },
{ id: "p2", x: 300, y: 150, author: "Karim", preview: "Colour is off here." },
{ id: "p3", x: 190, y: 220, author: "Jo", preview: "Done, thanks.", resolved: true },
];
export default function PinLayerDemo() {
const [view, setView] = useState({ x: 0, y: 0, zoom: 1 });
const [hide, setHide] = useState(false);
return (
<div
style={{ display: "flex", flexDirection: "column", gap: 12, width: "100%", maxWidth: 520 }}
>
<div style={{ display: "flex", gap: 8 }}>
<Button size="sm" onClick={() => setView((v) => ({ ...v, zoom: v.zoom === 1 ? 1.5 : 1 }))}>
Zoom {view.zoom === 1 ? "150%" : "100%"}
</Button>
<Button size="sm" onClick={() => setView((v) => ({ ...v, x: v.x === 0 ? 40 : 0 }))}>
Pan
</Button>
<Button size="sm" onClick={() => setHide(!hide)}>
{hide ? "Show resolved" : "Hide resolved"}
</Button>
</div>
<div
style={{
position: "relative",
height: 280,
border: "1px solid var(--line-strong)",
background: "var(--bg-sunk)",
}}
>
<PinLayer
label="Comments"
pins={pins}
view={view}
hideResolved={hide}
renderThread={(pin, close) => (
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
<strong>{pin.author}</strong>
<span style={{ color: "var(--ink-muted)" }}>{pin.preview}</span>
<Button size="sm" onClick={close}>
{pin.resolved ? "Reopen" : "Resolve"}
</Button>
</div>
)}
/>
</div>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
CommentPin: number / state / unread / active / author | number; “open” | “resolved”; boolean | — | One marker. Resolved is hollow, dashed, with a tick; its label says open or resolved, and unread. |
PinLayer: label | string | — | Names the layer: “Comments”. |
pins | { id, x, y, number?, resolved?, unread?, author?, preview? }[] | — | Where each tail points: world units with a view, else pixels. |
view | { x, y, zoom } | — | What the canvas shows, to project the pins (editorProject). |
openId / defaultOpenId / onOpenChange | string | null | — | The pin whose thread is open: one at a time. |
renderThread | (pin, close) => ReactNode | — | The thread, in the panel that opens beside the pin. |
hideResolved / threadWidth | boolean; number | — | Leave resolved pins out; the panel's width (280). |
className | string | — | Extra classes. |