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(card): replace card-group,card-template components css-vars #2333

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Oct 21, 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

重构 card-group,card-template 的 css 变量
移除 card-item card-layout 的样式文件。好像没地方引用

Summary by CodeRabbit

  • New Features
    • Updated theming variables for card components to enhance customization.
  • Bug Fixes
    • Removed unused mixins and variables to streamline the styling process.
  • Refactor
    • Shifted naming conventions for CSS variables to improve consistency across components.
  • Chores
    • Adjusted import statements to reflect the current components in use, removing outdated styles.

Copy link

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes involve the removal of several LESS files related to card components, including styles and variable definitions. Specifically, the vars.less files for card items and card layouts were deleted, along with their associated mixins and CSS variables. The index.less files for card items, card layouts, and card groups were also removed or modified, impacting the overall styling structure. Additionally, updates were made to the card template styles, including a shift in CSS variable naming conventions.

Changes

File Path Change Summary
packages/theme/src/card-group/index.less Removed import statement for vars.less and mixin call .component-css-vars-amount().
packages/theme/src/card-group/vars.less Deleted file containing an empty mixin definition.
packages/theme/src/card-item/index.less Deleted file containing comprehensive styles for the card item component.
packages/theme/src/card-item/vars.less Deleted file containing CSS variable definitions for the card item component.
packages/theme/src/card-layout/index.less Deleted file containing styles for the card layout component.
packages/theme/src/card-layout/vars.less Deleted file containing CSS variable definitions for the card layout component.
packages/theme/src/card-template/index.less Updated CSS variable references from --ti- to --tv- for various styles.
packages/theme/src/card-template/vars.less Replaced method .component-css-vars-card-template() with .inject-CardTemplate-vars().
packages/theme/src/index.less Removed imports for card-item and card-layout, added import for year-table.

Possibly related PRs

Suggested labels

refactoring

Suggested reviewers

  • zzcr

Poem

🐇 In fields of code, we hop and play,
With styles and vars, we clear the way.
The old is gone, the new takes flight,
A theme reborn, oh what a sight!
With every change, we dance and cheer,
For a brighter UI, we hold so dear! 🌼


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 bug Something isn't working label Oct 21, 2024
Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

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 (3)
packages/theme/src/card-template/index.less (2)

40-43: LGTM: Consistent variable renaming for title styling, with a minor suggestion.

The changes to title styling variables (font weight, font size, and text color) align with the new naming convention. However, there's a potential inconsistency:

Consider replacing the hardcoded color value on line 42 with a CSS variable for better theming consistency:

-    color: #333;
+    color: var(--tv-CardTemplate-header-title-text-color);

This change would make line 43 redundant, so you could remove it if you make this adjustment.


61-62: LGTM: Consistent variable renaming, with a suggestion for clarity.

The changes from --ti-card-header-height to --tv-CardTemplate-header-height for both height and line-height of list items are consistent with the new naming convention.

Consider creating a separate variable for list item height and line-height for better clarity:

-      height: var(--tv-CardTemplate-header-height);
-      line-height: var(--tv-CardTemplate-header-height);
+      height: var(--tv-CardTemplate-list-item-height);
+      line-height: var(--tv-CardTemplate-list-item-height);

This would make it clearer that these properties are specific to list items rather than the header.

packages/theme/src/card-template/vars.less (1)

18-19: Replace hardcoded values with CSS variables for consistency

The following properties are assigned hardcoded values:

  • Line 18: --tv-CardTemplate-tool-active-icon-color: #595959;
  • Line 19: --tv-CardTemplate-tool-selector-height: 40px;
  • Line 26: --tv-CardTemplate-header-border-color: #999999;

For better theming consistency and easier customization, consider using existing CSS variables or defining new ones to replace these hardcoded values.

Also applies to: 26-26

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 431b565 and f01abbf.

📒 Files selected for processing (9)
  • packages/theme/src/card-group/index.less (0 hunks)
  • packages/theme/src/card-group/vars.less (0 hunks)
  • packages/theme/src/card-item/index.less (0 hunks)
  • packages/theme/src/card-item/vars.less (0 hunks)
  • packages/theme/src/card-layout/index.less (0 hunks)
  • packages/theme/src/card-layout/vars.less (0 hunks)
  • packages/theme/src/card-template/index.less (5 hunks)
  • packages/theme/src/card-template/vars.less (1 hunks)
  • packages/theme/src/index.less (1 hunks)
💤 Files with no reviewable changes (6)
  • packages/theme/src/card-group/index.less
  • packages/theme/src/card-group/vars.less
  • packages/theme/src/card-item/index.less
  • packages/theme/src/card-item/vars.less
  • packages/theme/src/card-layout/index.less
  • packages/theme/src/card-layout/vars.less
🧰 Additional context used
🔇 Additional comments (12)
packages/theme/src/card-template/index.less (10)

23-23: LGTM: Consistent variable renaming.

The change from --ti-card-bg-color to --tv-CardTemplate-bg-color aligns with the new naming convention, making it more specific to the CardTemplate component.


31-32: LGTM: Consistent variable renaming for header dimensions.

The changes from --ti-card-header-height to --tv-CardTemplate-header-height for both height and line-height are consistent with the new naming convention and maintain proper spacing.


35-35: LGTM: Consistent variable renaming for header border.

