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

feat(steps): [steps] The stateless step style is added to the step bar, and the itemFooter slot is added. #2110

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

chenxi-20
Copy link
Collaborator

@chenxi-20 chenxi-20 commented Sep 12, 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

Release Notes

  • New Features

    • Introduced itemFooter property for enhanced step bar functionality.
    • Added dynamic Vue components for managing steps with add/remove actions.
    • Implemented tooltips for titles using a new directive.
  • Bug Fixes

    • Improved tooltip display logic to handle both horizontal and vertical overflow.
  • Styling Enhancements

    • Updated styles for better layout and readability of step components.
  • Documentation

    • Added new demo entry for the itemFooter slot with clear customization instructions.

@chenxi-20 chenxi-20 added the enhancement New feature or request (功能增强) label Sep 12, 2024
Copy link

coderabbitai bot commented Sep 12, 2024

Walkthrough

This pull request introduces several enhancements to the steps component in a Vue.js application. Key changes include the addition of an itemFooter property in the steps.js file, new Vue components for managing step items and footers, improved styling in the CSS files, and modifications to tooltip logic. The updates aim to enhance user interaction and provide better documentation for the new features, particularly focusing on dynamic management of steps and their associated actions.

Changes

File Path Change Summary
examples/sites/demos/apis/steps.js Added itemFooter with attributes in the exported object.
examples/sites/demos/pc/app/steps/slot-item-footer-composition-api.vue Introduced a new Vue component for managing steps with add/remove functionality.
examples/sites/demos/pc/app/steps/slot-item-footer.vue Created a Vue component for a footer that adds/removes steps dynamically.
examples/sites/demos/pc/app/steps/webdoc/steps.js Added a new demo entry for the itemFooter slot and made minor formatting changes.
packages/theme/src/steps/index.less Enhanced styling for steps component, added new classes for layout and text handling.
packages/vue-directive/src/auto-tip.ts Improved tooltip logic to handle vertical overflow in addition to horizontal overflow.
packages/vue/src/steps/package.json Updated package metadata, added dependencies, and restructured devDependencies.
packages/vue/src/steps/src/pc/pc-line.vue Introduced a new directive for tooltips and added a slot for itemFooter in the steps component.

Possibly related PRs

Poem

🐇 In the garden of steps, we hop and play,
With footers and slots brightening the way.
A button to add, a button to take,
Dynamic and lively, make no mistake!
Hopping along, our UI's a treat,
With every new change, our joy is complete! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

@chenxi-20
Copy link
Collaborator Author

chenxi-20 commented Sep 12, 2024

image

@chenxi-20
Copy link
Collaborator Author

image

@Issues-translate-bot
Copy link

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


image

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)
examples/sites/demos/pc/app/steps/slot-item-footer-composition-api.vue (1)

1-57: Potential improvements.

The component looks good overall, but here are some potential improvements to consider:

  • Extract the itemFooter slot into a separate component for better readability and maintainability. This will make the component easier to understand and maintain.
  • Use more descriptive names for the stepsData and handleChange variables and method. This will make the component easier to understand and maintain.
  • Use TypeScript for better type safety and documentation. This will make the component easier to understand and maintain, and will help catch potential bugs early.
packages/vue/src/steps/src/pc/pc-line.vue (1)

92-92: Consider adjusting the tooltip placement for the vertical title.

While using the v-auto-tip directive for the vertical title is a good enhancement, the 'bottom' placement might not be the most suitable as it could overlap with the content below.

Consider changing the placement to 'right' for a better user experience:

-<div v-auto-tip="{ placement: 'bottom' }" :class="['title-vertical', { 'not-vertical': !vertical }]">
+<div v-auto-tip="{ placement: 'right' }" :class="['title-vertical', { 'not-vertical': !vertical }]">
examples/sites/demos/apis/steps.js (1)

224-238: LGTM! Consider adding a mobile-first demo if applicable.

The addition of the itemFooter slot looks good and follows the existing code conventions. The naming is clear, the typing is consistent, and the documentation provides helpful information about the slot's purpose and usage.

The inclusion of the stability version in the meta property is a nice touch for tracking changes.

One suggestion would be to consider adding a mobile-first demo (mfDemo) if this slot is also applicable in mobile environments. If not, the current 'pc' mode specification is sufficient.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aaf5d4f and ccac231.

Files selected for processing (8)
  • examples/sites/demos/apis/steps.js (1 hunks)
  • examples/sites/demos/pc/app/steps/slot-item-footer-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/steps/slot-item-footer.vue (1 hunks)
  • examples/sites/demos/pc/app/steps/webdoc/steps.js (2 hunks)
  • packages/theme/src/steps/index.less (4 hunks)
  • packages/vue-directive/src/auto-tip.ts (1 hunks)
  • packages/vue/src/steps/package.json (1 hunks)
  • packages/vue/src/steps/src/pc/pc-line.vue (5 hunks)
Additional comments not posted (24)
packages/vue/src/steps/package.json (5)

3-3: LGTM!

Adding the "type": "module" field is a good practice as it explicitly indicates that the code in the package is written as an ECMAScript module. This clarifies the module system used by the package.


6-6: LGTM!

Adding the "license": "MIT" field is important for open-source projects. The MIT license is a permissive open-source license that allows users to freely use, modify, and distribute the code.


7-7: LGTM!

Setting "sideEffects": false is beneficial as it indicates that the package does not have any side effects when imported. This allows bundlers to perform tree-shaking and eliminate unused code, resulting in smaller bundle sizes.


22-25: Verify the necessity and compatibility of the added development dependencies.

The reintroduction of the devDependencies section with the @opentiny-internal/vue-test-utils and vitest packages indicates a shift in how development dependencies are managed. Please ensure that these packages are necessary for the package's development and testing workflow and are compatible with the existing setup.

Run the following script to verify the usage of the added development dependencies in the codebase:

Verification successful

Development dependencies are necessary and compatible.

The @opentiny-internal/vue-test-utils and vitest packages are actively used in the codebase, as evidenced by their import statements in TypeScript files. This confirms their necessity and compatibility with the existing development and testing workflow. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the added development dependencies in the codebase.

# Test: Search for the import statements of the added development dependencies.
# Expect: At least one occurrence of each development dependency import.
fd --type ts --exec rg --multiline $'import.*@opentiny-internal/vue-test-utils'
fd --type ts --exec rg --multiline $'import.*vitest'

Length of output: 474


Script:

#!/bin/bash
# Description: Verify the usage of the added development dependencies in the codebase.

# Find all TypeScript files and search for import statements of the added development dependencies.
fd --extension ts --exec rg --multiline 'import.*@opentiny-internal/vue-test-utils' {}
fd --extension ts --exec rg --multiline 'import.*vitest' {}

Length of output: 559


16-17: Verify the necessity and compatibility of the added dependencies.

Adding new dependencies is a significant change that can impact the package's functionality and compatibility. Please ensure that the @opentiny/vue-directive and @opentiny/vue-icon packages are necessary for the functionality introduced in this PR and are compatible with the package's existing dependencies and the project's overall ecosystem.

Run the following script to verify the usage of the added dependencies in the codebase:

examples/sites/demos/pc/app/steps/slot-item-footer-composition-api.vue (2)

1-19: LGTM!

The template section looks good:

  • The tiny-steps and tiny-link components are used correctly.
  • The itemFooter slot is used correctly to customize the footer of each step item.
  • The v-if and v-for directives are used correctly to conditionally render the links and multiple tiny-link components.
  • The #icon slot is used correctly to conditionally render the icon component.

53-57: LGTM!

The style section looks good:

  • The style is scoped correctly to the component.
  • The style adds a left margin of 16px to .item-link elements that are not the first child, which looks correct.
examples/sites/demos/pc/app/steps/slot-item-footer.vue (2)

1-19: LGTM!

The template section correctly demonstrates the usage of the tiny-steps component with a custom itemFooter slot. The rendering of the tiny-link component for each link and the conditional rendering of the link's icon are implemented correctly.


65-69: LGTM!

The scoped style correctly adds a left margin of 16px to .item-link elements that are preceded by another .item-link element. Using a scoped style is a good practice to avoid style conflicts with other components.

packages/vue-directive/src/auto-tip.ts (1)

34-35: LGTM!

The updated condition in the isEllipsis function correctly checks for both horizontal and vertical overflow, improving the tooltip display mechanism. This change aligns with the PR objective and is implemented correctly.

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

112-112: LGTM!

The added space improves the readability of the Chinese name. Good catch!


121-132: Excellent addition!

The new demo entry for the itemFooter slot is a great addition to the documentation. The names and descriptions are clear and consistent with the existing entries. The example provided in the description effectively illustrates the usage of the slot.

packages/vue/src/steps/src/pc/pc-line.vue (5)

44-45: LGTM!

The conditional classes are correctly applied based on the number of items and orientation to adjust the styling.


77-77: Great addition!

Using the v-auto-tip directive to display tooltips on the title is a nice enhancement to provide additional context to the user. The 'bottom' placement is suitable for the horizontal title.


103-103: LGTM!

Adding the v-auto-tip directive to the description is consistent with the other tooltip enhancements. The 'bottom' placement is suitable for the description.


107-109: Nice work!

The new itemFooter slot is a great addition to enhance the flexibility of the component by allowing users to render additional content at the bottom of each item. The slot is correctly scoped and conditionally rendered based on the presence of content.


146-146: LGTM!

Importing the AutoTip directive from @opentiny/vue-directive and registering it in the component using the new syntax is necessary and correctly done to enable the usage of the v-auto-tip directive in the template.

Also applies to: 153-153

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

372-373: LGTM!

The margin adjustments for .description and .line-footer elements in the vertical layout look good. This ensures consistent spacing and improves the visual alignment.


587-593: Looks good!

The new .block-mini class is a nice addition for creating more compact layouts. Restricting the maximum width of .title, .description, and .line-footer elements to 150px within this class is a reasonable choice.


595-600: Approved.

Setting a default maximum width of 250px for .title, .description, and .line-footer elements is a good practice. It helps maintain a consistent and readable layout by preventing the content from extending too wide. The chosen value of 250px seems appropriate for most cases.


604-610: Great improvements to the title text handling!

The changes made to the .title class significantly enhance its visual appearance and consistency:

  • Setting the line height to 1.5 improves readability.
  • Using -webkit-line-clamp: 2 limits the title to a maximum of 2 lines, maintaining a consistent height.
  • Allowing word breaking ensures proper wrapping of long words within the available width.

These improvements contribute to a better overall layout and user experience. Well done!


657-661: Approved.

The line height and margin adjustments for .description and .line-footer elements are beneficial:

  • Setting the line height to 1.5 improves readability and maintains consistent vertical spacing.
  • Calculating the left margin based on the step circle width and a predefined value ensures proper alignment with the step circle.

These changes enhance the overall layout and visual appeal of the step components. Good job!


682-682: LGTM.

Adjusting the top margin of the .description element to 10px in the non-vertical layout is a good choice. It creates consistent vertical spacing between the title and description, improving the visual separation and readability of the step content in this layout.


686-688: Nice addition!

Introducing styles for the .line-footer element is a good move to maintain consistent styling across the step components. Setting a top margin of 8px for the .line-footer creates an appropriate vertical spacing, improving the visual separation and hierarchy within the step layout. Well done!

Comment on lines +21 to +51
<script setup>
import { ref } from 'vue'
import { Button as TinyButton, Steps as TinySteps, Link as TinyLink } from '@opentiny/vue'
import { IconFilletExternalLink } from '@opentiny/vue-icon'

const stepsData = ref([
{
name: '创建桶(超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题)',
status: 'done',
description:
'桶是存储对象的容器,用于存储您的数据,我这个描述要超出隐藏,我这个描述要超出隐藏,我这个描述要超出隐藏',
links: [{ title: '前往创建' }, { title: '前往创建' }]
},
{ name: '上传文件', status: 'doing', description: '上传您项目相关的文件至桶内存储' },
{
name: '购买资源包(可选)',
description: '资源包是预付费的优惠套餐,可降低存储成本。',
links: [{ title: '了解套餐详情', icon: IconFilletExternalLink() }]
}
])
const handleChange = () => {
if (stepsData.value.length > 3) {
stepsData.value.pop()
} else {
stepsData.value.push({
name: '域名解析',
description: '域名解析的内容'
})
}
}
</script>
Copy link

Choose a reason for hiding this comment

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

Use immutable update patterns in the handleChange method.

The script section looks good overall:

  • The imports are correct.
  • The stepsData ref is defined correctly with an array of step objects.
  • The handleChange method logic is correct. It checks the length of the stepsData array and adds or removes a step accordingly.

However, the handleChange method mutates the stepsData array directly. This is generally not recommended in Vue 3. It's better to use immutable update patterns.

Consider using the spread operator to create a new array instead of mutating the existing one:

const handleChange = () => {
  if (stepsData.value.length > 3) {
-   stepsData.value.pop()
+   stepsData.value = stepsData.value.slice(0, -1)
  } else {
-   stepsData.value.push({
+   stepsData.value = [...stepsData.value, {
      name: '域名解析',
      description: '域名解析的内容'
-   })
+   }]
  }
}
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
<script setup>
import { ref } from 'vue'
import { Button as TinyButton, Steps as TinySteps, Link as TinyLink } from '@opentiny/vue'
import { IconFilletExternalLink } from '@opentiny/vue-icon'
const stepsData = ref([
{
name: '创建桶(超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题)',
status: 'done',
description:
'桶是存储对象的容器,用于存储您的数据,我这个描述要超出隐藏,我这个描述要超出隐藏,我这个描述要超出隐藏',
links: [{ title: '前往创建' }, { title: '前往创建' }]
},
{ name: '上传文件', status: 'doing', description: '上传您项目相关的文件至桶内存储' },
{
name: '购买资源包(可选)',
description: '资源包是预付费的优惠套餐,可降低存储成本。',
links: [{ title: '了解套餐详情', icon: IconFilletExternalLink() }]
}
])
const handleChange = () => {
if (stepsData.value.length > 3) {
stepsData.value.pop()
} else {
stepsData.value.push({
name: '域名解析',
description: '域名解析的内容'
})
}
}
</script>
<script setup>
import { ref } from 'vue'
import { Button as TinyButton, Steps as TinySteps, Link as TinyLink } from '@opentiny/vue'
import { IconFilletExternalLink } from '@opentiny/vue-icon'
const stepsData = ref([
{
name: '创建桶(超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题)',
status: 'done',
description:
'桶是存储对象的容器,用于存储您的数据,我这个描述要超出隐藏,我这个描述要超出隐藏,我这个描述要超出隐藏',
links: [{ title: '前往创建' }, { title: '前往创建' }]
},
{ name: '上传文件', status: 'doing', description: '上传您项目相关的文件至桶内存储' },
{
name: '购买资源包(可选)',
description: '资源包是预付费的优惠套餐,可降低存储成本。',
links: [{ title: '了解套餐详情', icon: IconFilletExternalLink() }]
}
])
const handleChange = () => {
if (stepsData.value.length > 3) {
stepsData.value = stepsData.value.slice(0, -1)
} else {
stepsData.value = [...stepsData.value, {
name: '域名解析',
description: '域名解析的内容'
}]
}
}
</script>

Comment on lines +21 to +63
<script>
import { Button, Steps, Link } from '@opentiny/vue'
import { IconFilletExternalLink } from '@opentiny/vue-icon'

export default {
components: {
TinyButton: Button,
TinySteps: Steps,
TinyLink: Link
},
data() {
return {
stepsData: [
{
name: '创建桶(超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题)',
status: 'done',
description:
'桶是存储对象的容器,用于存储您的数据,我这个描述要超出隐藏,我这个描述要超出隐藏,我这个描述要超出隐藏',
links: [{ title: '前往创建' }, { title: '前往创建' }]
},
{ name: '上传文件', status: 'doing', description: '上传您项目相关的文件至桶内存储' },
{
name: '购买资源包(可选)',
description: '资源包是预付费的优惠套餐,可降低存储成本。',
links: [{ title: '了解套餐详情', icon: IconFilletExternalLink() }]
}
]
}
},
methods: {
handleChange() {
if (this.stepsData.length > 3) {
this.stepsData.pop()
} else {
this.stepsData.push({
name: '域名解析',
description: '域名解析的内容'
})
}
}
}
}
</script>
Copy link

Choose a reason for hiding this comment

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

The script section looks good! Consider a minor refactor.

The component imports, components option, data property, and handleChange method are all implemented correctly.

As a minor refactor suggestion, consider using array spread syntax in the handleChange method when adding a new step to stepsData to make it more concise:

handleChange() {
  if (this.stepsData.length > 3) {
    this.stepsData.pop()
  } else {
-   this.stepsData.push({
+   this.stepsData = [...this.stepsData, {
      name: '域名解析',
      description: '域名解析的内容'
-   })
+   }]
  }
}
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
<script>
import { Button, Steps, Link } from '@opentiny/vue'
import { IconFilletExternalLink } from '@opentiny/vue-icon'
export default {
components: {
TinyButton: Button,
TinySteps: Steps,
TinyLink: Link
},
data() {
return {
stepsData: [
{
name: '创建桶(超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题)',
status: 'done',
description:
'桶是存储对象的容器,用于存储您的数据,我这个描述要超出隐藏,我这个描述要超出隐藏,我这个描述要超出隐藏',
links: [{ title: '前往创建' }, { title: '前往创建' }]
},
{ name: '上传文件', status: 'doing', description: '上传您项目相关的文件至桶内存储' },
{
name: '购买资源包(可选)',
description: '资源包是预付费的优惠套餐,可降低存储成本。',
links: [{ title: '了解套餐详情', icon: IconFilletExternalLink() }]
}
]
}
},
methods: {
handleChange() {
if (this.stepsData.length > 3) {
this.stepsData.pop()
} else {
this.stepsData.push({
name: '域名解析',
description: '域名解析的内容'
})
}
}
}
}
</script>
<script>
import { Button, Steps, Link } from '@opentiny/vue'
import { IconFilletExternalLink } from '@opentiny/vue-icon'
export default {
components: {
TinyButton: Button,
TinySteps: Steps,
TinyLink: Link
},
data() {
return {
stepsData: [
{
name: '创建桶(超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题)',
status: 'done',
description:
'桶是存储对象的容器,用于存储您的数据,我这个描述要超出隐藏,我这个描述要超出隐藏,我这个描述要超出隐藏',
links: [{ title: '前往创建' }, { title: '前往创建' }]
},
{ name: '上传文件', status: 'doing', description: '上传您项目相关的文件至桶内存储' },
{
name: '购买资源包(可选)',
description: '资源包是预付费的优惠套餐,可降低存储成本。',
links: [{ title: '了解套餐详情', icon: IconFilletExternalLink() }]
}
]
}
},
methods: {
handleChange() {
if (this.stepsData.length > 3) {
this.stepsData.pop()
} else {
this.stepsData = [...this.stepsData, {
name: '域名解析',
description: '域名解析的内容'
}]
}
}
}
}
</script>

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.

3 participants