Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(steps): add content-center prop to steps and add two saas icons #2907

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

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Feb 17, 2025

steps组件添加content-center属性并且添加两个saas图标

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 option for step components that centers the content by default, with demos available for both mobile and PC experiences.
    • Expanded the icon set with new lightning-themed icons to enhance the UI.
  • Style

    • Updated layout styling and flex properties for steps and tab navigation, ensuring improved alignment and a more consistent visual presentation.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Feb 17, 2025
Copy link

coderabbitai bot commented Feb 17, 2025

Walkthrough

The changes introduce a new property (content-center/contentCenter) in the steps component to enable centered step bar content. Updates include new demo components and demo entries in both mobile-first and PC versions, additions to Vue components and style sheets, and enhancements to the steps API in the core Vue package. Additionally, new Lightning icons are added to the icon packages and minor style improvements are made to the tabs component.

Changes

File(s) Change Summary
examples/sites/demos/.../steps.js, examples/sites/demos/mobile-first/app/steps/content-center.vue, examples/sites/demos/pc/app/steps/content-center*.vue, examples/sites/demos/.../webdoc/steps.js Added new content-center property and new demo entries/components for both mobile-first and PC versions of the steps component.
packages/theme-saas/src/steps/index.less, packages/theme/src/steps/index.less Introduced new CSS .content-center classes to adjust flex behavior, ensuring centered content in steps components.
packages/theme-saas/src/tabs/index.less Added CSS rules for &__nav-next and &__nav-prev classes to apply flex and items-center, adjusting the layout of tab navigation elements.
packages/vue-icon-saas/index.ts, packages/vue-icon/index.ts, packages/vue-icon/src/lightning-line/index.ts, packages/vue-icon/src/lightning/index.ts Added new Lightning icons (IconLightning and IconLightningLine) to expand the icon set.
packages/vue/src/steps/src/index.ts, packages/vue/src/steps/src/mobile-first*.vue, packages/vue/src/steps/src/pc*.vue Integrated new contentCenter Boolean prop into the steps component for both mobile-first and PC implementations, enabling conditional styling for centered content.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StepsComponent
    participant CSSEngine

    User->>StepsComponent: Render steps with contentCenter prop
    StepsComponent->>CSSEngine: Evaluate contentCenter (true/false)
    CSSEngine-->>StepsComponent: Apply "content-center" CSS class if true
    StepsComponent-->>User: Render centered (or default) step bar
Loading

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

I'm a rabbit, hopping through the code,
Centered steps make my heart explode.
Lightning icons flash with gleam,
Mobile and PC now share the dream.
With a twitch of my nose and a joyful cheer,
I celebrate these changes with a carrot near!
🥕🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/demos/apis/steps.js

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/pc/app/steps/content-center.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/mobile-first/app/steps/content-center.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 12 others
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

Walkthrough

此PR为steps组件添加了一个新的content-center属性,使步骤条内容默认居中显示,并引入了两个新的SaaS图标。此更改包括对组件的属性更新、样式调整以及图标的引入。

Changes

文件 摘要
examples/sites/demos/apis/steps.js 添加了content-center属性的描述和演示配置。
examples/sites/demos/mobile-first/app/steps/content-center.vue 新增了一个示例,展示content-center属性的使用。
examples/sites/demos/mobile-first/app/steps/webdoc/steps.js 添加了content-center属性的文档说明。
examples/sites/demos/pc/app/steps/content-center-composition-api.vue 新增了一个示例,展示content-center属性在Composition API中的使用。
examples/sites/demos/pc/app/steps/content-center.vue 新增了一个示例,展示content-center属性的使用。
examples/sites/demos/pc/app/steps/webdoc/steps.js 添加了content-center属性的文档说明。
packages/theme-saas/src/steps/index.less content-center属性添加了样式。
packages/theme-saas/src/svgs/lightning-line.svg 添加了新的SaaS图标。
packages/theme-saas/src/svgs/lightning.svg 添加了新的SaaS图标。
packages/theme-saas/src/tabs/index.less 更新了导航按钮的样式。
packages/theme/src/steps/index.less content-center属性添加了样式。
packages/theme/src/svgs/lightning-line.svg 添加了新的图标。
packages/theme/src/svgs/lightning.svg 添加了新的图标。
packages/vue-icon-saas/index.ts 引入了新的图标组件。
packages/vue-icon/index.ts 引入了新的图标组件。
packages/vue-icon/src/lightning-line/index.ts 新增了IconLightningLine组件。
packages/vue-icon/src/lightning/index.ts 新增了IconLightning组件。
packages/vue/src/steps/src/index.ts steps组件添加了contentCenter属性。
packages/vue/src/steps/src/mobile-first.vue steps组件添加了contentCenter属性。
packages/vue/src/steps/src/mobile-first/mobile-first-advanced.vue 更新了steps组件以支持contentCenter属性。
packages/vue/src/steps/src/pc.vue steps组件添加了contentCenter属性。
packages/vue/src/steps/src/pc/pc-advanced.vue 更新了steps组件以支持contentCenter属性。

@@ -89,7 +89,8 @@
data-tag="tiny-steps-text"
:class="
m(gcls('steps-text'), gcls(`steps-text-${node[statusField]}`), {
'text-color-text-inverse': index === active && node[statusField] !== 'disabled'
'text-color-text-inverse': index === active && node[statusField] !== 'disabled',

Choose a reason for hiding this comment

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

The addition of 'flex-none': contentCenter in the class binding seems correct for ensuring that the content is not flexed when contentCenter is true. However, ensure that this does not conflict with other styles or layout expectations.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Walkthrough

This PR adds a new content-center property to the steps component, making the step bar content centered by default, and introduces two new SaaS icons. This change includes property updates to components, style adjustments, and the introduction of icons.

Changes

File Summary
examples/sites/demos/apis/steps.js Added description and demonstration configuration for the content-center property.
examples/sites/demos/mobile-first/app/steps/content-center.vue Added an example to show the use of the content-center property.
examples/sites/demos/mobile-first/app/steps/webdoc/steps.js Added documentation for the content-center property.
examples/sites/demos/pc/app/steps/content-center-composition-api.vue Added an example to show how the content-center property is used in the Composition API.
examples/sites/demos/pc/app/steps/content-center.vue Added an example to show the use of the content-center property.
examples/sites/demos/pc/app/steps/webdoc/steps.js Added documentation for the content-center property.
packages/theme-saas/src/steps/index.less Added styles to the content-center property.
packages/theme-saas/src/svgs/lightning-line.svg Added a new SaaS icon.
packages/theme-saas/src/svgs/lightning.svg Added a new SaaS icon.
packages/theme-saas/src/tabs/index.less Updated the style of navigation buttons.
packages/theme/src/steps/index.less Added styles to the content-center property.
packages/theme/src/svgs/lightning-line.svg Added a new icon.
packages/theme/src/svgs/lightning.svg Added a new icon.
packages/vue-icon-saas/index.ts New icon component was introduced.
packages/vue-icon/index.ts New icon component was introduced.
packages/vue-icon/src/lightning-line/index.ts Added IconLightningLine component.
packages/vue-icon/src/lightning/index.ts Added IconLightning component.
packages/vue/src/steps/src/index.ts Added a contentCenter property to the steps component.
packages/vue/src/steps/src/mobile-first.vue Added a contentCenter property to the steps component.
packages/vue/src/steps/src/mobile-first/mobile-first-advanced.vue Updated the steps component to support the contentCenter property.
packages/vue/src/steps/src/pc.vue Added a contentCenter property to the steps component.
packages/vue/src/steps/src/pc/pc-advanced.vue Updated the steps component to support the contentCenter property.

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

🧹 Nitpick comments (8)
examples/sites/demos/pc/app/steps/content-center-composition-api.vue (1)

5-27: Consider adding i18n support for step labels and descriptions.

The hardcoded Chinese text in the demo could be replaced with i18n translations to improve accessibility and maintainability.

-    name: '默认',
+    name: t('steps.default'),
-    description: 'Optional Optional Optional...'
+    description: t('steps.defaultDescription')
examples/sites/demos/mobile-first/app/steps/content-center.vue (1)

1-36: Consider adding mobile-specific adaptations.

While the implementation is correct, consider adding mobile-specific features such as:

  • Responsive step sizes
  • Touch-friendly interactions
  • Mobile-optimized descriptions
packages/vue/src/steps/src/index.ts (2)

51-52: Add JSDoc comments for new props.

The new props flex and contentCenter should include JSDoc comments describing their purpose and usage.

+  /**
+   * Enable flex layout for steps
+   */
   flex: Boolean,
+  /**
+   * Center align the content within steps
+   */
   contentCenter: Boolean

52-52: Consider adding a default value for contentCenter.

For better predictability, consider explicitly setting a default value for the contentCenter prop.

-  contentCenter: Boolean
+  contentCenter: {
+    type: Boolean,
+    default: false
+  }
packages/vue/src/steps/src/mobile-first.vue (1)

52-53: LGTM! Consider adding JSDoc comments.

The contentCenter prop follows the component's pattern and is correctly typed as Boolean.

Consider adding JSDoc comments to document the prop's purpose:

+    /**
+     * Centers the content within steps
+     * @default false
+     */
     contentCenter: Boolean
packages/vue/src/steps/src/pc.vue (1)

64-65: LGTM! Consider adding JSDoc comments.

The contentCenter prop implementation matches the mobile-first version, maintaining consistency.

Consider adding JSDoc comments to document the prop's purpose:

+    /**
+     * Centers the content within steps
+     * @default false
+     */
     contentCenter: Boolean
examples/sites/demos/mobile-first/app/steps/webdoc/steps.js (1)

42-54: Improve the English description and code markup formatting.

The demo entry is well-structured, but there are some formatting inconsistencies.

Apply these improvements to the English description:

       'en-US':
-          '<p>Adding the attribute<code>content center</code>can make the step bar content appear centered by default.</p>'
+          '<p>Add the <code>content-center</code> attribute to center the step bar content by default.</p>'
packages/theme/src/steps/index.less (1)

304-307: Add .content-center Class for Centered Step Text
The new selector .content-center within the .@{steps-prefix-cls}-text block disables flex shrinking/growing (by setting flex: none), which aligns with the intent of the content-center prop to center the step bar content. Ensure that the corresponding documentation and tests are updated to reflect this new behavior.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c851785 and 066aa44.

⛔ Files ignored due to path filters (4)
  • packages/theme-saas/src/svgs/lightning-line.svg is excluded by !**/*.svg
  • packages/theme-saas/src/svgs/lightning.svg is excluded by !**/*.svg
  • packages/theme/src/svgs/lightning-line.svg is excluded by !**/*.svg
  • packages/theme/src/svgs/lightning.svg is excluded by !**/*.svg
📒 Files selected for processing (18)
  • examples/sites/demos/apis/steps.js (1 hunks)
  • examples/sites/demos/mobile-first/app/steps/content-center.vue (1 hunks)
  • examples/sites/demos/mobile-first/app/steps/webdoc/steps.js (1 hunks)
  • examples/sites/demos/pc/app/steps/content-center-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/steps/content-center.vue (1 hunks)
  • examples/sites/demos/pc/app/steps/webdoc/steps.js (1 hunks)
  • packages/theme-saas/src/steps/index.less (1 hunks)
  • packages/theme-saas/src/tabs/index.less (1 hunks)
  • packages/theme/src/steps/index.less (1 hunks)
  • packages/vue-icon-saas/index.ts (3 hunks)
  • packages/vue-icon/index.ts (3 hunks)
  • packages/vue-icon/src/lightning-line/index.ts (1 hunks)
  • packages/vue-icon/src/lightning/index.ts (1 hunks)
  • packages/vue/src/steps/src/index.ts (1 hunks)
  • packages/vue/src/steps/src/mobile-first.vue (1 hunks)
  • packages/vue/src/steps/src/mobile-first/mobile-first-advanced.vue (2 hunks)
  • packages/vue/src/steps/src/pc.vue (1 hunks)
  • packages/vue/src/steps/src/pc/pc-advanced.vue (2 hunks)
🔇 Additional comments (11)
packages/vue-icon/src/lightning/index.ts (1)

1-15: LGTM! Implementation follows the standard icon component pattern.

The implementation is clean, follows the established pattern, and includes proper copyright notice.

packages/vue-icon/src/lightning-line/index.ts (1)

1-15: LGTM! Implementation is consistent with other icon components.

The implementation follows the same pattern as IconLightning and other icon components.

packages/vue-icon/index.ts (1)

533-534: LGTM! Icon exports follow the established pattern.

The new lightning icons are properly imported and exported, maintaining consistency with existing icons.

Also applies to: 1511-1514

packages/vue-icon-saas/index.ts (1)

533-534: LGTM! SaaS package exports mirror the main package.

The lightning icons are properly exported in the SaaS package, maintaining consistency with the main package.

Also applies to: 1511-1514

examples/sites/demos/pc/app/steps/content-center-composition-api.vue (1)

1-3: LGTM! Props usage is correct.

The template correctly demonstrates the new content-center prop along with other required props for the steps component.

examples/sites/demos/pc/app/steps/content-center.vue (1)

1-36: LGTM! Implementation matches the Composition API version.

The component correctly demonstrates the same functionality using the Options API style.

packages/vue/src/steps/src/pc/pc-advanced.vue (1)

48-52: LGTM! Clean implementation of content centering.

The class binding is correctly implemented to toggle the content-center class based on the prop value.

examples/sites/demos/pc/app/steps/webdoc/steps.js (1)

55-67: LGTM! Well-structured demo entry.

The new demo entry for content-center is properly formatted with clear translations and descriptions.

packages/vue/src/steps/src/mobile-first/mobile-first-advanced.vue (1)

92-93: LGTM! Proper class binding.

The conditional application of the flex-none class based on contentCenter prop is implemented correctly.

packages/theme-saas/src/steps/index.less (1)

318-320: LGTM! Clean CSS implementation.

The content-center class is properly implemented with the correct utility class and scope.

packages/theme-saas/src/tabs/index.less (1)

145-146: Center Navigation Elements with Flex Layout
The addition of @apply flex; and @apply items-center; for &__nav-next and &__nav-prev ensures that the navigation controls display their content centered vertically, which improves UI consistency.

Comment on lines +203 to +204
'size',
'contentCenter'
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Define prop type for contentCenter.

The contentCenter prop is added but lacks type definition. Consider defining it properly in the component's props.

-    'size',
-    'contentCenter'
+    'size',
+    {
+      name: 'contentCenter',
+      type: Boolean,
+      default: false
+    }
📝 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
'size',
'contentCenter'
'size',
{
name: 'contentCenter',
type: Boolean,
default: false
}

Comment on lines +32 to +46
{
name: 'content-center',
type: 'string',
defaultValue: 'false',
desc: {
'zh-CN': '使步骤条内容默认居中显示',
'en-US': 'Make the step bar content appear centered by default'
},
meta: {
stable: '3.22.0'
},
mode: ['mobile-first', 'pc'],
pcDemo: 'content-center',
mfDemo: 'content-center'
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix type inconsistency in API documentation.

The content-center property is documented with type 'string' but implemented as Boolean in the component. Additionally, consider using consistent naming between the API (content-center) and implementation (contentCenter).

-          type: 'string',
+          type: 'boolean',
📝 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
{
name: 'content-center',
type: 'string',
defaultValue: 'false',
desc: {
'zh-CN': '使步骤条内容默认居中显示',
'en-US': 'Make the step bar content appear centered by default'
},
meta: {
stable: '3.22.0'
},
mode: ['mobile-first', 'pc'],
pcDemo: 'content-center',
mfDemo: 'content-center'
},
{
name: 'content-center',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '使步骤条内容默认居中显示',
'en-US': 'Make the step bar content appear centered by default'
},
meta: {
stable: '3.22.0'
},
mode: ['mobile-first', 'pc'],
pcDemo: 'content-center',
mfDemo: 'content-center'
},

@zzcr zzcr merged commit b2215cb into dev Feb 17, 2025
12 of 16 checks passed
@kagol kagol deleted the sync-inner-to-out-0217 branch April 14, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants