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

feat(popover): 增加最大宽度设置,支持文本超过最大宽度时,换行展示。 #2851

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented Dec 11, 2024

$popover-menu-item-width: var(--nutui-popover-menu-item-width, 160px) !default;

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新特性

    • 新增 CSS 变量 --nutui-popover-menu-item-width,用于自定义 Popover 组件菜单项的宽度。
  • 文档更新

    • 更新了 Popover 组件的文档,包含了新 CSS 变量的说明,增强了自定义样式选项的全面性。
  • 样式改进

    • .nut-popover-menu-item 类中添加了 max-widthword-wrap 属性,以改善菜单项的布局和可读性。
    • 更新了 .nut-popover-menu-item-name 类的宽度和弹性属性。
  • 变量更新

    • 新增变量 $popover-menu-item-width,用于设置 Popover 菜单项的默认宽度。

Copy link

coderabbitai bot commented Dec 11, 2024

Walkthrough

此次更改引入了新的 CSS 变量 --nutui-popover-menu-item-width,用于定义 Popover 组件中选项菜单项的宽度。该变量的添加增强了 Popover 组件的样式自定义能力。此外,相关文档也进行了更新,以反映这一新变量的使用和效果。

Changes

文件路径 更改摘要
src/packages/popover/doc.en-US.md 添加 CSS 变量 --nutui-popover-menu-item-width
src/packages/popover/doc.md 添加 CSS 变量 --nutui-popover-menu-item-width
src/packages/popover/doc.taro.md 添加 CSS 变量 --nutui-popover-menu-item-width
src/packages/popover/doc.zh-TW.md 添加 CSS 变量 --nutui-popover-menu-item-width
src/packages/popover/popover.scss 添加属性 max-width: $popover-menu-item-width;word-wrap: break-word;
src/styles/variables.scss 添加变量 $popover-menu-item-width: var(--nutui-popover-menu-item-width, 160px) !default;

Possibly related PRs

Suggested labels

size/M, 3.x

Suggested reviewers

  • Alex-huxiyang

🐰 兔子在草地上跳跃,
新变量如春风拂面,
Popover 菜单宽度自定义,
样式更美,内容更鲜,
让我们一起欢庆这变化,
兔子们齐声唱,乐无边! 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ea94cc3 and f923be9.

📒 Files selected for processing (1)
  • src/packages/popover/popover.scss (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/packages/popover/popover.scss

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

@github-actions github-actions bot added the 2.x label Dec 11, 2024
@xiaoyatong xiaoyatong requested a review from irisSong December 11, 2024 02:40
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.02%. Comparing base (601b5d1) to head (f923be9).
Report is 3 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2851   +/-   ##
=======================================
  Coverage   84.01%   84.02%           
=======================================
  Files         219      220    +1     
  Lines       17899    17907    +8     
  Branches     2622     2625    +3     
=======================================
+ Hits        15038    15046    +8     
  Misses       2856     2856           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 601b5d1 and 6b07aff.

📒 Files selected for processing (6)
  • src/packages/popover/doc.en-US.md (1 hunks)
  • src/packages/popover/doc.md (1 hunks)
  • src/packages/popover/doc.taro.md (1 hunks)
  • src/packages/popover/doc.zh-TW.md (1 hunks)
  • src/packages/popover/popover.scss (1 hunks)
  • src/styles/variables.scss (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/packages/popover/doc.en-US.md
🔇 Additional comments (4)
src/packages/popover/doc.taro.md (1)

161-161: 新增的 CSS 变量定义清晰且实用!

新增的 --nutui-popover-menu-item-width 变量很好地解决了长文本展示的问题,默认值 160px 也符合常见的 UI 设计规范。

src/packages/popover/doc.md (1)

170-170: 新增的 CSS 变量定义清晰且实用!

新增的 --nutui-popover-menu-item-width 变量很好地解决了长文本展示的问题,默认值 160px 也符合常见的 UI 设计规范。

src/packages/popover/popover.scss (1)

98-99: 样式变更正确且符合需求!

新增的样式属性可以有效控制菜单项的最大宽度,并在文本超出时自动换行,实现了预期功能。

src/styles/variables.scss (1)

1556-1556: 变量定义合理且具有灵活性!

新增的变量 $popover-menu-item-width 具有以下优点:

  • 遵循了项目的命名规范
  • 提供了合理的默认值 160px
  • 通过 CSS 变量支持运行时自定义
  • 使用 !default 标记允许外部覆盖

@@ -167,3 +167,4 @@ PopoverList 屬性是一個由對象構成的數組,數組中的每個對象
| \--nutui-popover-divider-color | 選項區的底部 border 顏色 | `$color-border` |
| \--nutui-popover-disable-color | 選項禁用的顏色 | `$color-text-disabled` |
| \--nutui-popover-menu-item-padding | 選項區菜單每一項的 padding 值 | `8px` |
| \--nutui-popover-menu-item-width | 選項區菜單每一項宽度值,超过宽度值后,会折行展示,保障信息的完整性 | `160px` |
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

请将说明文字翻译为繁体中文!

新增的 CSS 变量说明仍使用简体中文,需要翻译为繁体中文以保持文档的语言一致性。建议修改为:

-| \--nutui-popover-menu-item-width | 選項區菜單每一項宽度值,超过宽度值后,会折行展示,保障信息的完整性 | `160px` |
+| \--nutui-popover-menu-item-width | 選項區菜單每一項寬度值,超過寬度值後,會折行展示,保障信息的完整性 | `160px` |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| \--nutui-popover-menu-item-width | 選項區菜單每一項宽度值,超过宽度值后,会折行展示,保障信息的完整性 | `160px` |
| \--nutui-popover-menu-item-width | 選項區菜單每一項寬度值,超過寬度值後,會折行展示,保障信息的完整性 | `160px` |

Copy link
Collaborator

@irisSong irisSong left a comment

Choose a reason for hiding this comment

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

image
image

有icon会异常,可考虑增加一个demo展示这种形态

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants