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: remove 无意义的样式变量 #2827

Draft
wants to merge 1 commit into
base: feat_v3.x
Choose a base branch
from

Conversation

xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented Dec 4, 2024

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

  • 新特性
    • 更新了多个组件的样式,移除了 CSS 变量,采用固定值以简化样式定义。
    • 增强了样式变量的可配置性,新增了多个颜色和间距变量,以统一设计语言。
  • 样式
    • 调整了 .nut-col 类的样式,移除了未使用的浮动属性。
    • 更新了多个组件的边框半径,减少了视觉效果的圆润度。

Copy link

coderabbitai bot commented Dec 4, 2024

Walkthrough

本次更改主要涉及多个组件的样式调整和SCSS变量的更新。具体而言,src/packages/col/col.scss中删除了未使用的浮动属性,而在多个演示组件中,CSS变量被替换为固定值,以简化样式定义。此外,src/styles/variables.scss文件中引入了新的颜色和间距变量,并更新了现有变量的默认值,以增强样式的可配置性和一致性。

Changes

文件路径 更改摘要
src/packages/col/col.scss 删除了.nut-col类中的注释行//float: left;。保留了其他样式。
src/packages/layout/demos/h5/demo1.tsx .layout-flex-content类中的CSS变量替换为固定值。
src/packages/layout/demos/h5/demo2.tsx .layout-flex-content类中的CSS变量替换为固定值。
src/packages/layout/demos/h5/demo3.tsx .layout-flex-content类中的CSS变量替换为固定值。
src/packages/layout/demos/taro/demo1.tsx flexContent样式中的borderRadiuspxTransform(6)更改为pxTransform(2)
src/packages/layout/demos/taro/demo2.tsx flexContent样式中的borderRadiuspxTransform(6)更改为pxTransform(2)
src/packages/layout/demos/taro/demo3.tsx flexContent样式中的borderRadiuspxTransform(6)更改为pxTransform(2)
src/styles/variables.scss 更新和添加多个CSS变量,增强样式的可配置性和一致性。

Possibly related PRs

Suggested labels

size/XS, 2.x

Suggested reviewers

  • oasis-cloud

兔子欢快跳跃,样式焕然一新,
删除浮动,简化更清晰。
颜色变量已不再,
固定值让设计更自在。
组件风格齐整齐,
兔子乐在其中,真是美丽! 🐇✨


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.

@github-actions github-actions bot added the 3.x label Dec 4, 2024
@xiaoyatong xiaoyatong requested a review from irisSong December 4, 2024 12:54
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

🧹 Outside diff range and nitpick comments (4)
src/packages/layout/demos/h5/demo2.tsx (1)

7-11: 样式变量替换为固定值的修改已确认

这些改动移除了不必要的样式变量,使用固定值替代,简化了代码结构。不过建议考虑将这些常用的颜色值和尺寸提取到一个集中的主题配置中,以便将来统一管理和修改。

当前修改:

  • 行高固定为 40px
  • 边框圆角改为 2px
  • 背景色使用固定的十六进制值

建议将这些值统一到一个主题配置文件中:

// theme.ts
export const theme = {
  colors: {
    primary: '#ff8881',
    primaryLight: '#ffc7c4',
  },
  radius: {
    small: '2px',
  },
  lineHeight: {
    default: '40px',
  },
}

Also applies to: 16-16

src/packages/layout/demos/taro/demo1.tsx (1)

Line range hint 1-1: 建议优化样式管理架构

当前的改动移除了样式变量,使用固定值替代,这确实简化了代码。但从长远来看,建议考虑以下架构优化:

  1. 建立统一的设计令牌(Design Tokens)系统
  2. 实现主题配置机制
  3. 确保 H5 和 Taro 版本共享相同的设计变量

这样可以:

  • 提高样式的可维护性
  • 确保跨平台的一致性
  • 简化未来的主题定制需求
src/packages/layout/demos/h5/demo1.tsx (1)

7-11: 建议使用主题变量而不是硬编码值

