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: stepper #746

Merged
merged 1 commit into from
May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Stepper/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
overflow: hidden;
box-sizing: border-box;

&-button {
& &-button {
width: 56 * @rpx;
height: 56 * @rpx;
line-height: 56 * @rpx;
Expand All @@ -19,25 +19,25 @@
background-color: @COLOR_BACKGROUND;
}

&-button-hover {
& &-button-hover {
background-color: fade(@COLOR_BLACK_CHANGE, 8%);
}

&-button-up {
& &-button-up {
border-top-left-radius: 0;
border-top-right-radius: 4 * @rpx;
border-bottom-left-radius: 0;
border-bottom-right-radius: 4 * @rpx;
}

&-button-down {
& &-button-down {
border-top-right-radius: 0;
border-top-left-radius: 4 * @rpx;
border-bottom-right-radius: 0;
border-bottom-left-radius: 4 * @rpx;
}

&-button-disabled {
& &-button-disabled {
color: @COLOR_TEXT_ASSIST;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

这段代码是在一个样式文件中定义了一些按钮的样式。以下是我对代码的简要审核和建议:

  1. 第 10 行 "& &-button" 看起来略微冗长,不过从逻辑上讲,它是正确的,因为 & 符号代表的是父级选择器。因此,如果要创建一个 .foo-button 的按钮,在引用这个样式时,我们可以这样写:.foo { .button-styles &-button }。所以这个代码块在语言层面上没有问题。

  2. 接下来几个规则集中使用了边框半径,建议将常量 @rpx 提取到变量中,例如 "@border-radius: 4 * @rpx",然后在规则集中使用 "@border-radius"。

  3. 在第 23 和 29 行中,可以将属性排序以提高可读性。你可以按以下顺序编排:display, position, box-sizing, width, height, margin, padding, overflow, border, background-color等。

希望这些建议能对你有所帮助。

Expand All @@ -53,7 +53,7 @@
box-sizing: border-box;
background-color: @COLOR_BACKGROUND;
padding: 7 *@rpx 14 *@rpx;
caret-color: #1677ff;
caret-color: @COLOR_BRAND1;

&-disabled {
opacity: 0.4;
Copy link
Contributor

Choose a reason for hiding this comment

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

这段代码实现了一个按钮组件的样式,并在不同状态下应用对应的样式。以下是一些改进和可能的风险:

  • 第11行,使用 & &-button 似乎是重复的,建议改为 &-button。
  • 第12-14行,可以考虑使用变量存储按钮尺寸(如 @btn-size:56),以提高可维护性。
  • 第24-43行,涉及到边框半径和按钮状态的处理,这种代码结构可能会导致错误。建议将每个状态的 CSS 规则拆分为单独的类,并分别应用这些类而不是添加新的规则。
  • 第47行,使用了硬编码的颜色值。建议使用与其他地方相同的变量或常量来更好地管理颜色。
  • 最后6行,padding 可能受到响应性设计的约束。如果当前版本的 @rpx 大小不随屏幕宽度而调整,则需要调整 padding 尺寸。

风险:当前的代码片段只包含样式代码,而没有与 HTML 元素匹配。因此,我们无法确保它是否可以正常工作,而且还有其他潜在的风险,例如防止过度修饰或覆盖其他样式。

Expand Down