Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/components/notes/NotePreview/NotePreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type {NotePreviewProps} from "./NotePreviewProps.ts";

/**
* Renders a preview of the note content.
*
* This component processes the note content by truncating it to a specified length
* and wrapping it in a container with line-clamping styles to ensure it fits within the UI.
*
* @param props - The component properties.
* @param props.content - The text content of the note. Defaults to an empty string if null or undefined.
* @param props.maxLength - The maximum number of characters to display before the text is sliced.
* @returns The rendered note preview element.
*/
export function NotePreview(props: Readonly<NotePreviewProps>) {
const contents = props.content ?? "";

return (
<div className="line-clamp-3 text-base-content">
<p>
{contents}
</p>
</div>
);
}
4 changes: 4 additions & 0 deletions src/components/notes/NotePreview/NotePreviewProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface NotePreviewProps {
content?: string;
maxLength: number;
}