-
Notifications
You must be signed in to change notification settings - Fork 0
feat(NotePreview): add NotePreview component for rendering truncated note content #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Arnab-Mandal1
wants to merge
8
commits into
main
Choose a base branch
from
feature/note-preview
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cd0c0fc
feat(NotePreview): add NotePreview component for rendering truncated …
Arnab-Mandal1 2ae7ee6
fix(NotePreviewProps): make content prop optional
Arnab-Mandal1 df154b4
fix(NotePreview): display full content instead of truncated preview
Arnab-Mandal1 412af6d
Merge branch 'main' into feature/note-preview
Arnab-Mandal1 6aa9c09
Merge branch 'main' into feature/note-preview
Arnab-Mandal1 7b212f3
Merge branch 'main' into feature/note-preview
Arnab-Mandal1 85e09ec
refactor(NotePreview): remove unused maxLength prop
Arnab-Mandal1 3749bb5
Merge remote-tracking branch 'origin/feature/note-preview' into featu…
Arnab-Mandal1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 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. | ||
| * @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> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export interface NotePreviewProps { | ||
| content?: string; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve conflicting truncation strategies.
The component uses both character-based truncation (lines 16-18:
slice(0, maxLength)) and CSS line-clamping (line-clamp-3). These two approaches can conflict:If
maxLengthallows text that spans more than 3 lines, both truncations apply, which may produce unexpected results. Conversely, ifmaxLengthproduces only 1-2 lines,line-clamp-3is redundant.Choose one truncation strategy:
line-clamp-3for visual line-based truncation (removemaxLengthprop and slicing logic)line-clamp-3class)🔎 Example fix for Option 1 (line-based only)
In
NotePreviewProps.ts:export interface NotePreviewProps { content?: string; - maxLength: number; }In
NotePreview.tsx:✅ Addressed in commit df154b4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Arnab-Mandal1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai recheck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 957
@Arnab-Mandal1, good progress! The conflicting truncation strategies have been resolved—the component now uses only CSS line-clamping (line-clamp-3), and the character-based slicing logic has been removed. ✅However, there's a cleanup issue remaining:
The
maxLengthprop is still declared inNotePreviewPropsbut is no longer used in the component.This creates confusion for anyone using this component, as they'll see
maxLengthas a required prop but it won't have any effect. Additionally, the JSDoc still documents@param props.maxLength, which is now misleading.To complete the fix:
maxLengthfromNotePreviewProps.ts:@param props.maxLengthline from the JSDoc inNotePreview.tsx:Would you like me to create an issue to track this cleanup, or will you address it in this PR?
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check