NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

fix: add fold-code button when code is expand

Open code-october opened this issue 1 year ago • 7 comments

💻 变更类型 | Change Type

  • [ ] feat
  • [x] fix
  • [ ] refactor
  • [ ] perf
  • [ ] style
  • [ ] test
  • [ ] docs
  • [ ] ci
  • [ ] chore
  • [ ] build

🔀 变更说明 | Description of Change

Add a collapse code button when expanding the code to support toggling the code's collapsed state at any time.

📝 补充信息 | Additional Information

Relevant issue:https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5284

image

image

Summary by CodeRabbit

  • New Features

    • Simplified toggle button for content visibility, now showing "More" or "Less" based on state.
    • Added localization support for the toggle button in English, Simplified Chinese, and Traditional Chinese.
  • Style

    • Enhanced layout behavior for expanded content with updated alignment properties.

code-october avatar Sep 27 '24 12:09 code-october

@code-october is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 27 '24 12:09 vercel[bot]

Walkthrough

The changes involve updates to the rendering logic of the CustomCode component in the app/components/markdown.tsx file, specifically regarding a toggle button for content visibility. The button's display condition has been simplified, and new localization entries have been added for different languages. Additionally, CSS modifications enhance the layout of the .expanded class, improving content alignment.

Changes

Files Change Summary
app/components/markdown.tsx Updated CustomCode function to simplify toggle button rendering logic and dynamically update text.
app/locales/cn.ts Added Less: "折叠代码" for localization support in Chinese.
app/locales/en.ts Added Less: "Fold Code" for localization support in English.
app/locales/tw.ts Added Less: "收合程式" for localization support in Traditional Chinese.
app/styles/globals.scss Modified .expanded class to set justify-content: flex-end for improved layout behavior.

Possibly related PRs

  • #5303: Modifies the CustomCode component to change button text to a dynamic value, related to the toggle button rendering logic.
  • #5377: Adds an optional className property to the CustomCode function, enhancing styling flexibility relevant to the rendering logic changes.
  • #5495: Alters the onClick event handler in the PreCode component, changing how text is copied to the clipboard, related to the functionality of components in the main PR.

Suggested reviewers

  • lloydzhou

🐰 In the meadow, the code does play,
With toggles that dance, come what may.
"More" and "Less" in harmony sing,
Localization brings a joyful spring.
Aligning content, a neat little feat,
Hop along, changes make it sweet! 🌼


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 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.

coderabbitai[bot] avatar Sep 27 '24 12:09 coderabbitai[bot]

Your build has completed!

Preview deployment

github-actions[bot] avatar Sep 27 '24 12:09 github-actions[bot]

查看全部在顶部,居中。 所以,折叠收起,应该在底部居中,应该同样有一个遮罩层,只是颜色渐变是相反的。

lloydzhou avatar Sep 27 '24 12:09 lloydzhou

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


See all at the top, centered. So, folded, it should be centered at the bottom, and it should also have a mask layer, just with the color gradient reversed.

Issues-translate-bot avatar Sep 27 '24 12:09 Issues-translate-bot

@lloydzhou 我移动到右上角,主要是担心提示文字居中会遮挡代码,影响阅读代码观感,这再加上遮罩,感觉观感更差了 ?

code-october avatar Sep 27 '24 12:09 code-october

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


I moved it to the upper right corner, mainly because I was worried that the centering of the prompt text would block the code and affect the look and feel of reading the code. Coupled with the mask, the look and feel would be worse?

Issues-translate-bot avatar Sep 27 '24 12:09 Issues-translate-bot