The change from --ti-card-header-border-color to --tv-CardTemplate-header-border-color aligns with the new naming convention and is specific to the CardTemplate component.


51-51: LGTM: Consistent variable renaming for tool icon size.

The change from --ti-card-tool-icon-size to --tv-CardTemplate-tool-icon-size aligns with the new naming convention and is specific to the CardTemplate component.


68-68: LGTM: Consistent variable renaming for tool icon color.

The change from --ti-card-tool-icon-color to --tv-CardTemplate-tool-icon-color aligns with the new naming convention and is specific to the CardTemplate component.


73-80: LGTM: Consistent variable renaming for tool icon states.

The changes to tool icon color variables for default, hover, and active states align with the new naming convention and are specific to the CardTemplate component.


92-99: LGTM: Consistent variable renaming for 'more' section with good practices.

The changes to variables for the 'more' section (top positioning, border color, background color, and text color) align with the new naming convention and are specific to the CardTemplate component. The use of a fallback value in the calc() function on line 92 is a good practice for ensuring layout stability.


119-122: LGTM: Consistent variable renaming for 'more' section list items.

The changes to variables for the 'more' section list items (height, line height, and text color) align with the new naming convention and are specific to the CardTemplate component.


Line range hint 127-150: LGTM: Comprehensive and consistent variable renaming for list item states.

The changes to variables for the 'more' section list item states (default, hover, active) are consistent with the new naming convention and specific to the CardTemplate component. The styling is comprehensive, covering text colors, background colors, and icon colors for each state.


Line range hint 1-160: Overall assessment: Approved with minor suggestions.

The changes in this file consistently apply the new naming convention for CSS variables, improving the specificity to the CardTemplate component. The refactoring is well-executed, maintaining the existing functionality while enhancing the theming capabilities.

A few minor suggestions were made:

  1. Consider using a CSS variable for the hardcoded color value on line 42.
  2. Evaluate the use of header height variables for list items (lines 61-62) for potential clarity improvements.

These suggestions are optional and do not impede the overall quality and consistency of the changes. The PR can be approved from the perspective of this file.

packages/theme/src/index.less (2)

Line range hint 1-170: Summary of changes in packages/theme/src/index.less

The changes in this file partially align with the PR objectives:

  1. Removal of card-item and card-layout imports is consistent with the goal of refactoring card components.
  2. The addition of year-table import needs clarification as it's not mentioned in the PR objectives.
  3. There are no visible changes to card-group and card-template imports, which is unexpected given the PR objectives.

Please provide more context on these points to ensure the changes are fully aligned with the PR's goals.


Line range hint 1-170: Inquiry about card-group and card-template refactoring.

The PR objectives mention replacing CSS variables for card-group and card-template components. However, there are no visible changes to their imports in this file. Can you please provide an update on the status of this refactoring?

#!/bin/bash
# Description: Check for changes in card-group and card-template components

# Test: Search for changes in card-group and card-template files
git diff origin/main -- '**/card-group/**' '**/card-template/**'

@import './year-table/index.less';
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

The addition of @import './year-table/index.less'; appears unrelated to the PR's objective of refactoring card components. Please clarify the necessity of this import.

🔗 Analysis chain

Verify the addition of year-table import.

The addition of @import './year-table/index.less'; seems unrelated to the PR objectives of refactoring card components. Can you please clarify the reason for this addition?



🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if year-table component is used in the codebase

# Test: Search for year-table usage
rg -i 'year-table|yeartable' --type vue --type js

Length of output: 100


Script:

#!/bin/bash
# Description: Search for usage of 'year-table' component in the codebase

rg -i 'year-table|yeartable' --type vue --type js --type jsx --type ts --type tsx

Length of output: 111


Script:

#!/bin/bash
# Description: Search for usage of 'year-table' component in the codebase using file extensions

rg -i 'year-table|yeartable' --glob '*.vue' --glob '*.js' --glob '*.jsx' --glob '*.ts' --glob '*.tsx'

Length of output: 4187

--ti-card-header-title-font-weight: var(--ti-common-font-weight-7, bold);
--ti-card-header-title-font-size: var(--ti-common-font-size-1, 14px);
--ti-card-header-title-text-color: var(--ti-common-color-info-normal, #191919);
.inject-CardTemplate-vars() {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider renaming the mixin function for consistency

The mixin .inject-CardTemplate-vars() uses PascalCase in its name. For consistency with LESS mixin naming conventions in the codebase, consider renaming it to .inject-card-template-vars(), using lowercase letters and hyphens.

--tv-CardTemplate-bg-color: var(--tv-color-bg-secondary, #ffffff);
--tv-CardTemplate-tool-icon-size: var(--tv-icon-size);
--tv-CardTemplate-tool-icon-color: var(--tv-color-icon-control, #191919);
--tv-CardTemplate-tool-hover-icon-color: #c2c2c2; // 无对应的正确变量
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace hardcoded color value with a CSS variable

At line 17, --tv-CardTemplate-tool-hover-icon-color is assigned a hardcoded color value #c2c2c2. The comment indicates that there is no corresponding correct variable (// 无对应的正确变量). To maintain theming flexibility and consistency, consider defining a new CSS variable or using an existing one to replace the hardcoded color.

Would you like assistance in identifying or creating an appropriate CSS variable for this color?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants