Skip to content

feat: Make sidebar width adjustable #2872

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
wants to merge 3 commits into
base: alpha
Choose a base branch
from

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Jul 7, 2025

Summary

  • add global CSS variable for sidebar width
  • adjust layout styles to use --sidebar-width
  • add resize handle and logic to sidebar
  • install dependencies to run tests

Testing

  • npm test (fails: Cannot read properties of undefined (reading 'statusCode'))

https://chatgpt.com/codex/tasks/task_e_686bb3991f68832dbaacc10d547636ca

Summary by CodeRabbit

  • New Features

    • Added the ability for users to resize the sidebar by dragging a handle, with the chosen width saved for future sessions.
  • Style

    • Updated various interface elements (sidebar, toolbar, footers, content areas) to dynamically adjust their position and size based on the sidebar’s width.
    • Introduced a CSS variable for sidebar width, enabling consistent and flexible layout adjustments throughout the app.

@mtrezza mtrezza added the codex label Jul 7, 2025 — with ChatGPT Connector
Copy link

parse-github-assistant bot commented Jul 7, 2025

🚀 Thanks for opening this pull request!

Copy link

The label codex cannot be used here.

Copy link

coderabbitai bot commented Jul 7, 2025

📝 Walkthrough

Walkthrough

The changes introduce a user-resizable sidebar by updating the Sidebar component to support drag-based resizing and synchronizing its width with a CSS custom property (--sidebar-width). Multiple SCSS files are updated to use this variable instead of a fixed 300px value, enabling dynamic layout adjustments across the application. A default value is set in the global stylesheet.

Changes

File(s) Change Summary
src/components/Sidebar/Sidebar.react.js Added drag-to-resize functionality for the sidebar, syncing width with a CSS variable and localStorage.
src/components/Sidebar/Sidebar.scss Updated widths to use --sidebar-width variable; added styles for a draggable resize handle.
src/stylesheets/base.scss Defined global CSS variable --sidebar-width: 300px in the :root selector.
src/components/FlowFooter/FlowFooter.scss
src/components/Toolbar/Toolbar.scss
Replaced fixed left: 300px with left: var(--sidebar-width, 300px) for dynamic positioning.
src/dashboard/Dashboard.scss
src/parse-interface-guide/PIG.scss
Changed fixed margin-left: 300px to margin-left: var(--sidebar-width, 300px) for dynamic content offset.
src/dashboard/Data/Browser/Browser.scss
src/dashboard/Data/Browser/BrowserFooter.scss
src/dashboard/TableView.scss
Replaced fixed sidebar-related values (e.g., left: 300px, width: calc(100% - 300px)) with CSS variable --sidebar-width.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Sidebar
    participant CSS
    participant LocalStorage

    User->>Sidebar: Mouse down on resize handle
    Sidebar->>Sidebar: startResize()
    Sidebar->>User: Track mousemove events
    loop While dragging
        User->>Sidebar: Mouse move
        Sidebar->>Sidebar: Update width state (min 200px)
        Sidebar->>CSS: Update --sidebar-width property
    end
    User->>Sidebar: Mouse up
    Sidebar->>LocalStorage: Save new width
    Sidebar->>Sidebar: Remove event listeners
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef2f3d3 and bff8747.

