import { useDensity } from "$lib/density-context"; import type { DensityMode } from "$lib/design-tokens"; import type { Note } from "$lib/model"; import { Card } from "$ui/Card"; import { Tag } from "$ui/Tag"; import { A } from "@solidjs/router"; import type { Component } from "solid-js"; import { For, Show } from "solid-js"; type NoteCardProps = { note: Note; density?: DensityMode }; export const NoteCard: Component = (props) => { const globalDensity = useDensity(); const density = () => props.density || globalDensity; const truncateBody = (body: string, maxLength: number) => { const plainText = body.replace(/[#*`[\]]/g, "").trim(); return plainText.length > maxLength ? plainText.slice(0, maxLength) + "..." : plainText; }; const paddingClass = () => { const d = density(); return d === "compact" ? "p-4" : d === "spacious" ? "p-8" : "p-6"; }; return (

{props.note.title || "Untitled"}

{props.note.updated_at ? new Date(props.note.updated_at).toLocaleDateString() : ""}

{truncateBody(props.note.body, 120)}

0}>
{(tag) => } 3}> +{props.note.tags.length - 3}
); };