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(card): Simplification and optimization of card components #2496

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Nov 7, 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

    • Updated the Card component's API to streamline properties and events for improved usability.
    • Introduced new styling for the demo-card-custom-class to enhance visual appeal.
  • Bug Fixes

    • Removed deprecated demos from the documentation to reduce confusion and improve clarity.
  • Style

    • Enhanced card styling with a new border-radius for a more modern look.
  • Refactor

    • Simplified component structure by removing unused options and imports across various card-related components.

Copy link

coderabbitai bot commented Nov 7, 2024

Walkthrough

The changes in this pull request involve significant modifications to the Card component's API and related Vue components. Properties and events have been removed from the Card component's API definition, simplifying its interface. Additionally, several demo entries have been eliminated from the documentation. The styling of the card components has been updated, including changes to class names and the introduction of new styles. Overall, the modifications streamline the component's structure, reducing complexity and improving clarity.

Changes

File Path Change Summary
examples/sites/demos/apis/card.js Removed multiple properties (check-type, disabled, icon-more, label, options, size, status, v-model, check-mode) and events (change, icon-click, click). Updated footer slot description. Commented out types array including IOptions interface.
examples/sites/demos/pc/app/card/custom-class-composition-api.vue Changed wrapper class from card-wrap to a plain div. Updated tiny-card component's custom-class from my-card to demo-card-custom-class. Removed several imports and the options reactive array. Introduced new styles for .demo-card-custom-class.
examples/sites/demos/pc/app/card/custom-class.vue Simplified outer <div> by removing card-wrap class. Updated tiny-card component's custom-class from my-card to demo-card-custom-class. Removed second tiny-card instance and associated options data structure.
examples/sites/demos/pc/app/card/webdoc/card.js Removed multiple demo entries (card-size, card-disabled, card-group, card-status, check-type-checkbox, check-mode, card-select, operate-bar, card-events).
packages/theme/src/card/index.less Added border-radius: 8px; to the main card class, commented out existing border-radius properties for various card sizes. Hover effect remains unchanged.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • zzcr

🐰 "In the garden where cards once bloomed,
Properties vanished, and events were entombed.
With styles refined and classes anew,
The Card stands simpler, a fresh view!
A hop and a skip, we celebrate this change,
In our code's meadow, let’s rearrange!" 🐇


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 enhancement New feature or request label Nov 7, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (6)
examples/sites/demos/pc/app/card/custom-class-composition-api.vue (1)

17-19: LGTM! Clear and focused styling.

The styles effectively demonstrate custom class usage with appropriate scoping. Consider using CSS custom properties for the background color to maintain consistency with the design system.

.demo-card-custom-class {
  padding: 20px;
-  background-color: #f0f0f0;
+  background-color: var(--ti-base-color-bg-1, #f0f0f0);
}
examples/sites/demos/pc/app/card/custom-class.vue (1)

23-25: Add documentation to explain the demo's purpose.

While the styling is clear, consider adding comments to explain:

  • The purpose of this demo
  • How users can apply custom classes to cards
  • Best practices for card styling

Example improvement:

 <template>
+  <!-- This demo shows how to apply custom styling to TinyCard components using the custom-class prop -->
   <div>
     <tiny-card title="这是卡片标题" custom-class="demo-card-custom-class">
packages/theme/src/card/index.less (1)

Line range hint 1-276: Consider standardizing all border-radius values.

The file contains multiple hardcoded border-radius values (8px, 6px) in different places. Consider:

  1. Creating a set of standardized border-radius CSS variables
  2. Using these variables consistently throughout the component

Example approach:

// In vars.less
@card-border-radius-lg: 8px;
@card-border-radius-sm: 6px;

// Usage in the component
--tv-Card-border-radius: @card-border-radius-lg;
--tv-Card-checkbox-border-radius: @card-border-radius-sm;
examples/sites/demos/pc/app/card/webdoc/card.js (1)

56-57: Improve documentation comment structure.

The current comment "以下demo示例将暂不暴露" (These demo examples will not be exposed temporarily) could be more informative.

Consider replacing with a more detailed comment that explains:

  1. Why these features are being removed
  2. Whether they will be reintroduced in a different form
  3. What alternatives users should consider
-    // 以下demo示例将暂不暴露
+    // The following demos have been temporarily removed as part of the Card component simplification effort.
+    // These features will be reimplemented in a future release with improved APIs.
+    // For now, please use the basic card features and custom styling for similar functionality.
examples/sites/demos/apis/card.js (2)

295-322: Document alternative patterns for operation buttons

With the removal of the IOptions interface and related functionality, please:

  1. Document recommended patterns for implementing operation buttons
  2. Consider providing examples of custom implementations in the component documentation

Line range hint 1-322: Add migration guide for breaking changes

This PR introduces significant breaking changes by removing multiple properties, all events, and type definitions. Please:

  1. Add a migration guide documenting:
    • Removed APIs and their replacements/workarounds
    • Examples of migrating common use cases
    • Timeline for deprecation (if applicable)
  2. Consider a phased approach:
    • Deprecate APIs first with warnings
    • Remove in next major version
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eafb17c and 247c073.

📒 Files selected for processing (5)
  • examples/sites/demos/apis/card.js (3 hunks)
  • examples/sites/demos/pc/app/card/custom-class-composition-api.vue (2 hunks)
  • examples/sites/demos/pc/app/card/custom-class.vue (2 hunks)
  • examples/sites/demos/pc/app/card/webdoc/card.js (1 hunks)
  • packages/theme/src/card/index.less (1 hunks)
🔇 Additional comments (7)
examples/sites/demos/pc/app/card/custom-class-composition-api.vue (2)

2-3: LGTM! Template changes improve clarity.

The simplified wrapper and semantic custom class name enhance the demo's readability while maintaining functionality.


12-13: Consider documenting the removal of interactive options.

The script has been simplified to focus on class customization, which aligns with the component's simplification goals. However, since interactive options (delete, edit, sort, share) were removed, consider updating the documentation to reflect these API changes.

examples/sites/demos/pc/app/card/custom-class.vue (2)

2-3: LGTM! Improved class naming convention.

The simplified template structure with the standardized class naming convention (demo-card-custom-class) improves code clarity and maintainability.


Line range hint 2-25: Verify alignment with updated Card API.

Since this is part of a larger card component simplification effort, let's verify that this demo accurately reflects the current API.

✅ Verification successful

The custom-class prop is properly supported in the Card component

The code review shows that the custom-class prop is properly defined and implemented in both PC and mobile-first versions of the Card component:

  • It's defined in the component's props (index.ts): customClass: String
  • It's used in the template for both PC and mobile-first versions
  • The demo correctly demonstrates its usage for styling customization

The implementation aligns with the current Card API and no issues are found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if this demo aligns with the current Card API documentation

# Look for the main Card API definition file
fd -t f "card.js" -X grep -l "export const api"

# Check for any other demos that might need similar updates
fd -t f -e vue "card" examples/sites/demos/pc/app/card

Length of output: 894


Script:

#!/bin/bash
# Let's check the Card component's source code and API documentation

# Search for Card component definition and props
ast-grep --pattern 'defineComponent({
  $$$
  props: {
    $$$
  }
  $$$
})'

# Search for custom-class prop specifically
rg -A 3 "custom-class|customClass" 

# Check webdoc or API documentation
fd -t f -e md "card" -X grep -l "custom-class"

Length of output: 108866


Script:

#!/bin/bash
# Let's check the Card component's source code and props specifically

# Search for Card component definition and custom-class prop
ast-grep --pattern 'customClass: {
  $$$
}'

# Look for Card API documentation
rg -A 5 "custom-class|customClass" "packages/vue/src/card/src"

# Check if there are any recent changes to the Card component
rg -A 5 "custom-class|customClass" "packages/vue/src/card"

Length of output: 3713

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

27-27: Verify the impact of fixed border-radius.

While simplifying to a fixed border-radius aligns with the PR's goal, this change could affect existing implementations that rely on size-specific border radiuses.

Consider:

  1. Documenting this as a breaking change in the PR description
  2. Using a CSS variable for the border-radius value to maintain flexibility:
-  border-radius: 8px;
+  border-radius: var(--tv-Card-border-radius, 8px);
examples/sites/demos/pc/app/card/webdoc/card.js (1)

56-176: ⚠️ Potential issue

Verify breaking changes and update documentation accordingly.

The commented out demos indicate significant feature removals from the Card component:

  • Size variations (mini, small, medium, large)
  • Disabled state
  • Card grouping
  • Status indicators
  • Selection modes (checkbox/radio)
  • Operation bar
  • Event handling (change, icon-click events)

These removals represent breaking changes that could impact existing implementations.

Please ensure that:

  1. These removals are intentional and aligned with the component's roadmap
  2. Breaking changes are documented in the changelog
  3. Migration guide is provided for users to update their implementations
examples/sites/demos/apis/card.js (1)

80-190: Clarify the permanence of API removals

The comment "以下IPI暂不暴露" (these APIs are temporarily not exposed) suggests these removals might be temporary, which conflicts with the PR's simplification objective. Additionally, some of the removed properties seem fundamental to component functionality:

  • disabled: Common accessibility requirement
  • size: Basic styling requirement
  • status: Important for visual feedback

Please clarify:

  1. Are these removals permanent or temporary?
  2. How should consumers handle these common requirements without these props?

Let's verify the impact of these removals:

packages/theme/src/card/index.less Show resolved Hide resolved
examples/sites/demos/apis/card.js Show resolved Hide resolved
examples/sites/demos/apis/card.js Show resolved Hide resolved
@Youyou-smiles Youyou-smiles changed the title feat(card): [card] Simplification and optimization of card components feat(card): Simplification and optimization of card components Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

[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

@zzcr zzcr merged commit ccd1aa8 into dev Nov 8, 2024
8 of 10 checks passed
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