Skip to content

fix: 🐛 修复 Button 按钮设置为 block 无效的问题#762

Merged
Moonofweisheng merged 1 commit into
masterfrom
fix/button-block
Dec 5, 2024
Merged

fix: 🐛 修复 Button 按钮设置为 block 无效的问题#762
Moonofweisheng merged 1 commit into
masterfrom
fix/button-block

Conversation

@Moonofweisheng

@Moonofweisheng Moonofweisheng commented Dec 5, 2024

Copy link
Copy Markdown
Owner

🤔 这个 PR 的性质是?(至少选择一个)

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

🔗 相关 Issue

💡 需求背景和解决方案

调整Button样式,支持block

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

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

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新功能

    • 改进了按钮的布局和响应性,增强了用户体验。
    • 引入了新的内容包装结构,优化了加载状态和图标的显示方式。
  • 样式

    • 调整了按钮的显示属性,确保内容在不同状态下的对齐方式更加合理。

@vercel

vercel Bot commented Dec 5, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 10:56am

@netlify

netlify Bot commented Dec 5, 2024

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit dbcac46
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/675186de74ca850008b21cca
😎 Deploy Preview https://deploy-preview-762--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@coderabbitai

coderabbitai Bot commented Dec 5, 2024

Copy link
Copy Markdown

Walkthrough

此次变更涉及 wd-button 组件的样式和模板结构。index.scss 文件中的按钮显示属性已从 inline-flex 更改为 inline-block,并在不同状态下进行了布局调整。同时,wd-button.vue 文件引入了新的 <view> 包裹元素,改进了加载状态和图标的渲染逻辑,使按钮内容的组织更加清晰。整体结构保持不变,未对导出或公共实体的声明进行修改。

Changes

文件路径 更改摘要
src/uni_modules/wot-design-uni/components/wd-button/index.scss 修改按钮的显示属性和布局,添加新样式以改进内容对齐,设置中等按钮的最小宽度,移除圆形按钮的最小宽度。
src/uni_modules/wot-design-uni/components/wd-button/wd-button.vue 引入新的 <view> 元素以包裹加载状态和图标,改进按钮内容的渲染逻辑,确保加载状态下的内容组织更清晰。

Poem

在按钮中跳跃,样式变幻,
加载状态下,内容更显然。
小兔子欢喜,布局更美妙,
点击之间,快乐无穷遥。 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 356cb4a and dbcac46.

📒 Files selected for processing (2)
  • src/uni_modules/wot-design-uni/components/wd-button/index.scss (4 hunks)
  • src/uni_modules/wot-design-uni/components/wd-button/wd-button.vue (1 hunks)
🔇 Additional comments (3)
src/uni_modules/wot-design-uni/components/wd-button/wd-button.vue (1)

41-46: 模板结构优化得当!

新增的 wd-button__content 包装元素改进了按钮内容的组织结构,使得内容居中对齐更加可控,同时也便于实现 block 属性的样式效果。加载状态和图标的条件渲染逻辑清晰合理。

src/uni_modules/wot-design-uni/components/wd-button/index.scss (2)

45-45: 按钮显示属性修改合理!

将基础显示属性从 inline-flex 改为 inline-block,并在 block 模式下使用 display: block 是正确的做法,这样可以确保按钮在不同场景下都能正确展示。

Also applies to: 289-289


80-85: 建议验证样式改动的影响范围

  1. 新增的 wd-button__content 样式使用 flex 布局很合适,可以确保内容居中对齐。
  2. 但在 medium 尺寸下新增的 min-width: 120px 可能会影响现有页面的按钮布局。

运行以下脚本来检查可能受影响的页面:

Also applies to: 155-156

✅ Verification successful

Let's examine the actual usage of these medium buttons to understand the impact better.


Let's check the actual CSS changes to understand if there's any min-width property being added:


Let's try a different approach to find the size-related styles:


样式改动影响范围已确认

经过验证,发现:

  1. medium 尺寸按钮确实添加了 min-width: 120px 的样式,但有以下例外:
    • 当按钮设置 roundicon 属性时,min-width 会被重置为 0
    • 当按钮设置 roundtext 属性时,min-width 也会被重置为 0
  2. 目前使用 medium 尺寸按钮的地方仅有:
    • 文档示例页面
    • 按钮演示页面
    • 隐私弹窗组件(已使用 round 属性,不受影响)

由于实际业务代码中的使用场景有限,且关键场景都使用了 round 属性规避了最小宽度的限制,这个样式改动的影响范围可控。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:查找使用了 medium 尺寸按钮的页面

# 搜索包含 wd-button 且设置了 size="medium" 的文件
rg -l "wd-button.*size=\"medium\""

Length of output: 139


Script:

#!/bin/bash
# Check the actual usage context of medium buttons in the found files
rg -A 5 -B 5 "wd-button.*size=\"medium\"" src/pages/button/Index.vue src/components/wd-privacy-popup/wd-privacy-popup.vue docs/component/button.md

Length of output: 2490


Script:

#!/bin/bash
# Check the button component's SCSS file for size-related styles
rg -A 10 "@include m\(medium\)" src/uni_modules/wot-design-uni/components/wd-button/index.scss

Length of output: 96


Script:

#!/bin/bash
# Check the entire button SCSS file content
cat src/uni_modules/wot-design-uni/components/wd-button/index.scss

Length of output: 6202


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.

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.

1 participant