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(steps): [steps, timeline] Refactoring the steps and timeline themes #2261

Merged
merged 2 commits into from
Oct 14, 2024

Conversation

chenxi-20
Copy link
Collaborator

@chenxi-20 chenxi-20 commented Oct 14, 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

    • Introduced a new line property to the steps component for enhanced customization.
    • Expanded the mode options for the advanced property to include both mobile and PC.
  • Bug Fixes

    • Updated status values for various steps to reflect accurate states.
  • Style

    • Comprehensive updates to styling variables and properties for the steps component, enhancing visual consistency and customization.
  • Documentation

    • Improved clarity of property types and default values in the API definition.

@chenxi-20 chenxi-20 added the refactoring Refactoring (重构) label Oct 14, 2024
Copy link

coderabbitai bot commented Oct 14, 2024

Walkthrough

The pull request introduces several modifications to the steps component's API and related themes. Key changes include type corrections for properties, expansion of the mode for the advanced property, addition of a new line property, and updates to the tinyStepsAuroraTheme and tinyStepsOldTheme objects. Additionally, CSS variable naming conventions have been standardized across various files, transitioning from a ti- prefix to a tv- prefix, enhancing consistency and clarity in the styling of the steps component.

Changes

File Path Change Summary
examples/sites/demos/apis/steps.js - Updated property types for advanced, description-field, and size.
- Expanded mode for advanced.
- Added new line property.
- Specified typeAnchorName for data.
examples/sites/demos/pc/app/steps/advanced-steps-composition-api.vue - Modified status values for various steps in the tiny-steps component.
packages/theme/src/steps/aurora-theme.js - Replaced properties in tinyStepsAuroraTheme, changing keys from ti-steps- to tv-Steps-.
packages/theme/src/steps/index.less - Updated CSS variable references from --ti- to --tv-.
- Altered class definitions and introduced new mixins.
packages/theme/src/steps/old-theme.js - Renamed keys in tinyStepsOldTheme from ti-steps to tv-Steps.
packages/theme/src/steps/vars.less - Replaced .component-css-vars-steps() with .inject-Steps-vars().
- Added and modified several CSS variables.
packages/theme/src/theme/infinity-theme/component-vars.js - Renamed keys in infinityConcat from ti-steps- to tv-Steps-.

Possibly related PRs

Suggested reviewers

  • zzcr

🐰 In the meadow where the steps do play,
A new line added, brightens the way.
With colors anew, and types refined,
Our paths are clearer, our journeys aligned.
Hopping along, we cheer with delight,
For every small change makes the future bright! 🌼


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.

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: 4

🧹 Outside diff range and nitpick comments (12)
packages/theme/src/steps/aurora-theme.js (3)

2-39: Approve naming convention changes and suggest documentation update.

The renaming of all properties from ti-steps-* to tv-Steps-* improves consistency with what appears to be a new naming convention. This change enhances clarity and maintainability.

Consider updating any relevant documentation or style guides to reflect this new naming convention, ensuring that other developers are aware of the change and can maintain consistency in future updates.


8-8: Approve formatting and suggest comment improvement.

The overall formatting of the theme object is consistent and readable. The comment on line 8 about not omitting 'px' is helpful.

Consider expanding the comment to explain why 'px' cannot be omitted. For example:

'tv-Steps-line-margin-horizontal': '0px', // 'px' is required here as some browsers don't recognize unitless zero values for certain properties

This additional context can help prevent future developers from accidentally removing the unit.


1-39: Summary of changes and final suggestions.

Overall, the changes to the tinyStepsAuroraTheme object improve consistency and clarity. The new naming convention with the tv-Steps- prefix is well-applied throughout the theme. Here are the key points and suggestions from this review:

  1. The naming convention change is approved and consistent.
  2. Consider using CSS variables for the remaining hardcoded color values to improve maintainability.
  3. The formatting is consistent and readable.
  4. The comment about 'px' units is helpful but could be expanded for clarity.

To further improve this theme:

  1. Ensure that the new naming convention is documented in the project's style guide.
  2. Review the use of hardcoded color values and consider creating a color palette with CSS variables.
  3. Add a brief comment at the top of the file explaining the purpose of this theme and how it relates to the Steps component.

These changes will enhance the maintainability and clarity of the Aurora theme for the Steps component.

examples/sites/demos/apis/steps.js (4)

22-22: LGTM! Consider updating the description for clarity.

The changes to the advanced property look good:

  1. The type change from Boolean to boolean aligns with TypeScript conventions.
  2. Expanding the mode to include 'pc' is consistent with the new functionality.

Consider updating the description to reflect that this feature is now available for both mobile and PC modes:

  desc: {
-   'zh-CN': '是否开启高级向导模式',
-   'en-US': 'Enable Advanced Wizard Mode'
+   'zh-CN': '是否开启高级向导模式(适用于移动端和PC端)',
+   'en-US': 'Enable Advanced Wizard Mode (applicable for both mobile and PC)'
  },

Also applies to: 28-30


103-113: LGTM! Consider adding a note about mobile compatibility.

The addition of the line property is well-documented and seems to provide useful functionality for horizontal single chain step bars in PC mode.

Consider adding a note in the description about its compatibility with mobile mode:

  desc: {
    'zh-CN': '通过 line 设置横向单链型步骤条',
-   'en-US': 'Set horizontal single chain step bar through line'
+   'en-US': 'Set horizontal single chain step bar through line (PC mode only)'
  },

Line range hint 129-129: Consider using false as the default value for no-arrow.

The current change sets the default value to an empty string, which might be confusing for a boolean property.

Consider changing the default value to false for clarity:

-  defaultValue: '',
+  defaultValue: 'false',

This change would make it clear that arrows are shown by default.


Line range hint 140-141: LGTM for type change. Consider improvements to default value and description.

The change from String to string for the size property type is correct and aligns with TypeScript conventions.

  1. Consider setting a specific default value instead of an empty string:
-  defaultValue: '',
+  defaultValue: "'medium'",
  1. Update the description to clarify the default values for different modes:
  desc: {
    'zh-CN':
-     'line 单链型模式支持 mini、small、medium、large 4 种尺寸,默认值为 medium。advanced 高级向导模式支持 medium、large 2 种尺寸,默认值为 medium',
+     'line 单链型模式支持 mini、small、medium、large 4 种尺寸,默认值为 medium。advanced 高级向导模式支持 medium、large 2 种尺寸,默认值为 medium。若未指定,默认为 medium。',
-   'en-US': ''
+   'en-US': 'In line mode, supports 4 sizes: mini, small, medium, large (default: medium). In advanced mode, supports 2 sizes: medium, large (default: medium). If not specified, defaults to medium.'
  },
packages/theme/src/steps/vars.less (3)

14-254: Consider translating comments to English for consistency

The code contains comments in Chinese (e.g., lines 14, 86, 117, 152). To maintain consistency and improve accessibility for all team members, please consider translating all comments into English.


78-84: Standardize naming conventions for size variables

There are inconsistent naming conventions for size-related variables. For example:

  • --tv-Steps-mini-icon-size
  • --tv-Steps-mini-number-font-size
  • --tv-Steps-icon-small-size
  • --tv-Steps-small-number-font-size

Consider standardizing the naming to maintain consistency. For instance, you could use --tv-Steps-icon-size-mini and --tv-Steps-icon-size-small for better uniformity.


228-236: Use consistent terminology for status variables

The variables for status colors use both "danger" and "error" interchangeably:

  • --tv-Steps-timeline-dot-danger-bg-color
  • --tv-Steps-error-icon-color
  • --tv-Steps-advance-node-error-bg-color

Consider standardizing the terminology to either "error" or "danger" across all variables to improve code clarity and consistency.

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

233-233: Use consistent spacing for icon margins

The margin-right for .@{steps-prefix-cls}-icon is set to 8px. Review if this aligns with the spacing conventions used elsewhere in the project to ensure visual consistency.


Line range hint 90-93: Remove redundant margin-right property in vertical layout

In the .vertical class, both text-align: center; and margin-right: 0; are set. If centering the content negates the need for adjusting the margin, consider removing the redundant margin-right property to simplify the code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 47371e5 and f0149d3.

📒 Files selected for processing (7)
  • examples/sites/demos/apis/steps.js (2 hunks)
  • examples/sites/demos/pc/app/steps/advanced-steps-composition-api.vue (1 hunks)
  • packages/theme/src/steps/aurora-theme.js (1 hunks)
  • packages/theme/src/steps/index.less (22 hunks)
  • packages/theme/src/steps/old-theme.js (1 hunks)
  • packages/theme/src/steps/vars.less (1 hunks)
  • packages/theme/src/theme/infinity-theme/component-vars.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (16)
examples/sites/demos/pc/app/steps/advanced-steps-composition-api.vue (2)

Line range hint 1-35: Overall, the changes align with the refactoring objectives.

The modifications to the step statuses and count in the data ref appear to be intentional and part of the refactoring process for the steps theme. The rest of the component, including the template and the advancedClick function, remains unchanged, which is consistent with the PR's goal of not introducing functional changes.

However, please ensure that these status changes are reflected in any related documentation or test cases to maintain consistency across the project.


18-22: Verify the impact of status and count changes on the steps component.

The changes to the data ref modify the status and count of various steps:

  1. "Basic Info" is now marked as 'done' instead of 'doing'.
  2. "BOQ Info" is changed to 'doing' from 'done'.
  3. "Involved Parties" now has an 'error' status instead of 'doing'.
  4. "Billing" is set to 'disabled' from 'done'.
  5. The count for "Appraise" is increased from 0 to 3.

These modifications will affect the visual representation and potentially the behavior of the steps component. Please ensure that these changes align with the intended refactoring goals and don't introduce unexpected side effects in other parts of the application that might depend on these statuses.

To verify the impact of these changes, you can run the following script:

This script will help identify any potential areas in the codebase that might be affected by these status changes.

packages/theme/src/steps/old-theme.js (6)

2-9: LGTM: Consistent renaming of timeline-related properties.

The renaming from 'ti-steps-' to 'tv-Steps-' for timeline-related properties is consistent and maintains the existing functionality. The values correctly reference the appropriate CSS variables.


10-15: Verify the change from 'advanced' to 'advance' in property names.

While the renaming from 'ti-steps-' to 'tv-Steps-' is consistent, there's a change from 'advanced' to 'advance' in the following properties:

  • 'tv-Steps-advance-count-font-size'
  • 'tv-Steps-advance-count-bg-color'
  • 'tv-Steps-advance-link-font-size'
  • 'tv-Steps-advance-li-text-color'

This change might be unintentional and could lead to confusion. Please verify if this change is intended or if it should be reverted to 'advanced'.


16-21: LGTM: Improved specificity in disabled and error state property names.

The renaming of disabled and error state properties is consistent and provides more clarity on the specific elements being styled. For example:

  • 'tv-Steps-line-number-active-text-color-disabled' is more specific than the previous naming.
  • 'tv-Steps-line-title-text-color-disabled' clearly indicates it's for the line title.

This improved specificity will make it easier for developers to understand and use these theme properties.


22-31: LGTM: Enhanced clarity in active, done, and hover state property names.

The renaming of active, done, and hover state properties is consistent and offers improved clarity:

  • 'tv-Steps-line-doing-border-color' clearly indicates it's for the line in the 'doing' state.
  • 'tv-Steps-line-desc-text-color-active' specifies it's for the description text color in the active state.

These changes will help developers more easily identify and apply the correct styles for different states of the steps component.


32-42: LGTM: Improved semantic naming for various properties.

The renaming of these properties enhances clarity and semantic meaning:

  • 'tv-Steps-custom-icon-size' replaces separate width and height properties, assuming icons are square.
  • 'tv-Steps-node-circle-size' is more semantically correct than 'circle-width-height' for a single size value.
  • Other properties maintain consistency with the new naming convention while preserving their original meanings.

These changes contribute to a more intuitive and maintainable theme structure.


1-42: Overall: Consistent renaming improves theme structure with minor concerns.

The changes in this file demonstrate a systematic renaming of all properties in the tinyStepsOldTheme object from 'ti-steps-' to 'tv-Steps-'. This renaming:

  1. Improves consistency across the theme.
  2. Enhances clarity with more specific naming for certain properties.
  3. Maintains the existing functionality by preserving the CSS variable references.

However, there are two points that require attention:

  1. The change from 'advanced' to 'advance' in some property names (lines 10-13) needs verification.
  2. The rationale behind the prefix change from 'ti-' to 'tv-' is not clear from this file alone and might benefit from a comment explaining the change.

These changes will likely improve the maintainability of the theme, but ensuring consistency with the rest of the codebase is crucial.

examples/sites/demos/apis/steps.js (2)

Line range hint 60-60: LGTM! Type correction improves consistency.

The change from String to string for the description-field property type is correct and aligns with TypeScript conventions.


Line range hint 1-285: Overall, the changes improve the API definition, but there's room for further refinement.

The modifications to the steps component API enhance type consistency and expand functionality. Key improvements include:

  1. Consistent use of lowercase boolean and string types.
  2. Expansion of the advanced property to PC mode.
  3. Addition of the line property for horizontal single chain step bars.

Consider implementing the suggested improvements to default values and descriptions for better clarity and usability.

packages/theme/src/theme/infinity-theme/component-vars.js (1)

221-227: Consistent renaming of Steps component CSS variables

The changes in these lines represent a systematic renaming of CSS variables for the Steps component. Here's a summary of the changes:

  1. The prefix has changed from 'ti-' to 'tv-' for all variables.
  2. 'steps' has been capitalized to 'Steps' in all variable names.
  3. Some variable names have been slightly modified:
    • 'done-icon-bg-color' → 'node-done-bg-color'
    • 'done-active-border-color' → 'node-done-border-color'
  4. All values remain unchanged.

These changes appear to be part of a larger effort to standardize naming conventions across the codebase. The new naming scheme seems more consistent and descriptive.

To ensure these changes don't break existing styles, we should verify that all references to these variables have been updated accordingly. Run the following script to check for any remaining occurrences of the old variable names:

If this script returns any results, those occurrences will need to be updated to use the new variable names.

✅ Verification successful

No remaining occurrences of old Steps component CSS variables found

All instances of the old ti-steps- variable names have been successfully updated to the new tv-Steps- naming convention. No references to ti-steps- variables were found in .css, .js, or .vue files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining occurrences of the old variable names
echo "Searching for old variable names:"
rg --type css --type vue --type js 'ti-steps-(icon-size|done-icon-bg-color|done-active-border-color|done-icon-fill-color|line-active-bg-color|line-height|done-text-color)'

Length of output: 278


Script:

#!/bin/bash
# Search for any remaining occurrences of the old variable names in .css, .js, and .vue files
echo "Searching for old variable names in .css, .js, and .vue files:"
rg 'ti-steps-(icon-size|done-icon-bg-color|done-active-border-color|done-icon-fill-color|line-active-bg-color|line-height|done-text-color)' --type css --type js --type vue

Length of output: 336


Script:

#!/bin/bash
# Search for any remaining occurrences of the old variable names in .css, .js, and .vue files without using --type flags
echo "Searching for old variable names in .css, .js, and .vue files:"
rg 'ti-steps-(icon-size|done-icon-bg-color|done-active-border-color|done-icon-fill-color|line-active-bg-color|line-height|done-text-color)' -g '*.css' -g '*.js' -g '*.vue'

Length of output: 308

packages/theme/src/steps/index.less (5)

183-185: Confirm the correct positioning of arrow elements

The .arrow class uses position: absolute with specific dimensions. Ensure that the arrow elements are properly positioned across different browsers and screen sizes to maintain the intended design.


1191-1194: Consistent styling for .process-current .icon

The styles applied to .process-current .icon should align with the overall design system. Verify that the colors and backgrounds used here are consistent with other states and components.


545-545: Potential duplication of review comment

This comment appears to duplicate a previous comment regarding the --tv-Steps-error-text-color variable.


545-545: Check the definition of --tv-Steps-error-text-color variable

Verify that the CSS variable --tv-Steps-error-text-color used in line 545 is correctly defined in the theme variables. An undefined variable may result in unexpected styling issues.

Run the following script to confirm the variable definition:

#!/bin/bash
# Description: Search for the definition of '--tv-Steps-error-text-color' in LESS files.

# Test: Ensure the variable is defined. Expect: At least one match.
rg --type less '--tv-Steps-error-text-color\s*:\s*'

26-26: Verify the existence of the .inject-Steps-vars() mixin

Ensure that the mixin .inject-Steps-vars(); is defined and properly imported. Missing mixin definitions can lead to compilation errors during the build process.

Run the following script to check if the mixin is defined:

✅ Verification successful

.inject-Steps-vars() mixin is properly defined and imported.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for the definition of 'inject-Steps-vars' mixin in LESS files.

# Test: Verify that the mixin is defined. Expect: At least one match.
rg --type less '@mixin inject-Steps-vars'

Length of output: 490


Script:

#!/bin/bash
# Description: Search for the definition of 'inject-Steps-vars' mixin in LESS files with corrected pattern.

# Test: Verify that the mixin is defined. Expect: At least one match.
rg --type less '@mixin\s+inject-Steps-vars\b'

Length of output: 47


Script:

#!/bin/bash
# Description: Search for the definition of 'inject-Steps-vars' mixin in LESS files using correct LESS syntax.

# Test: Verify that the mixin is defined. Expect: At least one match.
rg --type less '\.inject-Steps-vars\s*\(.*\)'

Length of output: 165

packages/theme/src/steps/aurora-theme.js Show resolved Hide resolved
packages/theme/src/steps/index.less Show resolved Hide resolved
packages/theme/src/steps/index.less Show resolved Hide resolved
packages/theme/src/steps/index.less Show resolved Hide resolved
@zzcr zzcr merged commit 50c0b05 into dev Oct 14, 2024
3 checks passed
@kagol kagol deleted the fix/steps-theme-20241010 branch November 4, 2024 03:59
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