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

refactor(theme): [slider] refactor slider theme vars #2295

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Oct 18, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Updated styling for disabled control icons, enhancing visual feedback for checkboxes and radio buttons.
    • Refined slider component styles with a new naming convention for CSS variables, improving consistency and maintainability.
  • Bug Fixes

    • Adjusted hover and disabled states for the slider to ensure proper visual representation.
  • Chores

    • Cleaned up unused CSS variable definitions in the slider component.

Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request introduces modifications to the vars.less file, updating the value of the variable --tv-color-icon-control-disabled to a new color representation. Additionally, the slider component's LESS files have undergone significant changes, including the renaming of CSS variables to a new convention prefixed with tv- and adjustments in the method used to inject these styles. The overall structure of the files remains intact, with a focus on enhancing consistency and organization in the styling of the slider component.

Changes

File Change Summary
packages/theme/src/base/vars.less Updated variable --tv-color-icon-control-disabled from var(--tv-base-color-common-6); // #1476ff to var(--tv-base-color-common-6); // #dbdbdb.
packages/theme/src/slider/index.less Renamed CSS variables to prefix with tv-, updated method call from .component-css-vars-slider() to .inject-Slider-vars(), and made various styling adjustments for hover and disabled states.
packages/theme/src/slider/vars.less Refactored CSS variable declarations, renaming all variables from --ti- to --tv-, and updated method name from .component-css-vars-slider() to .inject-Slider-vars(). Cleaned up unused variables.

Possibly related PRs

Suggested labels

refactoring

Poem

In the land of code where colors gleam,
A rabbit hops, chasing a dream.
With sliders sleek and icons bright,
We change the hues, oh what a sight!
From ti- to tv-, a fresh new start,
In our theme's embrace, we take to heart! 🐇✨


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 refactoring Refactoring (重构) label Oct 18, 2024
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: 3

🧹 Outside diff range and nitpick comments (1)
packages/theme/src/slider/vars.less (1)

59-59: Consider using a relative unit for --tv-Slider-input-width

On line 59, --tv-Slider-input-width is set to 80px. For better scalability and responsiveness across different devices, consider using a relative unit like em or rem. This allows the input width to adjust based on the root font size.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5ccd986 and c971718.

📒 Files selected for processing (3)
  • packages/theme/src/base/vars.less (1 hunks)
  • packages/theme/src/slider/index.less (8 hunks)
  • packages/theme/src/slider/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (5)
packages/theme/src/base/vars.less (2)

Line range hint 1-597: Well-organized and comprehensive design token system.

The vars.less file presents a well-structured and comprehensive set of design tokens. The organization into categories such as colors, typography, spacing, and shadows provides a solid foundation for maintaining consistency across the application. This structure will facilitate easier updates and maintenance of the design system in the future.


297-297: Approve color change for disabled control icons, but verify consistency.

The color for --tv-color-icon-control-disabled has been updated from #1476ff to #dbdbdb. This lighter color is more appropriate for a disabled state, improving visual feedback for users. However, please ensure this change is intentional and consistent with the overall design system.

To ensure consistency, let's check if there are any other occurrences of the old color value that might need updating:

packages/theme/src/slider/vars.less (2)

82-82: Verify the reference for --tv-Slider-tips-border-color

On line 82, --tv-Slider-tips-border-color is set to var(--tv-Slider-tips-bg-color). If the intention is for the border color to match the background color of the tips, this is acceptable. However, if a distinct border color is desired, please verify and update the reference accordingly.


15-84: Consistency in variable naming and usage

The refactoring updates variable prefixes from --ti- to --tv-, aligning with the new naming convention. Excellent work ensuring that all variables follow this convention consistently.

packages/theme/src/slider/index.less (1)

Line range hint 21-248: CSS Variable Refactoring Enhances Consistency

The refactoring of CSS variables to the new --tv-Slider- prefix significantly improves the consistency and maintainability of the codebase. The updated variable names are clear and adhere to the established naming convention, ensuring that styles are easier to manage and understand.

--ti-slider-range-top: calc(-1 * var(--ti-common-space-base));
// 滑块进度条顶部外边距
--ti-slider-range-margin-top: 0;
--tv-Slider-range-top: -4px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Adjust --tv-Slider-range-top for better alignment

On line 32, --tv-Slider-range-top is set to -4px. Ensure that this negative value correctly aligns the slider range with the handle. It might be beneficial to calculate this value based on the slider height or handle dimensions to maintain consistency if those sizes change.

Comment on lines +43 to +54
--tv-Slider-handle-border-color: var(--tv-color-border-disabled);
// 滑块点圆角
--ti-slider-handle-border-radius: var(--ti-common-border-radius-5, 12px);
--tv-Slider-handle-border-radius: var(--tv-border-radius-round);

// 滑块点悬浮文本色
--ti-slider-handle-text-color-hover: var(--ti-common-color-bg-hover, #595959);
--tv-Slider-handle-text-color-hover: var(--tv-color-text-secondary);
// 滑块点悬浮边框色
--ti-slider-handle-border-color-hover: var(--ti-common-color-data-1, #1476ff);
--tv-Slider-handle-border-color-hover: var(--tv-color-border-active-control);
// 滑块点阴影
--ti-slider-handle-box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
// 滑块点top
--ti-slider-handle-top: calc(-1 * var(--ti-common-space-base));
// 滑块点边框厚度
--ti-slider-handle-border-weight: var(--ti-common-border-weight-normal, 1px);
// 滑块点边框悬浮厚度
--ti-slider-handle-border-weight-hover: var(--ti-common-border-weight-1, 2px);
// 滑块点图标的display(hide)
--ti-slider-handle-icon-display: none;
// 滑块点图标色
--ti-slider-handle-icon-fill-color: var(--ti-common-color-data-1, #1476ff);
// 滑块点图标悬浮色
--ti-slider-handle-icon-fill-color-hover: var(--ti-common-color-bg-hover, #595959);
// 滑块点的缩放值(hide)
--ti-slider-handle-transform: scale(1);
// 滑块点顶部外边距
--ti-slider-handle-margin-top: calc(var(--ti-common-space-2x, 8px) * -1);
// 滑块点水平外边距
--ti-slider-handle-margin-horizontal: calc(var(--ti-common-space-2x, 8px) * -1);
// 滑块点底部外边距
--ti-slider-handle-margin-bottom: var(--ti-common-space-0, 0px);
// 滑块点禁用时图标颜色
--ti-slider-handle-icon-disabled-fill-color: var(--ti-common-color-icon-disabled, #c2c2c2);
--tv-Slider-handle-box-shadow: var(--tv-shadow-1-down);
// 滑块点禁用时边框颜色
--ti-slider-handle-disabled-border-color: var(--ti-common-color-icon-disabled, #c2c2c2);
--tv-Slider-handle-disabled-border-color: var(--tv-color-border);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent assignment of border colors for slider handle

It appears that the border colors for the slider handle in its default and disabled states might be inverted:

  • Line 43: --tv-Slider-handle-border-color is set to var(--tv-color-border-disabled), which suggests the handle is in a disabled state.
  • Line 54: --tv-Slider-handle-disabled-border-color is set to var(--tv-color-border), which is typically used for enabled elements.

To maintain consistency and ensure the correct visual representation, consider swapping the variable assignments:

- --tv-Slider-handle-border-color: var(--tv-color-border-disabled);
+ --tv-Slider-handle-border-color: var(--tv-color-border);

...

- --tv-Slider-handle-disabled-border-color: var(--tv-color-border);
+ --tv-Slider-handle-disabled-border-color: var(--tv-color-border-disabled);
📝 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
--tv-Slider-handle-border-color: var(--tv-color-border-disabled);
// 滑块点圆角
--ti-slider-handle-border-radius: var(--ti-common-border-radius-5, 12px);
--tv-Slider-handle-border-radius: var(--tv-border-radius-round);
// 滑块点悬浮文本色
--ti-slider-handle-text-color-hover: var(--ti-common-color-bg-hover, #595959);
--tv-Slider-handle-text-color-hover: var(--tv-color-text-secondary);
// 滑块点悬浮边框色
--ti-slider-handle-border-color-hover: var(--ti-common-color-data-1, #1476ff);
--tv-Slider-handle-border-color-hover: var(--tv-color-border-active-control);
// 滑块点阴影
--ti-slider-handle-box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
// 滑块点top
--ti-slider-handle-top: calc(-1 * var(--ti-common-space-base));
// 滑块点边框厚度
--ti-slider-handle-border-weight: var(--ti-common-border-weight-normal, 1px);
// 滑块点边框悬浮厚度
--ti-slider-handle-border-weight-hover: var(--ti-common-border-weight-1, 2px);
// 滑块点图标的display(hide)
--ti-slider-handle-icon-display: none;
// 滑块点图标色
--ti-slider-handle-icon-fill-color: var(--ti-common-color-data-1, #1476ff);
// 滑块点图标悬浮色
--ti-slider-handle-icon-fill-color-hover: var(--ti-common-color-bg-hover, #595959);
// 滑块点的缩放值(hide)
--ti-slider-handle-transform: scale(1);
// 滑块点顶部外边距
--ti-slider-handle-margin-top: calc(var(--ti-common-space-2x, 8px) * -1);
// 滑块点水平外边距
--ti-slider-handle-margin-horizontal: calc(var(--ti-common-space-2x, 8px) * -1);
// 滑块点底部外边距
--ti-slider-handle-margin-bottom: var(--ti-common-space-0, 0px);
// 滑块点禁用时图标颜色
--ti-slider-handle-icon-disabled-fill-color: var(--ti-common-color-icon-disabled, #c2c2c2);
--tv-Slider-handle-box-shadow: var(--tv-shadow-1-down);
// 滑块点禁用时边框颜色
--ti-slider-handle-disabled-border-color: var(--ti-common-color-icon-disabled, #c2c2c2);
--tv-Slider-handle-disabled-border-color: var(--tv-color-border);
--tv-Slider-handle-border-color: var(--tv-color-border);
// 滑块点圆角
--tv-Slider-handle-border-radius: var(--tv-border-radius-round);
// 滑块点悬浮文本色
--tv-Slider-handle-text-color-hover: var(--tv-color-text-secondary);
// 滑块点悬浮边框色
--tv-Slider-handle-border-color-hover: var(--tv-color-border-active-control);
// 滑块点阴影
--tv-Slider-handle-box-shadow: var(--tv-shadow-1-down);
// 滑块点禁用时边框颜色
--tv-Slider-handle-disabled-border-color: var(--tv-color-border-disabled);

position: absolute;
padding: 12px 16px;
line-height: 1.5;
z-index: 1010;
word-break: normal; // popup-body里面加了默认折行影响到此处需要重置
white-space: nowrap; // 强制不换行-to liyingfu 纵向进度条上的tips如果内容过多并有空格就会掉下去,此处设置强制显示一行
background: var(--ti-slider-tips-bg-color);
border: 1px solid var(--ti-slider-tips-border-color);
background: var(--tv-Slider-tips-bg-color);
border-radius: var(--ti-common-border-radius-1);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent Variable Naming Detected for border-radius

Multiple definitions of --ti-common-border-radius-1 found with differing values. This inconsistency can lead to theming issues and confusion in variable management.

  • Found in:
    • packages/theme/src/slider/index.less at line 174
🔗 Analysis chain

Inconsistent Variable Naming for border-radius

At line 174, the border-radius is set using var(--ti-common-border-radius-1), which differs from the updated --tv-Slider- prefix convention used elsewhere in the file. This inconsistency might lead to theming issues or confusion in variable management.

To confirm whether --ti-common-border-radius-1 should be updated to match the new naming convention or if it's intentionally left as a common global variable, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for the definition and usage of `--ti-common-border-radius-1`

# Expected Outcome: Determine if `--ti-common-border-radius-1` is a global variable used across multiple components.

# Search for the variable definition in LESS files
rg --type less --no-filename --no-line-number --pretty '^\s*--ti-common-border-radius-1\s*:'

# Search for usages of the variable in LESS files
rg --type less --pretty 'var\(--ti-common-border-radius-1\)'

Length of output: 340

@kagol kagol merged commit bc0ffc5 into dev Oct 18, 2024
6 of 7 checks passed
@kagol kagol deleted the refactor-slider-theme-vars branch November 4, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring (重构)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants