Conversation
…d color of nested card sections
Summary of ChangesHello @adoriandoran, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the visual appearance and structural integrity of the list view by introducing and integrating new, reusable Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the list view's appearance by refactoring it to use new, reusable Card and CardSection components. This is a positive architectural change that enhances modularity. The new components make good use of modern CSS features and React context for managing nested layouts. My review includes several suggestions for code simplification, adherence to best practices in React/Preact, and notes on the use of modern CSS features that might affect compatibility and maintainability.
| .tn-icon { | ||
| color: var(--left-pane-icon-color); | ||
| margin-inline-end: 8px; | ||
| font-size: 1.2em; | ||
| } | ||
|
|
||
| .note-book-title { | ||
| color: inherit; | ||
| } | ||
|
|
||
| .note-list-attributes { | ||
| flex-grow: 1; | ||
| text-align: right; | ||
| font-size: .75em; | ||
| opacity: .75; | ||
| } |
There was a problem hiding this comment.
This file uses CSS nesting syntax (e.g., .tn-icon nested inside .note-list h5) but has a .css extension. While modern browsers are starting to support this, it's not universal and can be confusing for developers who expect .css files to contain standard CSS.
If you are using a CSS preprocessor like Sass or Less, it's a best practice to rename the file to .scss or .less to make the dependency on a preprocessor explicit.
If you are relying on native CSS nesting, please ensure your target platforms (browsers, Electron version) have sufficient support.
| const children = <> | ||
| {isExpanded && <> | ||
| <CardSection className="note-content-preview"> | ||
| <NoteContent note={note} highlightedTokens={highlightedTokens} noChildrenList includeArchivedNotes={includeArchived} /> | ||
| </CardSection> | ||
| <NoteChildren note={note} parentNote={parentNote} highlightedTokens={highlightedTokens} currentLevel={currentLevel} expandDepth={expandDepth} includeArchived={includeArchived} /> | ||
| </>} | ||
| </> |
There was a problem hiding this comment.
The outer React.Fragment (<>...</>) and the object wrapper around the conditional rendering are unnecessary. You can simplify this by directly using the conditional rendering expression.
const children = isExpanded && <>
<CardSection className="note-content-preview">
<NoteContent note={note} highlightedTokens={highlightedTokens} noChildrenList includeArchivedNotes={includeArchived} />
</CardSection>
<NoteChildren note={note} parentNote={parentNote} highlightedTokens={highlightedTokens} currentLevel={currentLevel} expandDepth={expandDepth} includeArchived={includeArchived} />
</>;
| data-note-id={note.noteId} | ||
| > | ||
| <h5 className="note-book-header"> | ||
| <h5 className=""> |
| <span | ||
| className={`note-expander ${isExpanded ? "bx bx-chevron-down" : "bx bx-chevron-right"}`} | ||
| onClick={() => setExpanded(!isExpanded)} | ||
| onClick={(e) => {setExpanded(!isExpanded); e.stopPropagation();}} | ||
| /> |
There was a problem hiding this comment.
The onClick handler on this <span> is redundant. The parent <CardSection> already has an onAction prop that handles toggling the expansion state, and clicks on this span will bubble up to it. Removing this handler simplifies the code and avoids duplication of intent. The e.stopPropagation() is also not needed because other clickable elements like NoteLink already handle their own events and stop propagation.
<span
className={`note-expander ${isExpanded ? "bx bx-chevron-down" : "bx bx-chevron-right"}`}
/>
|
|
||
| &.tn-card-section-nested { | ||
| padding-left: calc(8px + (var(--card-nested-section-indent) * var(--tn-card-section-nesting-level))); | ||
| background-color: color-mix(in srgb, var(--card-background-color) calc(100% / (var(--tn-card-section-nesting-level) + 1)) , transparent); |
There was a problem hiding this comment.
|
|
||
| export function CardSection(props: {children: ComponentChildren} & CardSectionProps) { | ||
| const parentContext = useContext(CardSectionContext); | ||
| const nestingLevel = (parentContext && parentContext.nestingLevel + 1) ?? 0; |
| <section className={clsx(["tn-card-section", { | ||
| "tn-card-section-nested": nestingLevel > 0, | ||
| "tn-action": props?.hasAction} | ||
| ], props.className)} |
There was a problem hiding this comment.
The clsx function can be called with multiple arguments, which is more idiomatic than passing an array as the first argument.
| <section className={clsx(["tn-card-section", { | |
| "tn-card-section-nested": nestingLevel > 0, | |
| "tn-action": props?.hasAction} | |
| ], props.className)} | |
| <section className={clsx("tn-card-section", { | |
| "tn-card-section-nested": nestingLevel > 0, | |
| "tn-action": props?.hasAction | |
| }, props.className)} |
| "tn-action": props?.hasAction} | ||
| ], props.className)} | ||
| style={"--tn-card-section-nesting-level: " + nestingLevel} | ||
| onClick={() => {props.onAction?.()}}> | ||
| {props.children} | ||
| </section> | ||
|
|
||
| {props?.childrenVisible && | ||
| <CardSectionContext.Provider value={{nestingLevel}}> | ||
| {props.subSections} | ||
| </CardSectionContext.Provider> | ||
| } |
| "tn-card-section-nested": nestingLevel > 0, | ||
| "tn-action": props?.hasAction} | ||
| ], props.className)} | ||
| style={"--tn-card-section-nesting-level: " + nestingLevel} |
There was a problem hiding this comment.
In Preact/React, it's a best practice to pass the style prop as an object rather than a string. This allows React to handle CSS properties more efficiently and safely.
| style={"--tn-card-section-nesting-level: " + nestingLevel} | |
| style={{ "--tn-card-section-nesting-level": nestingLevel }} |
| "tn-action": props?.hasAction} | ||
| ], props.className)} | ||
| style={"--tn-card-section-nesting-level: " + nestingLevel} | ||
| onClick={() => {props.onAction?.()}}> |
There was a problem hiding this comment.
No description provided.