虽然移除了无用的样式变量,但建议将颜色值(如 #ff8881#ffc7c4)和其他可能需要主题定制的值(如 border-radius)改为使用主题变量。这样可以:

  • 保持样式的一致性
  • 便于主题定制
  • 简化后续的样式维护

建议参考以下修改方案:

.layout-flex-content {
  line-height: 40px;
  color: #fff;
  text-align: center;
-  border-radius: 2px;
-  background: #ff8881;
+  border-radius: var(--nutui-radius-sm, 2px);
+  background: var(--nutui-brand-color, #ff8881);
  font-size: 14px;
}

.layout-flex-content-light {
-  background: #ffc7c4;
+  background: var(--nutui-brand-color-light, #ffc7c4);
}

Also applies to: 16-16

src/packages/layout/demos/taro/demo3.tsx (1)

15-15: 建议使用主题变量定义圆角值

虽然此更改保持了与 H5 版本的一致性,但建议使用主题变量来定义圆角值,以便于统一管理和维护。

建议参考以下修改方案:

- borderRadius: pxTransform(2),
+ borderRadius: pxTransform(theme.radiusSm || 2),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 41c2255 and 6342f6d.

📒 Files selected for processing (8)
  • src/packages/col/col.scss (0 hunks)
  • src/packages/layout/demos/h5/demo1.tsx (1 hunks)
  • src/packages/layout/demos/h5/demo2.tsx (1 hunks)
  • src/packages/layout/demos/h5/demo3.tsx (1 hunks)
  • src/packages/layout/demos/taro/demo1.tsx (1 hunks)
  • src/packages/layout/demos/taro/demo2.tsx (1 hunks)
  • src/packages/layout/demos/taro/demo3.tsx (1 hunks)
  • src/styles/variables.scss (1 hunks)
💤 Files with no reviewable changes (1)
  • src/packages/col/col.scss
🔇 Additional comments (3)
src/packages/layout/demos/taro/demo2.tsx (1)

15-15: 边框圆角数值调整已确认

borderRadiuspxTransform(6) 调整为 pxTransform(2),保持了与 H5 版本的视觉一致性,同时正确使用了 pxTransform 确保跨平台兼容性。

src/packages/layout/demos/taro/demo1.tsx (1)

16-16: 保持示例代码一致性的修改已确认

borderRadius 值统一调整为 pxTransform(2),与其他示例保持一致,有助于维护代码的统一性和可预测性。

src/styles/variables.scss (1)

2401-2401: 请验证此间距调整的影响范围

将列组件的默认下边距从 15px 减少到 10px 可能会影响现有布局。建议:

  1. 检查此变更是否符合设计规范
  2. 验证对现有页面布局的影响
  3. 确认是否需要在文档中说明此变更
✅ Verification successful

Based on the search results, I can now provide a final verification response:

此变更影响范围可控且合理

  1. col-default-margin-bottom 变量仅在以下文件中使用:

    • src/packages/col/col.scss: 用于设置列组件的下边距
    • 在主题变量文件中定义: src/styles/variables.scss, variables-jrkf.scss, variables-jmapp.scss
    • 在组件文档中记录: src/packages/layout/doc.md 及其多语言版本
  2. 此调整是合理的,因为:

    • 变更是全局一致的,所有使用此变量的地方都会同步更新
    • 从15px减少到10px的调整幅度适中,不会导致布局剧烈变化
    • 变更已在文档中明确记录
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 搜索使用了 col-default-margin-bottom 变量的文件
rg --type scss "col-default-margin-bottom"

# 搜索可能受影响的 Col 组件使用处
rg --type tsx "Col"

Length of output: 119


Script:

#!/bin/bash
# Search for col-default-margin-bottom variable usage
rg "col-default-margin-bottom"

# Search for Col component references
rg "Col"

# Search for SCSS files that might contain the variable
fd -e scss

# Search for component files that might use Col
fd -e tsx -e jsx

Length of output: 75270

Comment on lines +7 to +11
line-height: 40px;
color: #fff;
text-align: center;
border-radius: var(--nutui-row-content-border-radius, 6px);
background: var(
--nutui-row-content-background-color,
var(--row-content-bg-color, #ff8881)
);
border-radius: 2px;
background: #ff8881;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议合并重复的样式定义

当前的样式定义与 demo1.tsx 完全相同。建议将这些共用样式提取到一个共享的样式文件中,以减少代码重复并简化维护。

建议创建一个共享的样式文件(例如 layout-demo.scss),然后在各个 demo 组件中引用:

+ // src/packages/layout/demos/h5/layout-demo.scss
+ .layout-flex-content {
+   line-height: 40px;
+   color: #fff;
+   text-align: center;
+   border-radius: var(--nutui-radius-sm, 2px);
+   background: var(--nutui-brand-color, #ff8881);
+   font-size: 14px;
+ }
+ 
+ .layout-flex-content-light {
+   background: var(--nutui-brand-color-light, #ffc7c4);
+ }

// demo1.tsx 和 demo3.tsx
- const style = `
-   .layout-flex-content { ... }
-   .layout-flex-content-light { ... }
- `
+ import './layout-demo.scss'

Also applies to: 16-16

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.00%. Comparing base (41c2255) to head (6342f6d).

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #2827   +/-   ##
==========================================
  Coverage      84.00%   84.00%           
==========================================
  Files            220      220           
  Lines          17901    17901           
  Branches        2678     2678           
==========================================
  Hits           15038    15038           
  Misses          2858     2858           
  Partials           5        5           

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

@xiaoyatong xiaoyatong marked this pull request as draft December 5, 2024 02:16
@@ -4,16 +4,16 @@ import { Row, Col } from '@nutui/nutui-react'
const Demo1 = () => {
const style = `
.layout-flex-content {
line-height: var(--nutui-row-content-line-height, 40px);
Copy link
Collaborator

Choose a reason for hiding this comment

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

样式变量删除,doc里面是不是也要删除

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