Skip to content
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

fix: Fix RTL direction spacing errors and sidebar dragging functional… #6274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YaoweiZou
Copy link

@YaoweiZou YaoweiZou commented Feb 21, 2025

💻 变更类型 | Change Type

  • fix

🔀 变更说明 | Description of Change

Summary by CodeRabbit

  • Style
    • Refined the sidebar layout with improved spacing and alignment for a cleaner, more consistent visual experience.
    • Updated chat item display for a unified layout, removing unnecessary complexity.
  • Bug Fixes
    • Enhanced the sidebar's drag behavior to correctly respond to right-to-left language settings, ensuring smoother interaction for all users.
    • Simplified chat deletion confirmation logic for a more straightforward user experience.

Copy link

vercel bot commented Feb 21, 2025

@YaoweiZou is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

The changes involve updates to the sidebar's styling and functionality across multiple components. In the SCSS file, margin rules are replaced with gap properties for better spacing, and new classes are introduced to enhance layout flexibility. In the TypeScript files, imports and functions are modified to streamline sidebar dragging behavior, including adjustments for language directionality and the removal of redundant props. Overall, the modifications simplify the rendering logic and improve the user interface.

Changes

File Change Summary
app/components/home.module.scss Updated styling: replaced margin rules with gap properties for .sidebar-header-bar, .sidebar-actions; added new class .header-actions and nested class .second-actions; modified .chat-item and .chat-item-selected styles; updated .sidebar-actions and added .sidebar-drag.
app/components/sidebar.tsx Added getLang import; modified useDragSideBar to use a reassignable variable for drag direction based on language; removed toggleSideBar function and related props from SideBarContainer and SideBarHeader.
app/components/chat-list.tsx Removed narrow prop from ChatItem and ChatList; simplified rendering logic in ChatItem and deletion confirmation in ChatList.
app/components/home.tsx Restructured rendering logic in Screen function to integrate conditional rendering directly, eliminating the separate renderContent function.
app/constant.ts Updated MIN_SIDEBAR_WIDTH from 230 to 260; removed NARROW_SIDEBAR_WIDTH; adjusted formatting for consistency.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant S as Sidebar Component
    participant L as getLang()

    U->>S: Initiate sidebar drag
    S->>L: Request current language
    L-->>S: Return language code (e.g., "ar")
    alt Language is Arabic
        S->>S: Reverse drag direction (negate d)
    else Other language
        S->>S: Apply normal drag behavior
    end
    S->>U: Update sidebar position accordingly
Loading

Poem

I'm a coding rabbit on the run,
Hopping through changes under the sun.
Styles gap out with a gentle beat,
And sidebar drags now feel complete.
With a twitch of my nose and a joyful hop,
I celebrate updates that never stop!
🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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
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

🧹 Nitpick comments (6)
app/components/sidebar.tsx (5)

15-15: Check broader RTL languages
Currently, the drag direction is inverted only if getLang() equals "ar". Consider covering all RTL locales (e.g., Hebrew, Persian) if needed.


107-109: Applying dynamic sidebar width
Using a CSS variable to store and update the width is neat. Consider testing orientation changes and re-renders for consistency.

Would you like a quick verification script to confirm CSS changes under simulated orientation events?


156-164: Async MCP check
The checkMcpStatus logs an error only in the console. Consider user-facing error handling or graceful fallback if MCP initialization fails.


285-289: Remove stale commented code
The code segment at lines 285-289 is fully commented out. Delete it if it's no longer relevant to keep the code base lean.


292-301: Refined sidebar usage
Replacing the old logic with <SideBarContainer> and removing the narrow references reduces complexity. If the commented tail code is obsolete, remove it fully.

app/components/chat-list.tsx (1)

63-69: Unified layout
Eliminating the narrow-based conditional rendering simplifies the UI. Confirm it still looks acceptable on smaller displays.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0daf4 and 7ffa095.

⛔ Files ignored due to path filters (1)
  • app/icons/panel-left-close.svg is excluded by !**/*.svg
📒 Files selected for processing (5)
  • app/components/chat-list.tsx (3 hunks)
  • app/components/home.module.scss (6 hunks)
  • app/components/home.tsx (2 hunks)
  • app/components/sidebar.tsx (7 hunks)
  • app/constant.ts (5 hunks)
🔇 Additional comments (20)
app/components/sidebar.tsx (9)

8-8: SVG icon import
The additional icon import looks correct. Verify that its dimensions and styling blend well with the rest of the UI.


29-29: Import for selector
Adding Selector aligns well with the new discovery functionality.


80-84: RTL drag logic
Negating d for Arabic is an effective approach. Verify behavior when switching between LTR and RTL at runtime (if supported).


87-87: Sidebar width floor check
Restricting the width strictly to > MIN_SIDEBAR_WIDTH may prevent narrower layouts. Confirm it matches intended design specs.


111-111: Refined return value
Only returning onDragStart removes complexity. Ensure no other components depend on the removed shouldNarrow.


118-127: Smooth event binding
Destructuring onDragStart and applying the className via clsx is clean and consistent with your style approach.


144-154: Discovery and MCP states
The new hooks and state variables (showDiscoverySelector, mcpEnabled) significantly expand sidebar capabilities. Check that re-renders remain performant.


168-179: Header close button
The new top-level close button is introduced but appears to have no click handler. If it's not intended for future use, consider removing it to avoid confusion.


203-251: Enhanced sidebar bar
Including Discovery, Mask, and MCP features in the bar is a nice addition for discoverability. Good job centralizing these actions.

app/components/chat-list.tsx (2)

87-87: Dropping the narrow prop
Removing the narrow prop from ChatList aligns with the new sidebar approach. This cleanup should reduce complexity.


139-139: Always confirm chat deletion
Asking for confirmation every time is user-friendly. Ensure the confirmation text is translated or localized as needed.

app/components/home.tsx (2)

185-187: Inline route checks
Returning <AuthPage /> or <Sd /> directly is simpler. Verify that merging isSd and isSdNew flows does not disrupt user expectations for separate pages.


196-212: Always show sidebar
Rendering the <SideBar> for all routes (except early returns) unifies layout logic. Test on smaller screens to confirm it doesn't hamper usability.

app/constant.ts (1)

102-102: LGTM! Increased minimum sidebar width.

The change from 230px to 260px provides more space for the sidebar content, which should help resolve the RTL direction spacing issues mentioned in the PR objectives.

app/components/home.module.scss (6)

55-55: LGTM! Improved spacing in sidebar header bar.

Using gap property instead of margins is a better approach for consistent spacing between flex items.


94-102: LGTM! Well-structured header actions layout.

The new .header-actions class with flex layout and nested .second-actions provides a clean and maintainable way to organize header buttons.


188-188: LGTM! Simplified chat item styling.

Replacing complex styling (border-radius, margin-bottom, box-shadow) with a simple bottom border creates a cleaner, more consistent look.


198-198: LGTM! Improved selected chat item visibility.

Using background color instead of border color for selected items provides better visual feedback.


254-254: LGTM! Consistent spacing in sidebar actions.

Using gap property for spacing between sidebar actions aligns with the modern CSS best practices.


269-272: LGTM! Fixed RTL sidebar drag functionality.

The RTL-specific adjustments to the sidebar drag handle's position correctly handle right-to-left layouts, addressing the issue mentioned in the PR objectives.

@YaoweiZou
Copy link
Author

@Leizhenpeng 这个 PR 还需要更多的信息才能合并吗?如果是,还需要什么?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


@Leizhenpeng Does this PR need more information to merge? If so, what else is needed?

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