📒 Files selected for processing (1)
  • src/components/Sidebar/Sidebar.scss (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Sidebar/Sidebar.scss
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Node 22
  • GitHub Check: Node 18
  • GitHub Check: Node 20
  • GitHub Check: Docker linux/amd64
  • GitHub Check: Lint

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 sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for 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.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jul 7, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

@mtrezza mtrezza changed the title Make sidebar width adjustable feat: Make sidebar width adjustable Jul 7, 2025
Copy link

@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

🧹 Nitpick comments (4)
src/stylesheets/base.scss (1)

10-12: Consider documenting the new CSS custom property

Future maintainers may not immediately realize this variable is manipulated at runtime by the Sidebar component. A short comment would improve discoverability.

 :root {
+  /* Width of the left-hand sidebar – updated dynamically via Sidebar.react.js */
   --sidebar-width: 300px;
 }
src/components/Sidebar/Sidebar.scss (1)

25-33: Well-implemented resize handle, consider usability.

The resize handle implementation is technically correct with proper positioning, cursor, and user interaction properties. However, the 5px width might be challenging for users to target precisely.

Consider increasing the handle width slightly for better usability:

-    width: 5px;
+    width: 8px;

Alternatively, you could add a hover effect to provide visual feedback when the handle is targetable.

src/components/Sidebar/Sidebar.react.js (2)

39-41: Improve localStorage parsing robustness.

The localStorage parsing could be more robust to handle edge cases like invalid values or empty strings.

Consider adding validation for the parsed value:

-  const initialWidth = parseInt(localStorage.getItem('sidebarWidth') || '300', 10);
+  const getInitialWidth = () => {
+    const stored = localStorage.getItem('sidebarWidth');
+    const parsed = parseInt(stored || '300', 10);
+    return Number.isNaN(parsed) || parsed < 200 ? 300 : parsed;
+  };
+  const initialWidth = getInitialWidth();

123-139: Well-implemented drag-to-resize functionality.

The resize implementation correctly handles mouse drag interactions with proper event listener management and cleanup. The minimum width constraint of 200px prevents the sidebar from becoming unusably narrow.

Consider making the minimum width configurable:

+const MIN_SIDEBAR_WIDTH = 200;

-      const newWidth = Math.max(200, startWidth + ev.clientX - startX);
+      const newWidth = Math.max(MIN_SIDEBAR_WIDTH, startWidth + ev.clientX - startX);

This would make the constraint more maintainable if requirements change.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cfd0bce and fd7229d.

📒 Files selected for processing (10)
  • src/components/FlowFooter/FlowFooter.scss (1 hunks)
  • src/components/Sidebar/Sidebar.react.js (5 hunks)
  • src/components/Sidebar/Sidebar.scss (2 hunks)
  • src/components/Toolbar/Toolbar.scss (1 hunks)
  • src/dashboard/Dashboard.scss (1 hunks)
  • src/dashboard/Data/Browser/Browser.scss (2 hunks)
  • src/dashboard/Data/Browser/BrowserFooter.scss (1 hunks)
  • src/dashboard/TableView.scss (1 hunks)
  • src/parse-interface-guide/PIG.scss (2 hunks)
  • src/stylesheets/base.scss (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/components/Sidebar/Sidebar.react.js (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2726
File: src/components/ContextMenu/ContextMenu.react.js:56-74
Timestamp: 2025-05-24T18:24:15.988Z
Learning: In the Parse Dashboard ContextMenu component, the one-time positioning calculation using hasPositioned ref works well even with window resizing and movement, so additional window resize event listeners are not necessary for menu positioning.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (10)
src/components/Toolbar/Toolbar.scss (1)

14-14: Good switch to CSS variable – enables real-time resizing

The fallback guarantees legacy support while allowing the new dynamic width. Looks correct.

src/dashboard/TableView.scss (1)

13-13: LGTM – dynamic sidebar width reflected in table headers
No issues spotted.

src/components/FlowFooter/FlowFooter.scss (1)

13-13: Variable use is correct; confirm animation still behaves as intended

left is transitioned, so changing --sidebar-width should still animate the footer. Just keep in mind some browsers skip transitions when only a custom property changes—test in target browsers.

src/dashboard/Dashboard.scss (1)

11-11: LGTM – content area now respects adjustable sidebar
Implementation is straightforward and consistent with the other updates.

src/dashboard/Data/Browser/Browser.scss (1)

13-13: LGTM! Consistent implementation of dynamic sidebar width.

The changes properly replace hardcoded sidebar width values with the CSS custom property --sidebar-width, maintaining backward compatibility with the 300px fallback. This enables responsive layout adjustments based on user-resizable sidebar width.

Also applies to: 27-27

src/parse-interface-guide/PIG.scss (1)

14-14: LGTM! Proper implementation of dynamic sidebar width.

The changes correctly replace fixed pixel values with the CSS custom property --sidebar-width while maintaining consistent fallback behavior. The implementation aligns with the overall refactor objective.

Also applies to: 56-56

src/dashboard/Data/Browser/BrowserFooter.scss (1)

5-5: LGTM! Correct implementation of dynamic width calculation.

The footer width calculation properly adapts to the dynamic sidebar width using CSS custom properties within the calc() function. The implementation maintains the original calculation logic while enabling responsive behavior.

src/components/Sidebar/Sidebar.scss (1)

17-17: LGTM! Consistent implementation of dynamic sidebar width.

The width properties are correctly updated to use the CSS custom property with appropriate fallback values.

Also applies to: 174-174

src/components/Sidebar/Sidebar.react.js (2)

72-75: LGTM! Proper CSS custom property synchronization.

The useEffect correctly updates the CSS custom property and maintains the current width reference to prevent stale closures during drag operations.


221-221: LGTM! Properly positioned resize handle.

The resize handle is correctly positioned and connected to the resize functionality.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 7, 2025
Copy link

uffizzi-cloud bot commented Jul 7, 2025

Uffizzi Ephemeral Environment deployment-64527

⌚ Updated Jul 07, 2025, 13:51 UTC

☁️ https://app.uffizzi.com/github.com/parse-community/parse-dashboard/pull/2872

📄 View Application Logs etc.

What is Uffizzi? Learn more

Copy link

@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/CategoryList/CategoryList.scss (1)

40-44: Add min-width: 0 to guarantee the ellipsis works inside a flex row

When a flex-item is allowed to grow (flex: 1 1 auto), some browsers (notably Chrome) will refuse to apply text-overflow: ellipsis unless the item may shrink below its content width.
Explicitly setting min-width: 0 solves this and prevents layout breakage when class names are long.

       &:last-of-type {
         flex: 1 1 auto;
+        min-width: 0;      /* allow shrinking for proper ellipsis */
         overflow: hidden;
         text-overflow: ellipsis;
         white-space: nowrap;
       }
🧹 Nitpick comments (1)
src/components/CategoryList/CategoryList.scss (1)

31-38: display: block on flex items is redundant

Each span is already a flex item because its parent <a> is display: flex.
The additional display: block declaration adds no benefit and can be removed for cleaner CSS.

No code change required if you keep it, just flagging the redundancy.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fd7229d and ef2f3d3.

📒 Files selected for processing (2)
  • src/components/CategoryList/CategoryList.scss (2 hunks)
  • src/components/Sidebar/Sidebar.scss (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/Sidebar/Sidebar.scss
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker linux/amd64

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 7, 2025
@mtrezza
Copy link
Member Author

mtrezza commented Jul 7, 2025

Resizing works, but it needs further adjustment for min and max width of sidebar. Leaving this open for someone to pick up.

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.

2 participants