Skip to content

enforce correct lesson order in course sidebar, improve styling and seperation of course sidebar#84

Merged
AustinKelsay merged 3 commits intomainfrom
bugfix/course-lessons-in-sidebar
Jul 6, 2025
Merged

enforce correct lesson order in course sidebar, improve styling and seperation of course sidebar#84
AustinKelsay merged 3 commits intomainfrom
bugfix/course-lessons-in-sidebar

Conversation

@AustinKelsay
Copy link
Copy Markdown
Owner

@AustinKelsay AustinKelsay commented Jul 6, 2025

Summary by CodeRabbit

  • Refactor
    • Simplified the sidebar layout on both desktop and mobile for a cleaner and more consistent appearance.
    • Removed internal scrolling containers from the sidebar, streamlining navigation.
    • Updated the desktop layout to use a flexible side-by-side arrangement for main content and sidebar.
    • Integrated the sidebar into a dedicated "lessons" tab on mobile for improved usability.

@vercel
Copy link
Copy Markdown

vercel bot commented Jul 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plebdevs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2025 10:38pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 6, 2025

Walkthrough

The changes simplify the layout and scrolling behavior of the course sidebar in both the sidebar component and the course page. Internal scrolling containers and fixed widths are removed, replaced by a cleaner flexbox-based layout. The mobile sidebar is now integrated as a tab, and sidebar rendering is conditional on visibility.

Changes

Files Change Summary
src/components/content/courses/layout/CourseSidebar.js Removed overflow and fixed height classes, eliminated internal scrolling wrappers, adjusted sticky offset, and simplified layout.
src/pages/course/[slug]/index.js Refactored main content and sidebar to use flexbox, simplified sidebar rendering logic, integrated mobile sidebar as a tab, and applied conditional rendering.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CoursePage
    participant Sidebar

    User->>CoursePage: Loads course page
    CoursePage->>Sidebar: Conditionally renders Sidebar (desktop or mobile tab)
    Sidebar-->>CoursePage: Sidebar content (no internal scrolling)
    User->>CoursePage: Switches tabs (mobile)
    CoursePage->>Sidebar: Shows/hides Sidebar as tab content
Loading

Possibly related PRs

  • AustinKelsay/plebdevs#73: Modifies sidebar rendering and styling logic in the same files, focusing on sidebar animations and transitions.
  • AustinKelsay/plebdevs#72: Simplifies sidebar rendering and layout by removing conditional class toggling and complex wrappers.
  • AustinKelsay/plebdevs#70: Changes lesson selection handling in the sidebar, related to component behavior but distinct from layout and rendering changes.

Poem

In the warren of code, a sidebar unfurled,
Lost its scroll, its width, its twirl.
Now flex and flow, side by side,
Tabs for mobile, no scroll to hide.
With layouts neat and logic slim,
The rabbit hops—sidebar trim!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-06T22_53_08_386Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/components/content/courses/layout/CourseSidebar.js (1)

94-100: Add explicit lesson ordering in CourseSidebar

To enforce the ordering promised by the PR title, sort the lessons array by its index property before rendering. For example, in src/components/content/courses/layout/CourseSidebar.js:

• At the top of the component, derive a sorted array:

   const CourseSidebar = ({
     lessons,
     activeIndex,
     onLessonSelect,
     completedLessons,
     isMobileView,
     sidebarVisible,
   }) => {
+   const sortedLessons = useMemo(
+     () => [...lessons].sort((a, b) => a.index - b.index),
+     [lessons]
+   );

• Then update the JSX mapping to use sortedLessons instead of lessons:

-        {lessons.map((lesson, index) => (
-          <LessonItem key={index} lesson={lesson} index={index} />
-        ))}
+        {sortedLessons.map((lesson, index) => (
+          <LessonItem key={index} lesson={lesson} index={index} />
+        ))}

This ensures the sidebar always displays lessons in ascending order by index.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 892ac6c and eda202c.

📒 Files selected for processing (2)
  • src/components/content/courses/layout/CourseSidebar.js (2 hunks)
  • src/pages/course/[slug]/index.js (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/content/courses/layout/CourseSidebar.js (2)
src/pages/course/[slug]/index.js (1)
  • navbarHeight (40-40)
src/components/navbar/Navbar.js (1)
  • navbarHeight (19-19)
🔇 Additional comments (4)
src/components/content/courses/layout/CourseSidebar.js (1)

131-137: Layout simplification improves maintainability.

The removal of complex positioning and the switch to a cleaner flexbox-based layout with conditional rendering is a good improvement. The transition classes are simplified while maintaining smooth animations.

src/pages/course/[slug]/index.js (3)

230-232: Flexbox layout improves responsiveness and maintainability.

The switch from fixed width with padding adjustments to a flexbox layout is a significant improvement. This approach provides better responsive behavior and cleaner separation between main content and sidebar.


284-302: Mobile lessons tab implementation looks solid.

The integration of the sidebar as a tab for mobile view is well-implemented. The conditional rendering and proper state management with setSidebarVisible and toggleTab maintain consistency across views.


305-328: Desktop sidebar conditional rendering is efficient.

The conditional rendering approach ({sidebarVisible && (...)) prevents unnecessary DOM elements and the smooth width/opacity transitions provide good UX. The pointerEvents toggle is a nice touch to prevent interaction when hidden.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@AustinKelsay
Copy link
Copy Markdown
Owner Author

@CodeRabbit full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 6, 2025

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/pages/course/[slug]/index.js (1)

305-328: Well-implemented conditional rendering and lesson sorting

The desktop sidebar implementation correctly addresses the PR objectives:

  • Conditional rendering (sidebarVisible &&) improves performance
  • Explicit lesson sorting by index (sort((a, b) => a.index - b.index)) enforces correct lesson order
  • Smooth transitions with pointer events control enhance UX

This addresses the lesson ordering concerns from previous reviews.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 892ac6c and 41afe6a.

📒 Files selected for processing (2)
  • src/components/content/courses/layout/CourseSidebar.js (2 hunks)
  • src/pages/course/[slug]/index.js (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/content/courses/layout/CourseSidebar.js (2)
src/pages/course/[slug]/index.js (1)
  • navbarHeight (40-40)
src/components/navbar/Navbar.js (1)
  • navbarHeight (19-19)
🔇 Additional comments (3)
src/components/content/courses/layout/CourseSidebar.js (2)

94-94: Clean layout simplification

The removal of nested scrolling containers and simplification to a basic flex container improves the code structure and reduces complexity.


131-135: Improved sticky positioning and styling

The simplified transition classes and clean sticky positioning with adjusted offset (navbarHeight + 70px) enhance the sidebar's visual behavior and maintain proper spacing relative to the header.

src/pages/course/[slug]/index.js (1)

229-232: Excellent flexbox layout implementation

The transition to flexbox layout with flex items-start gap-x-8 provides a clean, responsive structure that properly handles the main content and sidebar positioning. This is a significant improvement over the previous layout approach.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Repository owner deleted a comment from coderabbitai bot Jul 6, 2025
@AustinKelsay
Copy link
Copy Markdown
Owner Author

@CodeRabbit full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 6, 2025

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/components/content/courses/layout/CourseSidebar.js (1)

94-100: Sidebar no longer scrolls – long lesson lists will become inaccessible

overflow-y-auto was removed and no alternative height/overflow constraint was introduced.
When a course contains more lessons than the viewport can show, the sticky container will simply grow, pushing the bottom items below the fold with no way to reach them.

-      <div className="flex-1 pr-2">
+      <div
+        className="flex-1 pr-2 overflow-y-auto"
+        style={{ maxHeight: `calc(100vh - ${navbarHeight + 90}px)` }} /* leaves space for header & padding */
+      >
♻️ Duplicate comments (1)
src/pages/course/[slug]/index.js (1)

305-328: Excellent lesson sorting implementation addresses previous concerns.

The explicit sorting of lessons by index ([...uniqueLessons].sort((a, b) => a.index - b.index)) directly addresses the PR objective to "enforce correct lesson order" and resolves the consistency issues flagged in previous reviews. The conditional rendering with proper pointer events management ensures clean desktop sidebar behavior.

🧹 Nitpick comments (2)
src/components/content/courses/layout/CourseSidebar.js (2)

96-99: Prefer stable keys over the array index

Using index as a React key breaks reconciliation whenever the lesson array is reordered, filtered, or items are inserted. A stable identifier (e.g., lesson.id) avoids subtle UI bugs.

-          {lessons.map((lesson, index) => (
-            <LessonItem key={index} lesson={lesson} index={index} />
+          {lessons.map((lesson, index) => (
+            <LessonItem key={lesson.id ?? index} lesson={lesson} index={index} />
           ))}

131-136: transition-all wrapper is now redundant

The middle wrapper always renders with opacity-100; since the sidebar is conditionally mounted rather than animated, the transition never fires and the extra element adds complexity.

-          <div 
-            className={`transition-all duration-500 ease-in-out opacity-100`}
-          >
-            <div className="ml-2 w-80 sticky rounded-lg border border-gray-800 shadow-md bg-gray-800"
+          <div className="ml-2 w-80 sticky rounded-lg border border-gray-800 shadow-md bg-gray-800"
                  style={{ top: `${navbarHeight + 70}px` }}> {/* Adjusted to match new header spacing */}
               <SidebarContent />
-            </div>
           </div>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 892ac6c and da0c6ca.

📒 Files selected for processing (2)
  • src/components/content/courses/layout/CourseSidebar.js (2 hunks)
  • src/pages/course/[slug]/index.js (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/content/courses/layout/CourseSidebar.js (2)
src/pages/course/[slug]/index.js (1)
  • navbarHeight (40-40)
src/components/navbar/Navbar.js (1)
  • navbarHeight (19-19)
🔇 Additional comments (9)
src/components/content/courses/layout/CourseSidebar.js (4)

94-94: Good simplification of scroll handling.

Removing the overflow-y-auto class from the sidebar content container simplifies the layout by eliminating nested scrollable areas. This change aligns with the PR objective to improve styling and separation of the course sidebar.


131-131: Simplified transition classes improve maintainability.

The simplified transition classes remove complex styling while maintaining the smooth animation effects. This change makes the CSS more maintainable and consistent.


133-134: Proper sticky positioning with adjusted top offset.

The sticky positioning with top: ${navbarHeight + 70}px correctly accounts for the navbar height plus additional spacing. The simplified class structure removes unnecessary complexity while maintaining the desired layout behavior.


135-135: Effective removal of nested scroll wrapper.

Removing the scrollable wrapper around SidebarContent eliminates redundant scroll containers, which could cause scrolling conflicts. This change improves the user experience by providing cleaner scroll behavior.

src/pages/course/[slug]/index.js (5)

229-232: Excellent flexbox layout implementation.

The new flexbox layout with flex items-start gap-x-8 provides proper side-by-side positioning of main content and sidebar on desktop. The flex-1 min-w-0 on the main content ensures it takes available space while preventing overflow issues.


235-247: Proper component formatting and prop passing.

The CourseOverview component is correctly formatted with proper prop passing, including the lesson selection handler and mobile view support.


268-276: Clean content rendering with authorization checks.

The CourseContent component rendering maintains proper authorization checks and loading states while passing all necessary props correctly.


281-281: Consistent component formatting.

The CourseQA component maintains consistent formatting with other tab components.


284-302: Well-implemented mobile lessons tab.

The mobile implementation correctly renders lessons as a tab with proper sorting and event handling. The close handler appropriately manages sidebar state and tab switching.

@AustinKelsay AustinKelsay merged commit 4a2e0ec into main Jul 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant