fix: add fold-code button when code is expand
💻 变更类型 | 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
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 is attempting to deploy a commit to the NextChat Team on Vercel.
A member of the Team first needs to authorize it.
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
CustomCodecomponent to change button text to a dynamic value, related to the toggle button rendering logic. -
#5377: Adds an optional
classNameproperty to theCustomCodefunction, enhancing styling flexibility relevant to the rendering logic changes. -
#5495: Alters the
onClickevent handler in thePreCodecomponent, 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?
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Your build has completed!
Preview deployment
查看全部在顶部,居中。 所以,折叠收起,应该在底部居中,应该同样有一个遮罩层,只是颜色渐变是相反的。
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.
@lloydzhou 我移动到右上角,主要是担心提示文字居中会遮挡代码,影响阅读代码观感,这再加上遮罩,感觉观感更差了 ?
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?