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: button css 简化 和 Demo 调整 #2375

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented Jun 21, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 样式

    • 调整按钮组件的字体大小、颜色和布局,包括不同状态下的按钮(主要、成功、信息、危险、警告)的颜色。
    • 增加子元素样式,优化按钮排版和显示。
  • 新功能

    • 在按钮组件中,根据平台兼容性进行条件渲染。
    • 在多个示例中,将按钮组件包裹在 Cell 组件中,提高布局灵活性。
  • 改进

    • 简化按钮背景色变量的定义,使用单一颜色代替渐变色。
  • 文档

    • 更新多个按钮组件示例,添加和使用新的演示组件。

Copy link

coderabbitai bot commented Jun 21, 2024

Walkthrough

这个更新主要涉及按钮元素样式和功能的调整。CSS 和 SCSS 文件的变化包括重新排序属性、调整字体大小和权重、修改不同按钮状态的颜色,以及添加子元素样式。TypeScript 文件的改动则引入了平台相关的条件渲染。此外,还更新了多个演示文件,保证按钮在不同平台上的一致性和更好的布局效果。

Changes

文件路径 变更摘要
src/packages/button/button.harmony.css 调整 .nut-button 类的属性顺序,改动字体大小和权重,修改按钮状态的颜色,增加子元素样式
src/packages/button/button.scss 调整按钮样式的边框、颜色及背景属性,并根据平台兼容性添加条件样式
src/packages/button/button.taro.tsx 引入 harmonyAndRn 以实现平台条件渲染,修改 ButtonPropsnativeType 属性
src/packages/button/demo.taro.tsx 引入和使用新的演示组件 Demo4Demo5,简化组件渲染结构
src/packages/button/demos/h5/demo2.tsx 为按钮组件添加 type="primary" 属性
src/packages/button/demos/taro/demo1.tsx 引入 Cell 组件并将按钮包裹在 Cell 组件内
src/packages/button/demos/taro/demo2.tsx - demo9.tsx 在多个demo文件中引入 Cell 组件,并将按钮包裹在 Cell 组件内,调整按钮布局
src/styles/variables.scss 简化 $button-primary-background-color 变量的定义,直接引用 $color-primary 变量

Poem

按钮样式巧调整,
颜色字体俱更新。
平台兼容有妙招,
Demo演示齐焕新。
代码整洁如新衣,
UX提升如春风。

   (\(\ 
  ( -.-)
 o_(")(")

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2b31483 and 19a9ca1.

Files selected for processing (16)
  • src/packages/button/button.harmony.css (10 hunks)
  • src/packages/button/button.scss (17 hunks)
  • src/packages/button/button.taro.tsx (3 hunks)
  • src/packages/button/demo.taro.tsx (2 hunks)
  • src/packages/button/demos/h5/demo2.tsx (1 hunks)
  • src/packages/button/demos/taro/demo1.tsx (1 hunks)
  • src/packages/button/demos/taro/demo10.tsx (2 hunks)
  • src/packages/button/demos/taro/demo2.tsx (2 hunks)
  • src/packages/button/demos/taro/demo3.tsx (2 hunks)
  • src/packages/button/demos/taro/demo4.tsx (1 hunks)
  • src/packages/button/demos/taro/demo5.tsx (1 hunks)
  • src/packages/button/demos/taro/demo6.tsx (1 hunks)
  • src/packages/button/demos/taro/demo7.tsx (2 hunks)
  • src/packages/button/demos/taro/demo8.tsx (2 hunks)
  • src/packages/button/demos/taro/demo9.tsx (1 hunks)
  • src/styles/variables.scss (1 hunks)
Files skipped from review due to trivial changes (2)
  • src/packages/button/demo.taro.tsx
  • src/packages/button/demos/h5/demo2.tsx
Additional comments not posted (33)
src/packages/button/demos/taro/demo9.tsx (2)

2-2: 优化组件引入

引入了 ButtonCell 组件,这有助于后续的组件布局和样式调整。这是一个合理的改动,有助于代码的模块化和可维护性。


6-10: 改进组件结构

通过将 Button 组件包裹在 Cell 组件中,优化了布局和样式的处理。这种做法提高了组件的灵活性和可重用性,符合最佳实践。

src/packages/button/demos/taro/demo1.tsx (2)

2-2: 优化组件引入

demo9.tsx 类似,引入了 ButtonCell 组件。这有助于在组件间实现更好的协同工作,提高代码的整洁度和可维护性。


7-14: 结构调整以增强布局灵活性

通过使用 Cell 组件来包裹不同的 Button 组件,优化了页面的布局。这种做法不仅使得页面更加整洁,还提高了组件的可重用性和维护性。

src/packages/button/demos/taro/demo6.tsx (2)

2-2: 优化组件引入

引入了 ButtonCell 组件,有助于提升代码的模块化和可维护性。这是一个积极的改变,符合现代前端开发的趋势。


7-14: 改进组件结构和布局

Button 组件包裹在 Cell 组件中,这有助于更好地管理组件间的空间和布局。这种结构调整是合理的,有助于提高代码的可读性和可维护性。

src/packages/button/demos/taro/demo3.tsx (2)

2-2: 优化组件引入

引入了 ButtonCell 组件,这是一个积极的改变,有助于提升代码的模块化和可维护性。这种做法符合现代前端开发的趋势。


Line range hint 7-20: 优化组件布局和样式

通过 Cell 组件包裹 Button 组件,优化了组件间的布局和样式处理。这种结构调整有助于提高页面的整洁度和组件的可维护性。

src/packages/button/demos/taro/demo7.tsx (1)

2-2: 代码整合良好,布局更加合理。

添加了 Cell 组件来包装 Button 组件,这有助于改善按钮的布局和样式。建议进行视觉检查以确保布局的改动符合设计预期。

Also applies to: 8-25

src/packages/button/demos/taro/demo2.tsx (1)

2-2: 布局优化,代码整洁。

通过使用 Cell 组件包装 Button 组件,使得按钮布局更加清晰和一致。请确保这些变化在不同设备和平台上的显示效果符合预期。

Also applies to: 7-26

src/packages/button/demos/taro/demo8.tsx (1)

2-2: 代码一致性增强,布局更加整齐。

在此文件中,Cell 组件的添加用于包装 Button 组件,这有助于提升按钮的视觉和交互质量。建议进行视觉检查以确保布局的改动符合设计预期。

Also applies to: 7-24

src/packages/button/demos/taro/demo10.tsx (1)

2-2: 布局调整合理,代码风格一致。

Cell 组件的使用提升了按钮组件的布局和风格一致性。请确保这些变化在不同设备和平台上的显示效果符合预期。

Also applies to: 7-42

src/packages/button/demos/taro/demo4.tsx (2)

2-4: 导入语句的调整

添加了 Cell 组件的导入,这有助于改善布局和样式。此外,还导入了 harmonyAndRn 函数,用于条件渲染,这是一个合理的改动。


10-126: 条件渲染和按钮样式的调整

通过 harmonyAndRn 函数进行条件渲染,以控制不同平台下的展示方式。这可以确保组件在不同环境下的兼容性和一致性。所有的按钮都被放置在 Cell 组件中,这有助于更好地管理布局和间距。每个按钮都具有一致的 marginStyle,这保证了整体的视觉一致性。

src/packages/button/demos/taro/demo5.tsx (2)

2-4: 导入语句的调整

demo4.tsx 类似,此文件也正确地导入了所需的组件和函数。这有助于确保代码的一致性和功能的正确实现。


10-131: 条件渲染和禁用按钮的调整

此文件中的所有按钮都设置为禁用状态,这可能用于展示按钮在禁用状态下的样式。条件渲染的使用确保了组件在不同平台下的正确显示,这是一个明智的设计选择。

src/packages/button/button.taro.tsx (3)

9-12: 导入语句的调整

导入了 harmonyAndRn 函数,这对于实现基于平台的条件样式非常关键。这是一个合理的改动,有助于增强组件的可用性和灵活性。


43-43: 属性调整:nativeType

ButtonProps 中添加了 'button' 作为 nativeType 的一个可选值。这提供了更多的灵活性,使得按钮可以更好地适应不同的表单行为。


134-134: 点击事件处理

优化了点击事件的处理逻辑,使其更加清晰和易于管理。这有助于避免在加载或禁用状态下触发不必要的动作。

src/packages/button/button.harmony.css (2)

6-6: 样式调整

移除了 width: 100px; 并调整了其他样式以适应不同的按钮尺寸和状态。这有助于使按钮的样式更加灵活和响应不同的布局需求。


27-27: 颜色和字体权重的调整

调整了多个类的颜色和字体权重,这有助于提升视觉层面的吸引力和信息的清晰度。特别是在不同状态(如禁用或加载)下,这些调整确保了按钮的可读性和视觉一致性。

Also applies to: 64-66, 111-112, 115-117, 123-123, 152-152, 186-187, 220-221, 254-255, 288-289, 322-323

src/packages/button/button.scss (11)

25-25: 调整边框属性的写法

原代码中关于边框的属性被拆分为三个独立的属性,这样的改动可以增加代码的可读性,同时也便于后续的维护。这种写法更符合CSS的标准实践。


69-71: 移除特定平台的背景设置

在这里使用条件编译来针对非 rn harmony 平台移除背景设置。这是一种针对多平台支持进行优化的良好实践,确保了样式在不同环境下的一致性。


93-94: 精简边框样式的声明

通过将边框样式的声明分开,使得代码更为清晰和易于管理。这种改动有助于在未来需要调整边框样式时,可以更快速地定位和修改。


105-106: 调整禁用状态下的按钮样式

这里对禁用状态下的按钮进行了背景和文字颜色的调整,这样的改动使得用户界面在禁用状态下更为清晰,用户体验得到提升。


Line range hint 187-197: 优化边框和禁用状态的样式

这段代码调整了边框颜色,并为禁用状态下的按钮添加了特定的样式。这是一个很好的实践,能够确保不同状态下按钮的视觉效果更加一致和专业。


Line range hint 210-232: 成功按钮的样式调整

对成功按钮的样式进行了一系列调整,包括背景、边框和禁用状态的颜色。这种细致的调整有助于突出按钮在不同状态下的视觉效果,增强用户的交互体验。


Line range hint 240-262: 信息按钮的样式细节调整

对信息按钮的样式进行了调整,特别是在禁用状态下的颜色和边框设置。这样的改动有助于在应用中更好地利用视觉层次感,使按钮的功能和状态更加明确。


Line range hint 270-292: 危险按钮的样式调整

这段代码对危险按钮的样式进行了调整,特别是在背景和边框的颜色上。这有助于在用户界面中更好地突出这类按钮的重要性和警告性质。


Line range hint 300-322: 警告按钮的样式调整

对警告按钮的样式进行了全面的调整,确保在不同状态下的视觉效果都能够达到预期的标准。这种颜色和样式的调整对于提升用户的注意力和反应是非常有帮助的。


331-338: 轮廓和虚线按钮的背景和边框样式调整

这里对轮廓和虚线按钮的样式进行了调整,通过设置透明背景和明确的边框样式,使得按钮的设计更加灵活和适应不同的背景环境。


168-170: 主要按钮的背景和边框颜色调整

对主要按钮的背景和边框颜色进行了调整,这可能是为了更好地与应用的整体风格保持一致。请确保这些颜色的变更在所有相关的界面中都进行了测试,以保证视觉效果的统一。

Verification successful

主要按钮的背景和边框颜色调整已在多个相关界面中进行更新,包括 calendar.scssbutton.scssaddress.scss 文件。这些变更在代码库中显现出一致性。

  • 位置:
    • src/packages/calendar/calendar.scss
    • src/packages/button/button.scss
    • src/packages/address/address.scss

请确保在所有相关界面中进行视觉效果的测试,以保证统一的用户体验。

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the primary button's color changes are reflected across all relevant interfaces.

# Test: Search for the primary button's color usage. Expect: Consistent color usage across interfaces.
rg --type scss $'button-primary-background-color'

Length of output: 77



Script:

#!/bin/bash
# Description: Verify that the primary button's color changes are reflected across all relevant interfaces.

# Test: Search for the primary button's color usage. Expect: Consistent color usage across interfaces.
rg 'button-primary-background-color'

Length of output: 459

src/styles/variables.scss (1)

276-276: 简化按钮的背景色设置

这次更改将 $button-primary-background-color 的定义从复杂的线性渐变简化为直接引用 $color-primary 变量。这种简化有助于减少代码的复杂性,并可能提高样式计算的性能。


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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant