From cd0c0fc2077320108a48c9d18cc6d04f3fcb4bb6 Mon Sep 17 00:00:00 2001 From: Arnab Date: Wed, 24 Dec 2025 23:09:55 +0530 Subject: [PATCH 1/3] feat(NotePreview): add NotePreview component for rendering truncated note content --- .../notes/NotePreview/NotePreview.tsx | 27 +++++++++++++++++++ .../notes/NotePreview/NotePreviewProps.ts | 4 +++ 2 files changed, 31 insertions(+) create mode 100644 src/components/notes/NotePreview/NotePreview.tsx create mode 100644 src/components/notes/NotePreview/NotePreviewProps.ts diff --git a/src/components/notes/NotePreview/NotePreview.tsx b/src/components/notes/NotePreview/NotePreview.tsx new file mode 100644 index 0000000..e5cb8d1 --- /dev/null +++ b/src/components/notes/NotePreview/NotePreview.tsx @@ -0,0 +1,27 @@ +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) { + const contents = props.content ?? ""; + const previewText = contents.length > props.maxLength + ? contents.slice(0, props.maxLength) + : contents; + + return ( +
+

+ {previewText} +

+
+ ); +} \ No newline at end of file diff --git a/src/components/notes/NotePreview/NotePreviewProps.ts b/src/components/notes/NotePreview/NotePreviewProps.ts new file mode 100644 index 0000000..f5a9675 --- /dev/null +++ b/src/components/notes/NotePreview/NotePreviewProps.ts @@ -0,0 +1,4 @@ +export interface NotePreviewProps { + content: string; + maxLength: number; +} \ No newline at end of file From 2ae7ee6eb461824fd671142c83b4d835d5b0a78b Mon Sep 17 00:00:00 2001 From: Arnab Date: Wed, 24 Dec 2025 23:24:22 +0530 Subject: [PATCH 2/3] fix(NotePreviewProps): make content prop optional --- src/components/notes/NotePreview/NotePreviewProps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/notes/NotePreview/NotePreviewProps.ts b/src/components/notes/NotePreview/NotePreviewProps.ts index f5a9675..1bd2cae 100644 --- a/src/components/notes/NotePreview/NotePreviewProps.ts +++ b/src/components/notes/NotePreview/NotePreviewProps.ts @@ -1,4 +1,4 @@ export interface NotePreviewProps { - content: string; + content?: string; maxLength: number; } \ No newline at end of file From df154b4164255986e7f63bfaf006f74107f64d5d Mon Sep 17 00:00:00 2001 From: Arnab Date: Thu, 25 Dec 2025 13:26:23 +0530 Subject: [PATCH 3/3] fix(NotePreview): display full content instead of truncated preview --- src/components/notes/NotePreview/NotePreview.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/notes/NotePreview/NotePreview.tsx b/src/components/notes/NotePreview/NotePreview.tsx index e5cb8d1..ec0fb7b 100644 --- a/src/components/notes/NotePreview/NotePreview.tsx +++ b/src/components/notes/NotePreview/NotePreview.tsx @@ -13,14 +13,11 @@ import type {NotePreviewProps} from "./NotePreviewProps.ts"; */ export function NotePreview(props: Readonly) { const contents = props.content ?? ""; - const previewText = contents.length > props.maxLength - ? contents.slice(0, props.maxLength) - : contents; return (

- {previewText} + {contents}

);