-
Notifications
You must be signed in to change notification settings - Fork 277
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(tag): [tag] refactor tag 's theme and demos #2264
Conversation
WalkthroughThe changes in this pull request involve updates to the Changes
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
[e2e-test-warn] 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Outside diff range and nitpick comments (35)
examples/sites/demos/pc/app/tag/basic-usage.spec.ts (2)
3-3
: Consider updating the file name to match the new test focus.The test case name has been changed from "各型号尺寸是否正常" (Normal sizes for each model) to "配置式标签" (Configuration Tag). This change reflects a shift in the test's focus. However, the file name "basic-usage.spec.ts" no longer accurately represents the content of the test.
Consider renaming the file to something like "configuration-tag.spec.ts" to better align with the new test focus.
7-9
: New assertion is good, but consider adding more comprehensive checks.The new assertion correctly checks for the presence of the '配置式标签' (Configuration Tag). This aligns well with the updated test focus.
However, to ensure comprehensive testing:
- Consider adding assertions to check the tag's functionality (e.g., can it be closed if closable?).
- Verify the tag's appearance (e.g., correct color, size, etc.).
- If the configuration aspect is important, add assertions to check if the tag reflects the expected configuration.
Example of additional checks:
const tag = page.locator('.all-demos-container').getByText('配置式标签') await expect(tag).toHaveCount(1) // Check tag's appearance await expect(tag).toHaveCSS('background-color', 'expected-color') await expect(tag).toHaveCSS('font-size', 'expected-size') // Check tag's functionality (if closable) const closeButton = tag.locator('.close-button') await closeButton.click() await expect(tag).toHaveCount(0) // Check configuration is applied correctly await expect(tag).toHaveAttribute('data-config', 'expected-config-value')examples/sites/demos/pc/app/tag/basic-usage-composition-api.vue (2)
6-10
: Script setup looks good, with a minor optimization possibleThe script section correctly uses the Composition API setup syntax and imports the necessary components. However, there's a small optimization opportunity:
The
tinyIconHeartempty
constant is created but not used in the script or template. You can remove this line:- const tinyIconHeartempty = IconHeartempty()
The icon is already directly used in the template as
<tiny-icon-heartempty>
, so this constant is unnecessary.
13-15
: Style changes improve layout, consider using CSS variablesThe style changes look good:
- Scoped styles ensure these only apply to this component.
- The increased margin-right (16px) improves spacing between tags.
For better consistency and maintainability, consider using a CSS variable for the margin:
<style scoped> .tiny-tag { - margin-right: 16px; + margin-right: var(--tiny-tag-margin-right, 16px); } </style>This allows for easier theme customization and ensures consistency across components.
examples/sites/demos/pc/app/tag/basic-usage.vue (3)
2-3
: LGTM! Consider adding more diverse examples.The refactored template provides a clearer demonstration of the
tiny-tag
component's capabilities. It showcases different types ("success" and "info") and methods of setting content (slot andvalue
prop).Consider adding one or two more examples to demonstrate other tag types (e.g., "warning" or "danger") or additional props like
closable
to provide a more comprehensive overview of the component's features.
6-14
: LGTM! Consider simplifying the icon component registration.The script section has been updated appropriately to support the new template structure. The import of
IconHeartempty
and its registration as a component are correct.The registration of
TinyIconHeartempty
appears to use a function callIconHeartempty()
. This might be unnecessary. Consider simplifying it to:- TinyIconHeartempty: IconHeartempty() + TinyIconHeartempty: IconHeartemptyThis change assumes
IconHeartempty
is a component and not a factory function. Please verify this assumption before making the change.
18-21
: LGTM! Consider vertical spacing for multiple rows.The style changes improve the horizontal spacing between tags and properly scope the styles to this component.
While the horizontal spacing has been improved, consider the scenario where tags might wrap to multiple lines. You might want to add a
margin-bottom
property to ensure adequate vertical spacing:.tiny-tag { margin-right: 16px; + margin-bottom: 8px; }
This change would ensure consistent spacing both horizontally and vertically when multiple tags are displayed.
examples/sites/demos/pc/app/tag/size-composition-api.vue (2)
1-8
: LGTM! Consider adding ARIA labels for accessibility.The template structure effectively demonstrates the various sizes of the
tiny-tag
component. The presentation is clear and logical, showcasing the sizes from largest to smallest.Consider adding ARIA labels to improve accessibility, especially for screen readers that may not read the Chinese characters correctly. For example:
- <tiny-tag size="medium"> 中等标签 </tiny-tag> + <tiny-tag size="medium" aria-label="Medium tag"> 中等标签 </tiny-tag>
14-19
: LGTM! Consider scoping the styles.The styles effectively add spacing between the tags, improving the demo's readability.
Consider adding the
scoped
attribute to the<style>
tag to ensure these styles don't affect other components:- <style> + <style scoped>This change will limit the style's effect to only this component, preventing potential conflicts with other parts of the application.
examples/sites/demos/pc/app/tag/size.spec.ts (2)
3-3
: Consider using English for the test title and add a description.While the current title "各型号尺寸是否正常" is descriptive, it's recommended to use English for consistency across the codebase. Additionally, consider adding a test description for better clarity.
Here's a suggested improvement:
test('Tag sizes are rendered correctly', async ({ page }) => { // Test that different tag sizes (default, medium, small, mini) have the correct heights // ...
12-15
: LGTM: Assertions are correct. Consider adding more comprehensive tests.The height assertions for each tag size are correct and cover all sizes. To make the test more robust, consider adding assertions for other CSS properties like padding, font-size, or color.
Here's a suggested addition to make the tests more comprehensive:
// Existing height assertions await expect(normal).toHaveCSS('height', '22px'); await expect(medium).toHaveCSS('height', '24px'); await expect(small).toHaveCSS('height', '20px'); await expect(mini).toHaveCSS('height', '16px'); // Additional assertions for other properties await expect(normal).toHaveCSS('padding', '0 9px'); await expect(medium).toHaveCSS('padding', '0 10px'); await expect(small).toHaveCSS('padding', '0 8px'); await expect(mini).toHaveCSS('padding', '0 6px'); // Font size assertions await expect(normal).toHaveCSS('font-size', '14px'); await expect(medium).toHaveCSS('font-size', '14px'); await expect(small).toHaveCSS('font-size', '12px'); await expect(mini).toHaveCSS('font-size', '12px');These additional assertions will provide a more complete test of the tag's visual properties.
examples/sites/demos/pc/app/tag/slot-default-composition-api.vue (2)
3-6
: LGTM! Consider adding a comment for clarity.The changes to the
<tiny-tag>
components improve the demo by simplifying the first tag and adding a new variation with an icon. This provides a clearer demonstration of the component's capabilities.Consider adding a comment above each
<tiny-tag>
to explain what aspect of the component it's demonstrating. For example:<!-- Basic tag with icons --> <tiny-tag size="small"> ... </tiny-tag> <!-- Closable tag with icon --> <tiny-tag closable> ... </tiny-tag>
This would enhance the readability and educational value of the demo.
20-22
: Style changes improve layout. Consider using CSS custom properties.The addition of margin to
.tiny-tag
improves the spacing between tags, which enhances the overall layout of the demo. The removal of unnecessary CSS rules (as mentioned in the AI summary) simplifies the styling and makes it more maintainable.Consider using CSS custom properties for the margin value to improve maintainability:
:root { --tiny-tag-margin-right: 10px; } .tiny-tag { margin-right: var(--tiny-tag-margin-right); }This approach would make it easier to adjust the spacing globally if needed.
examples/sites/demos/pc/app/tag/slot-default.vue (2)
3-6
: LGTM! Consider adding aria-label for accessibility.The changes to the template look good. The use of
tiny-icon-*
components is consistent with the script section, and the addition of theclosable
prop enhances functionality.Consider adding an
aria-label
to the tags for improved accessibility, especially for screen readers. For example:- <tiny-tag size="small"> + <tiny-tag size="small" aria-label="Small tag with file upload icon">
17-19
: LGTM! Consider updating imports for consistency.The changes to the component registration look good and align with the template updates.
For consistency, consider updating the import statements at the top of the script section to reflect the new component names:
- import { IconTime, IconFileupload, IconChevronRight } from '@opentiny/vue-icon' + import { TinyIconTime, TinyIconFileupload, TinyIconChevronRight } from '@opentiny/vue-icon' export default { components: { TinyTag: Tag, - TinyIconTime: IconTime(), - TinyIconFileupload: IconFileupload(), - TinyIconChevronRight: IconChevronRight() + TinyIconTime, + TinyIconFileupload, + TinyIconChevronRight } }This change would make the imports consistent with the component registration and improve code readability.
examples/sites/demos/pc/app/tag/color-border-composition-api.vue (1)
14-15
: Great addition of custom background and text color example.The new section effectively demonstrates an advanced use case of the
<tiny-tag>
component, showing how to customize both background (with a gradient) and text color. This addition enhances the documentation by providing users with more information about the component's capabilities.Consider adding a brief comment explaining the array syntax used for setting both background and text color. This could help users understand the API more quickly:
<tiny-tag :color="['linear-gradient(to right, #e8cda4, #f8eddb)', '#8f3c00']" title="First value sets background, second sets text color" > 自定义背景色和文本色 </tiny-tag>examples/sites/demos/pc/app/tag/color-border.vue (1)
12-15
: Excellent addition of custom color examplesThe new sections for custom background and custom background with text color are valuable additions to the demo. They effectively showcase the flexibility of the
tiny-tag
component for advanced customization scenarios.Consider adding a brief comment above each custom tag to explain the syntax used, especially for the gradient background with custom text color. This would help users understand how to apply these advanced customizations in their own code.
packages/vue/src/tag/src/pc.vue (2)
23-35
: LGTM! Props declaration reformatted for improved readability.The multi-line format enhances code readability without changing functionality. All props are correctly transferred and maintain their original order.
Consider moving the comment for the 'hit' prop to the prop's documentation for better maintainability and consistency with other props' documentation.
Line range hint
1-85
: Suggestions for future improvementsWhile not directly related to the changes in this PR, consider the following improvements for future refactoring:
The type annotation for the setup function return value uses 'unknown'. Consider using a more specific type for better type safety.
The render function is quite long. Consider splitting it into smaller, more manageable functions for improved readability and maintainability.
The color logic in the render function could be extracted into a separate function. This would make the code more modular and easier to understand.
Would you like assistance in implementing any of these suggestions in a future PR?
examples/sites/demos/pc/app/alert/webdoc/alert.js (1)
Line range hint
1-43
: Overall assessment: Minor but valuable HTML improvementsThe changes made to this file are minor but important for maintaining proper HTML structure in the demo descriptions. Both modifications involve adding closing
</ul>
tags, which ensures valid HTML and consistent rendering.While these changes are beneficial, it might be worth considering a more comprehensive review of all HTML content in the file to ensure similar issues don't exist elsewhere. This could involve checking for any other unclosed tags or inconsistencies in the HTML structure across all demo descriptions.
Consider running a linter or HTML validator on this file and similar documentation files to catch any other potential HTML structure issues.
examples/sites/demos/apis/tag.js (4)
Line range hint
41-41
: Update type to lowercase 'string' for consistency.The
type
for thecustom-class
prop is currently 'String'. To maintain consistency with JavaScript conventions and other prop types in this file, it should be changed to lowercase 'string'.Please apply the following change:
- type: 'String', + type: 'string',
Line range hint
102-102
: Update type to lowercase 'boolean' for consistency.The
type
for theoperable
prop is currently 'Boolean'. To maintain consistency with JavaScript conventions and other prop types in this file, it should be changed to lowercase 'boolean'.Please apply the following change:
- type: 'Boolean', + type: 'boolean',
Line range hint
111-111
: Update type to lowercase 'boolean' for consistency.The
type
for theselectable
prop is currently 'Boolean'. To maintain consistency with JavaScript conventions and other prop types in this file, it should be changed to lowercase 'boolean'.Please apply the following change:
- type: 'Boolean', + type: 'boolean',
Line range hint
223-223
: Fix syntax error in 'close' event type signature.The
type
for theclose
event contains a syntax error with an extra closing parenthesis. This should be corrected to ensure proper type checking and documentation.Please apply the following change:
- type: '(event: Event)) => void', + type: '(event: Event) => void',packages/theme/src/tag/test-vars.less (3)
51-129
: Theme variables are comprehensive and well-organized.The variables for light, dark, and plain themes are thoroughly defined, covering various aspects of tag styling including text color, background color, and border color for different states and types.
Consider adding comments to separate the theme sections more clearly, e.g.:
// Light theme variables // ... // Dark theme variables // ... // Plain theme variables // ...This would improve readability and make it easier to navigate the file.
132-158
: Color-specific tag variables provide good styling options.The color-specific variables for red, orange, green, blue, purple, brown, and grey tags offer a wide range of styling options.
Consider using common design tokens for all color values instead of hardcoded hex values. This would improve consistency and make it easier to maintain the theme. For example:
--ti-tag-purple-text-color: var(--ti-common-color-purple, #832fd6); --ti-tag-purple-bg-color: var(--ti-common-color-purple-bg, #f4e0fc);Ensure that these common color variables are defined in your global theme file.
1-161
: Overall, thetest-vars.less
file is well-structured and comprehensive.This file provides a robust set of CSS custom properties for tag styling, covering various sizes, themes, states, and colors. The use of common design tokens for fallback values ensures consistency across the theme.
To further improve the file:
- Consider adding section comments to improve readability.
- Use common design tokens for all color values to enhance maintainability.
- Consider grouping the disabled state variable (line 160) with other state-related variables for better organization.
These minor improvements will make the file even more maintainable and easier to navigate.
packages/theme/src/tag/index.less (6)
28-28
: Use consistent comment languageThe comment on line 28
/** size 场景 */
includes Chinese characters. For consistency and to ensure readability for all contributors, consider translating comments into English.
52-52
: Use consistent comment languageThe comment on line 52
/** 颜色场景 */
is in Chinese. Please translate it into English to maintain consistency across the codebase.
97-97
: Use consistent comment languageThe comment on line 97
// colors
is in English, whereas surrounding comments are in Chinese. For consistency, ensure all comments are in English.
124-124
: Use consistent comment languageThe comment on line 124
/** 关闭图标 场景 */
contains Chinese text. Translating it into English would enhance readability for all team members.
141-141
: Use consistent comment languageThe comment on line 141
/** 其它 场景 */
is in Chinese. Consider using English to maintain consistency throughout the code.
143-143
: Use consistent comment languageThe comment on line 143
// 默认插槽内的图标
is in Chinese. Please translate it into English for better understanding.packages/theme/src/tag/vars.less (2)
15-203
: Consider translating comments to English for consistencyMany comments in the code are written in Chinese. To improve accessibility and maintainability for all team members, consider translating the comments to English.
60-60
: Variable defined but comment indicates it's not neededThe variable
--tv-Tag-border-color-light
is defined, but the comment indicates that the specification does not require a border ("规范不需要边框"). If the border is not needed, consider removing this variable to avoid confusion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (24)
- examples/sites/demos/apis/tag.js (1 hunks)
- examples/sites/demos/pc/app/alert/webdoc/alert.js (2 hunks)
- examples/sites/demos/pc/app/tag/basic-usage-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tag/basic-usage.spec.ts (1 hunks)
- examples/sites/demos/pc/app/tag/basic-usage.vue (1 hunks)
- examples/sites/demos/pc/app/tag/color-border-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tag/color-border.vue (1 hunks)
- examples/sites/demos/pc/app/tag/content-composition-api.vue (0 hunks)
- examples/sites/demos/pc/app/tag/content.spec.ts (0 hunks)
- examples/sites/demos/pc/app/tag/content.vue (0 hunks)
- examples/sites/demos/pc/app/tag/create-composition-api.vue (0 hunks)
- examples/sites/demos/pc/app/tag/create.spec.ts (0 hunks)
- examples/sites/demos/pc/app/tag/create.vue (0 hunks)
- examples/sites/demos/pc/app/tag/size-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tag/size.spec.ts (1 hunks)
- examples/sites/demos/pc/app/tag/size.vue (1 hunks)
- examples/sites/demos/pc/app/tag/slot-default-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tag/slot-default.vue (2 hunks)
- examples/sites/demos/pc/app/tag/webdoc/tag.js (2 hunks)
- packages/theme/src/tag/index.less (1 hunks)
- packages/theme/src/tag/test-index.less (1 hunks)
- packages/theme/src/tag/test-vars.less (1 hunks)
- packages/theme/src/tag/vars.less (1 hunks)
- packages/vue/src/tag/src/pc.vue (1 hunks)
💤 Files with no reviewable changes (6)
- examples/sites/demos/pc/app/tag/content-composition-api.vue
- examples/sites/demos/pc/app/tag/content.spec.ts
- examples/sites/demos/pc/app/tag/content.vue
- examples/sites/demos/pc/app/tag/create-composition-api.vue
- examples/sites/demos/pc/app/tag/create.spec.ts
- examples/sites/demos/pc/app/tag/create.vue
🧰 Additional context used
🔇 Additional comments (31)
examples/sites/demos/pc/app/tag/basic-usage-composition-api.vue (1)
2-3
: Improved demonstration of TinyTag usageThe template has been simplified and now effectively demonstrates two key use cases of the TinyTag component:
- A tag with an embedded icon, showcasing component flexibility.
- A tag using the
value
attribute for configuration.This change provides a clearer and more concise example for users.
examples/sites/demos/pc/app/tag/size-composition-api.vue (1)
10-12
: LGTM! Script setup is correctly implemented.The script section is concise and correctly implemented. It properly imports the
Tag
component and aliases it asTinyTag
, which matches the usage in the template.examples/sites/demos/pc/app/tag/size.vue (1)
10-18
: LGTM: Script section is well-structured.The script section correctly imports and registers the
Tag
component asTinyTag
. The use of JSX is appropriately indicated, and the component setup is minimal and suitable for this demo.examples/sites/demos/pc/app/tag/size.spec.ts (3)
1-1
: LGTM: Imports are correct and concise.The necessary Playwright testing utilities are imported correctly.
1-16
: Summary: Good addition to the test suite with room for improvementsThis new test file for tag sizes is a valuable addition to ensure the correct rendering of different tag sizes. The test structure and assertions are fundamentally correct. However, there are several areas for improvement:
- Use English for test titles and descriptions for consistency.
- Clarify the navigation URL structure.
- Implement more robust element selection methods using data attributes.
- Expand the test coverage to include additional CSS properties beyond just height.
These changes will enhance the test's reliability, maintainability, and comprehensiveness.
4-5
: LGTM: Error handling is in place. Consider clarifying the navigation URL.The error listener is a good practice. However, the navigation URL 'tag#basic-usage' might benefit from more context.
Could you clarify if this is a relative path or if there's a base URL that should be prepended? Let's verify the URL structure:
examples/sites/demos/pc/app/tag/slot-default-composition-api.vue (2)
10-18
: Script section is consistent with template changes.The script section remains unchanged, which is appropriate given the modifications in the template. The removal of the
disabled
ref is consistent with its removal from the template, and all necessary imports for the components used in the template are present.
Line range hint
1-24
: Overall, these changes improve the demo's clarity and effectiveness.The modifications to this file have successfully simplified the tag component demo while still showcasing its key features. The removal of unnecessary props and classes, along with the addition of a new tag variation, provides a more focused and informative example. The style changes enhance the layout, and the script section remains appropriately minimal.
These changes align well with the PR's objective of refactoring the tag's theme and demos. They contribute to a cleaner, more maintainable codebase and a more effective demonstration of the component's capabilities.
examples/sites/demos/pc/app/tag/slot-default.vue (1)
Line range hint
1-31
: Verify PR objectives: Removal of dynamic tag exampleThe changes in this file look good and align with the refactoring goals. However, I noticed that the PR objectives mention removing the example for dynamically adding tags, which is not present in this file.
To ensure all PR objectives are met, please run the following script to check if the dynamic tag example has been removed from other files:
If the script returns results, please review those files to ensure the dynamic tag example has been removed as intended.
✅ Verification successful
PR Objective Verified: Dynamic Tag Example Removed
The search did not find any instances of dynamic tag examples in the specified directory, confirming that the dynamic tag example has been removed as per the PR objectives.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for the presence of dynamic tag example # Test: Search for files that might contain dynamic tag examples rg --type vue -i "dynamic.*tag" examples/sites/demos/pc/app/tagLength of output: 93
Script:
#!/bin/bash # Description: Check for the presence of dynamic tag example # Search for "dynamic tag" in .vue files within the specified directory rg -i "dynamic.*tag" examples/sites/demos/pc/app/tag --glob "*.vue"Length of output: 69
examples/sites/demos/pc/app/tag/color-border-composition-api.vue (3)
11-11
: LGTM: Addition of gold tag enhances color variety.The inclusion of the gold tag is a good addition to the preset color demonstration, providing users with more color options to choose from.
12-13
: Improved clarity in custom background demonstration.The changes in this section enhance clarity:
- The new header "自定义背景:" more accurately describes the feature being demonstrated.
- The example is simplified to a single tag, which may be easier for users to understand.
These modifications align well with the overall goal of improving the component's documentation and examples.
Line range hint
24-27
: Approval of style removal with verification suggestion.The removal of the
.tiny-tag
class style is a good change as it suggests better encapsulation of styles within the<tiny-tag>
component itself.Please verify that the border-radius is still applied correctly to the tags, either through the component's internal styles or global styles. Run the following command to check for border-radius styles applied to the tag component:
examples/sites/demos/pc/app/tag/color-border.vue (2)
11-11
: LGTM: Addition of gold color tagThe new gold color tag enhances the variety of preset color options demonstrated in this example. It follows the existing pattern and provides users with an additional color choice.
Line range hint
32-36
: Approve CSS simplification and verify component stylingThe removal of the
.tiny-tag
class from the scoped CSS is a good practice, as it suggests that the component now handles its own styling internally. This promotes consistency and reduces the risk of unintended style overrides.To ensure that the border-radius styling is correctly handled by the component, please run the following verification:
This will help confirm that the border-radius is properly defined within the component's base styles.
packages/vue/src/tag/src/pc.vue (1)
Line range hint
1-85
: Summary: Props declaration refactored for improved readabilityThe changes in this PR successfully improve the readability of the props declaration without altering functionality. All props are correctly transferred and maintain their original order. The rest of the file remains unchanged.
While not part of this PR's scope, some suggestions for future improvements have been provided to enhance type safety, modularity, and overall code structure.
examples/sites/demos/pc/app/tag/webdoc/tag.js (7)
12-19
: Improved description for basic usage demoThe updated description for the 'basic-usage' demo provides more detailed information about using the default slot and the
value
property. This change enhances the clarity of the documentation for both Chinese and English users.
24-35
: Improved focus and clarity for theme demoThe 'content' demo has been appropriately renamed to 'effect' and now clearly focuses on demonstrating themes. The updated description provides specific information about using the
effect
andtype
properties, enhancing the usefulness of this demo for developers.
64-73
: Improved focus and clarity for size customization demoThe 'effect' demo has been appropriately renamed to 'size' and now clearly focuses on demonstrating size customization options. The updated description provides specific information about using the
size
property, enhancing the usefulness of this demo for developers.
104-105
: Improved naming for default slot demoThe name of the 'slot-default' demo has been updated to better reflect its focus on the default slot. This change improves the clarity of the demo's purpose for developers.
Line range hint
1-130
: Overall improvement in demo organization and clarityThe changes to this file have significantly improved the organization and clarity of the tag component demos. The descriptions are more detailed and focused, providing better guidance for developers. The renaming of some demos (e.g., 'effect' to 'size') aligns them more closely with their actual purposes.
However, the removal of the 'create' demo needs further clarification to ensure no important functionality has been lost in the refactoring process.
These changes should enhance the developer experience when working with the tag component, but it's important to ensure that all necessary functionality is still covered in the updated demo set.
Line range hint
1-1
: Clarification needed on removal of 'create' demoThe 'create' demo entry has been removed from the demos array. Could you please provide context for this removal? It's important to ensure that this doesn't negatively impact the completeness of the documentation or remove any crucial examples for users.
To help understand the impact, please run the following command to check for any references to the removed 'create' demo:
#!/bin/bash # Description: Check for references to the removed 'create' demo # Test: Search for references to the 'create' demo in the codebase rg --type vue --type js 'create' examples/sites/demos/pc/app/tag/If the 'create' demo is still relevant, I can assist in updating it to fit the new structure or incorporating its functionality into other demos.
44-59
: Enhanced description and added warning for color customizationThe description for the 'color-border' demo has been significantly improved, providing more detailed information about color customization options. The added warning about avoiding simultaneous use of
color
,type
, andeffect
properties is particularly helpful for preventing conflicts.Please verify that the HTML used in the description (particularly the
<div class="tip custom-block">
) renders correctly in your documentation system.✅ Verification successful
HTML rendering verified in
tag.js
The
<div class="tip custom-block">
elements are correctly present inexamples/sites/demos/pc/app/tag/webdoc/tag.js
, ensuring proper rendering in the documentation system.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if HTML is properly handled in the documentation system # Test: Search for HTML usage in demo descriptions rg --type js '<div class="tip custom-block">' examples/sites/demos/pc/app/tag/webdoc/Length of output: 202
Script:
#!/bin/bash # Description: Verify HTML rendering elements in both JS and Vue files within the documentation demos # Search for HTML usage in .js and .vue files in the specified directory rg '<div class="tip custom-block">' examples/sites/demos/pc/app/tag/webdoc/ --type js --type vueLength of output: 126
Script:
#!/bin/bash # Description: Verify HTML rendering elements in both JS and Vue files within the documentation demos # Ensure the target directory exists if [ ! -d "examples/sites/demos/pc/app/tag/webdoc/" ]; then echo "Directory examples/sites/demos/pc/app/tag/webdoc/ does not exist." exit 1 fi # Search for the specific HTML snippet in .js and .vue files rg '<div class="tip custom-block">' examples/sites/demos/pc/app/tag/webdoc/ -g '*.js' -g '*.vue'Length of output: 327
examples/sites/demos/pc/app/alert/webdoc/alert.js (2)
33-33
: Approved: Proper HTML structure maintainedThe addition of the closing
</ul>
tag is correct and necessary. It ensures that the unordered list in the description is properly structured, which is crucial for maintaining valid HTML and ensuring correct rendering across different platforms and browsers.
43-43
: Approved: Consistent HTML structure improvementThe addition of the closing
</ul>
tag here is correct and maintains consistency with the previous fix. This change ensures that all unordered lists in the demo descriptions are properly closed, contributing to overall HTML validity and consistent rendering.examples/sites/demos/apis/tag.js (1)
148-148
: LGTM. Verify the new 'size' demo.The
pcDemo
value for thesize
prop has been updated to 'size', which seems more appropriate. This change likely points to a new or renamed demo specifically for tag sizes.Please run the following script to verify the existence of the new size demo:
packages/theme/src/tag/test-vars.less (4)
1-11
: Copyright notice looks good.The copyright notice is properly included at the beginning of the file, providing necessary legal information and license details.
13-13
: Mixin declaration is correct.The mixin
.component-css-vars-tag()
is properly declared and follows the naming convention for component-specific CSS variables.
15-33
: Tag size variables are well-defined.The variables for different tag sizes (default, medium, small, mini) are properly defined with appropriate fallback values from common design tokens. This ensures consistency across the theme and allows for easy customization.
37-49
: State and type variables are well-defined.The variables for different tag states (normal, hover) and types (warning, danger, success, info) are comprehensively defined within each theme section. The close button styles are also properly addressed.
Also applies to: 64-89
packages/theme/src/tag/vars.less (2)
93-110
:⚠️ Potential issueInconsistent naming between comments and variable names for 'error' theme
The comments refer to the 'error' theme, but the variable names use 'danger'. For consistency and clarity, consider using a consistent term throughout, either 'error' or 'danger'.
You can run the following script to identify all occurrences of
danger
anderror
in variable names and comments:This will help you assess where each term is used and align the naming convention accordingly.
182-182
: Use of gradient background for 'gold' tag differs from othersThe variable
--tv-Tag-bg-color-gold
uses a gradient background, whereas other color variables use solid colors. Please confirm if this is intentional and aligns with the design specifications.To check where
--tv-Tag-bg-color-gold
is used and ensure it renders as expected, you can run the following script:This will help identify how the gradient background is applied and if it integrates well with the component styles.
✅ Verification successful
Gradient background for 'gold' tag is intentional, but usage unclear
The variable
--tv-Tag-bg-color-gold
is indeed defined with a gradient background in./packages/theme/src/tag/vars.less
:--tv-Tag-bg-color-gold: linear-gradient(to right, #e8cda4, #f8eddb);This confirms that the use of a gradient for the 'gold' tag is intentional and aligns with the current design specifications. However, no direct usages of this variable were found in the codebase, which raises questions about its implementation and consistency across the project.
To ensure proper utilization and maintain design consistency, please:
- Verify if this gradient is being applied correctly to gold tags in the UI.
- Check if there are any indirect usages of this variable through LESS/CSS mechanisms not caught by our search.
- Consider adding a comment in the
vars.less
file explaining the intentional difference for the gold tag, if not already present.- Ensure that the design team is aware of and approves this unique treatment for the gold tag.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find usages of '--tv-Tag-bg-color-gold' in the codebase # Search for the variable in LESS and Vue component files rg --type less --type vue '\-\-tv\-Tag\-bg\-color\-gold'Length of output: 2547
Script:
#!/bin/bash # Description: Find usages of '--tv-Tag-bg-color-gold' in .less and .vue files # Use fd to find all .less and .vue files, then search for the variable using rg fd -e less -e vue --exec rg '\-\-tv\-Tag\-bg\-color\-gold' {} +Length of output: 225587
Script:
#!/bin/bash # Description: Find definition and usages of '--tv-Tag-bg-color-gold' in the codebase # Search for the variable definition echo "Searching for variable definition:" find . -type f -name "*.less" -exec grep -H '--tv-Tag-bg-color-gold:' {} + # Search for potential usages of the variable echo -e "\nSearching for variable usages:" find . -type f \( -name "*.less" -o -name "*.css" -o -name "*.vue" -o -name "*.js" -o -name "*.ts" \) -exec grep -H '\-\-tv\-Tag\-bg\-color\-gold' {} +Length of output: 631
page.on('pageerror', (exception) => expect(exception).not.toBeNull()) | ||
await page.goto('tag#basic-usage') | ||
await page.goto('tag#content') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Remaining 'tag#basic-usage' reference found.
A leftover reference to 'tag#basic-usage'
was found in:
examples/sites/demos/pc/app/tag/size.spec.ts
Please update this to 'tag#content'
to ensure consistency across all test files.
🔗 Analysis chain
URL update looks good. Ensure consistency across test files.
The URL change from 'tag#basic-usage' to 'tag#content' aligns well with the new test focus. This change likely reflects updates to the component's demo structure or naming convention.
To ensure consistency, please verify that similar updates have been made in other relevant test files. You can run the following script to check for any remaining instances of 'tag#basic-usage':
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for remaining instances of 'tag#basic-usage' in test files
rg --type ts "tag#basic-usage" "examples/sites/demos/pc/app/tag/"
Length of output: 145
<template> | ||
<div class="tiny-tag-demo"> | ||
<tiny-tag size="medium"> 中等标签 </tiny-tag> | ||
<tiny-tag> 默认标签 </tiny-tag> | ||
<tiny-tag size="small"> 小型标签 </tiny-tag> | ||
<tiny-tag size="mini"> 超小标签 </tiny-tag> | ||
</div> | ||
</template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider internationalizing the tag content.
The template structure effectively demonstrates different tag sizes. However, the content of the tags is currently in Chinese. To improve accessibility for international users, consider using a localization system or providing translations.
You could implement this using vue-i18n or a similar internationalization library. For example:
<tiny-tag size="medium">{{ $t('mediumTag') }}</tiny-tag>
<tiny-tag>{{ $t('defaultTag') }}</tiny-tag>
<tiny-tag size="small">{{ $t('smallTag') }}</tiny-tag>
<tiny-tag size="mini">{{ $t('miniTag') }}</tiny-tag>
Then provide translations in your localization files.
<style> | ||
.tiny-tag-demo .tiny-tag { | ||
margin-right: 10px; | ||
margin-bottom: 10px; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider scoping styles and using responsive units.
The current styling effectively spaces the tags, but there are two potential improvements:
- Scoping: The styles are currently global. Consider scoping them to prevent potential conflicts in larger applications.
- Responsive units: Using pixels for margins might not be ideal for all screen sizes. Consider using relative units for better responsiveness.
Here's a suggested improvement:
<style scoped>
.tiny-tag-demo :deep(.tiny-tag) {
margin-right: 0.625rem;
margin-bottom: 0.625rem;
}
</style>
This change scopes the styles to the component and uses rem
units for better responsiveness. The :deep()
pseudo-class is used to target the child components.
const normal = page.getByText('默认标签') | ||
const medium = page.getByText('中等标签') | ||
const small = page.getByText('小型标签') | ||
const mini = page.getByText('超小标签') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using more robust element selection methods and consistent language.
While getByText()
works, it can be fragile if the text content changes. Consider using data attributes for more stable selections. Also, using English for both code and text content would improve consistency and maintainability.
Here's a suggested improvement:
const normal = page.getByTestId('default-tag');
const medium = page.getByTestId('medium-tag');
const small = page.getByTestId('small-tag');
const mini = page.getByTestId('mini-tag');
Ensure to add corresponding data-testid
attributes to your tag elements in the component.
&.is-disabled.is-disabled.is-disabled.is-disabled { | ||
color: var(--tv-Tag-text-color-disabled); | ||
background-color: var(--tv-Tag-bg-color-disabled); | ||
cursor: not-allowed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify redundant class selectors in disabled state
The class selector &.is-disabled.is-disabled.is-disabled.is-disabled
repeats the is-disabled
class multiple times unnecessarily. This can be simplified to a single &.is-disabled
for clarity.
Suggested change:
-&.is-disabled.is-disabled.is-disabled.is-disabled {
+&.is-disabled {
color: var(--tv-Tag-text-color-disabled);
background-color: var(--tv-Tag-bg-color-disabled);
cursor: not-allowed;
}
📝 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.
&.is-disabled.is-disabled.is-disabled.is-disabled { | |
color: var(--tv-Tag-text-color-disabled); | |
background-color: var(--tv-Tag-bg-color-disabled); | |
cursor: not-allowed; | |
&.is-disabled { | |
color: var(--tv-Tag-text-color-disabled); | |
background-color: var(--tv-Tag-bg-color-disabled); | |
cursor: not-allowed; |
font-size: 12px; // smb新增 | ||
border-radius: var(--ti-tag-small-border-radius); // smb新增 | ||
// smb新增 | ||
&.is-disabled.is-disabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate class in selector
In the selector &.is-disabled.is-disabled
, the is-disabled
class is duplicated. It should be sufficient to include it once.
Suggested change:
-&.is-disabled.is-disabled {
+&.is-disabled {
.@{tag-prefix-cls}__close {
fill: var(--tv-Tag-close-icon-color-disabled);
}
}
📝 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.
&.is-disabled.is-disabled { | |
&.is-disabled { |
var(--ti-tag-red-bg-color), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extraneous commas in mixin calls to prevent syntax errors.
In the custom color variants (&--red
, &--orange
, &--green
, &--blue
, &--purple
, &--brown
, &--grey
), there's a trailing comma after the last argument in the .tag-variant
mixin calls. In LESS, trailing commas after the last argument are invalid and can cause compilation errors. Please remove these trailing commas.
Apply the following diffs to fix the issue:
Lines 165-166 (&--red
):
- var(--ti-tag-red-bg-color),
+ var(--ti-tag-red-bg-color)
Lines 173-174 (&--orange
):
- var(--ti-tag-orange-bg-color),
+ var(--ti-tag-orange-bg-color)
Lines 181-182 (&--green
):
- var(--ti-tag-green-bg-color),
+ var(--ti-tag-green-bg-color)
Lines 189-190 (&--blue
):
- var(--ti-tag-blue-bg-color),
+ var(--ti-tag-blue-bg-color)
Lines 197-198 (&--purple
):
- var(--ti-tag-purple-bg-color),
+ var(--ti-tag-purple-bg-color)
Lines 205-206 (&--brown
):
- var(--ti-tag-brown-bg-color),
+ var(--ti-tag-brown-bg-color)
Lines 213-214 (&--grey
):
- var(--ti-tag-grey-bg-color),
+ var(--ti-tag-grey-bg-color)
Also applies to: 173-174, 181-182, 189-190, 197-198, 205-206, 213-214
line-height: var(--ti-tag-height); | ||
padding: 0 8px; | ||
font-size: var(--ti-tag-font-size); | ||
border-width: var(--ti-tag-border-weight); // smb新增 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translate non-English comments to maintain codebase consistency.
Several comments are written in Chinese (e.g., // smb新增
, // smb修正
). To ensure consistency and readability across the codebase, please translate these comments into English.
For example:
Line 27:
- border-width: var(--ti-tag-border-weight); // smb新增
+ border-width: var(--ti-tag-border-weight); // smb added
Lines 43-45:
- margin-left: var(--ti-tag-close-margin-left); // smb新增
- margin-right: var(--ti-tag-close-margin-right); // smb新增
- opacity: var(--ti-tag-primary-close-opacity); // smb新增
+ margin-left: var(--ti-tag-close-margin-left); // smb added
+ margin-right: var(--ti-tag-close-margin-right); // smb added
+ opacity: var(--ti-tag-primary-close-opacity); // smb added
Line 50:
- // smb新增
+ // smb added
Please update the remaining comments accordingly.
Also applies to: 43-45, 50-50, 219-221, 223-223, 232-235, 245-247, 255-255
&.is-disabled:focus, | ||
&.is-disabled:hover { | ||
cursor: not-allowed; | ||
color: #c2c2c2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace hardcoded color values with CSS variables for consistency.
In lines 260 and 266, the color #c2c2c2
is hardcoded. To maintain consistency and facilitate theming, please use existing CSS variables instead of hardcoded values.
Apply the following changes:
Line 260:
- color: #c2c2c2;
+ color: var(--ti-tag-disabled-text-color);
Line 266:
- fill: #c2c2c2;
+ fill: var(--ti-tag-disabled-icon-color);
Ensure that these variables (--ti-tag-disabled-text-color
, --ti-tag-disabled-icon-color
) are defined in your vars.less
file.
Also applies to: 266-266
--tv-Tag-text-color-plain: var(--tv-color-text); | ||
// 默认标签plain的背景色 | ||
--tv-Tag-bg-color-plain: var(--tv-color-bg-secondary); | ||
// 默认标签plain的边框色 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Border color for 'plain' theme might need verification
The variable --tv-Tag-border-color-plain
is set to var(--tv-color-border-hover)
, and the comment indicates "没有正确的边框色" ("no correct border color"). This suggests that the correct border color is not available or needs to be defined. Please verify and update the border color as needed.
Would you like assistance in identifying the correct border color?
There was a problem hiding this 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 (4)
examples/sites/demos/pc/app/tag/basic-usage-composition-api.vue (3)
2-4
: LGTM! Consider adding aria-labels for accessibility.The template effectively demonstrates various configurations of the TinyTag component, providing a clear and concise example of its usage. The structure is clean and easy to understand.
Consider adding
aria-label
attributes to the icon-only tag for better accessibility:- <tiny-tag type="success" only-icon><tiny-icon-heartempty /> </tiny-tag> + <tiny-tag type="success" only-icon aria-label="Success"><tiny-icon-heartempty /> </tiny-tag>
7-11
: LGTM! Consider using the defined icon constant in the template.The script section correctly sets up the component using the Composition API. The imports are appropriate for the component's needs.
For consistency, consider using the
tinyIconHeartempty
constant in the template instead of<tiny-icon-heartempty />
:- <tiny-tag type="success" only-icon><tiny-icon-heartempty /> </tiny-tag> - <tiny-tag type="success"><tiny-icon-heartempty /> 默认标签 </tiny-tag> + <tiny-tag type="success" only-icon>{{ tinyIconHeartempty }} </tiny-tag> + <tiny-tag type="success">{{ tinyIconHeartempty }} 默认标签 </tiny-tag>This change would ensure that the icon rendering is consistent with how it's defined in the script.
14-17
: LGTM! Consider using CSS custom properties for improved flexibility.The style section appropriately uses scoped styling to apply component-specific styles. The margin adjustment helps in spacing the tags correctly.
For improved flexibility and easier theme customization, consider using CSS custom properties:
<style scoped> .tiny-tag { - margin-right: 16px; + margin-right: var(--tiny-tag-margin-right, 16px); } </style>This change allows for easier overrides and theme adjustments without modifying the component's internal styles.
packages/theme/src/tag/index.less (1)
97-115
: Great addition, minor naming suggestionThe
.color-colors-mixin(@color)
is an excellent addition that further improves the flexibility of color handling. It allows for easy addition of new color variants, which is great for maintainability and extensibility.However, the naming of the mixin might be slightly confusing. Consider renaming it to something like
.specific-color-mixin(@color)
or.color-variant-mixin(@color)
to more clearly distinguish its purpose from the.color-type-effect-mixin(@type)
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (7)
- examples/sites/demos/apis/tag.js (3 hunks)
- examples/sites/demos/pc/app/tag/basic-usage-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tag/basic-usage.vue (1 hunks)
- packages/theme/src/tag/index.less (1 hunks)
- packages/theme/src/tag/vars.less (1 hunks)
- packages/vue/src/tag/src/index.ts (1 hunks)
- packages/vue/src/tag/src/pc.vue (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- examples/sites/demos/apis/tag.js
- packages/vue/src/tag/src/pc.vue
🧰 Additional context used
🔇 Additional comments (11)
examples/sites/demos/pc/app/tag/basic-usage.vue (3)
2-4
: Excellent refactoring of the tag usage examples!The new template provides a clear and concise demonstration of different tag usages:
- An icon-only tag
- A tag with both icon and text
- A tag with text content set via the
value
attributeThis variety effectively showcases the component's flexibility and aligns well with the PR's objective of refactoring the tag's demos.
19-22
: Style improvements enhance the component's appearance and flexibility.The style changes are beneficial:
- Scoped styling prevents unintended style leaks.
- Increased right margin (16px) improves spacing between tags.
- Removal of bottom margin allows for more flexible layout control at the parent level.
These changes contribute to a cleaner and more maintainable styling approach.
1-22
: Overall, excellent refactoring that aligns with PR objectives.This refactored
basic-usage.vue
file successfully achieves the PR's goal of improving the tag's demos. The changes provide a more focused and diverse set of examples, demonstrating various tag types and content options. The script and style modifications contribute to better maintainability and flexibility.These improvements will help users better understand and implement the tag component in their projects.
packages/vue/src/tag/src/index.ts (1)
30-30
: Approved addition with suggestions for improvementThe addition of the
onlyIcon
property is a good enhancement to the tag component. However, consider the following suggestions:
Add an English translation to the comment for better accessibility. For example:
onlyIcon: Boolean, // 仅图标模式 (only icon mode)Consider adding a default value for consistency with other properties:
onlyIcon: { type: Boolean, default: false },To ensure this new mode is properly implemented, please verify the following:
packages/theme/src/tag/index.less (7)
14-17
: LGTM: Improved modularity and variable usageThe simplification of imports and introduction of
@tag-prefix-cls
variable improve the modularity and maintainability of the styles. This change aligns with best practices for LESS.
19-49
: Improved flexibility with size mixin, clarification neededThe introduction of
.size-mixin(@size)
greatly improves the flexibility of the component by allowing easy size customization. This is a good practice for maintaining consistent sizing across different variants of the tag.However, could you please clarify the use of the
e()
function in the LESS code? While it's commonly used for escaping, it would be helpful to understand the specific reason for its usage here, especially for other developers who might work on this code in the future.
52-94
: Excellent: Improved color scheme handlingThe introduction of
.color-type-effect-mixin(@type)
is a significant improvement in managing color schemes for different tag types. This approach:
- Enhances maintainability by centralizing color logic.
- Facilitates easy addition of new color types.
- Ensures consistency across different tag variants.
The application of this mixin to various tag types (success, danger, warning, info) demonstrates its effectiveness and reusability.
141-156
: LGTM: Improved icon handlingThe additional styles for icons within the default slot and the specific style for tags with only an icon are well-implemented. These changes:
- Improve the flexibility of the component by accommodating various icon usage scenarios.
- Maintain consistency with the rest of the component by using CSS variables.
- Provide a clean solution for the only-icon scenario with appropriate padding and font-size adjustments.
Good job on considering these different use cases and implementing them cleanly.
Line range hint
1-156
: Overall: Significant improvements with minor suggestionsThis refactoring of the tag component's styles brings substantial improvements:
- Enhanced modularity through well-structured mixins for sizes and colors.
- Improved flexibility, allowing easy customization and extension.
- Consistent use of CSS variables, promoting a unified design system.
The main suggestions for improvement are:
- Simplifying repeated class selectors in disabled states.
- Considering a more descriptive name for the
.color-colors-mixin
.These changes significantly enhance the maintainability and scalability of the component. Great work overall!
118-121
:⚠️ Potential issueSimplify disabled state selector
As mentioned in a previous review, the class selector
&.is-disabled.is-disabled.is-disabled.is-disabled
repeats theis-disabled
class unnecessarily. This can be simplified to improve readability and maintain the same specificity.Please apply the following change:
-&.is-disabled.is-disabled.is-disabled.is-disabled { +&.is-disabled { color: var(--tv-Tag-text-color-disabled); background-color: var(--tv-Tag-bg-color-disabled); cursor: not-allowed; }
124-137
:⚠️ Potential issueApprove close icon styles, simplify disabled state selector
The new styles for the close icon are well-implemented and improve the component's functionality. Good job on using CSS variables for easy customization.
However, as mentioned in a previous review, the disabled state selector for the close icon still contains a duplicate class. Please apply the following change:
-&.is-disabled.is-disabled { +&.is-disabled { .@{tag-prefix-cls}__close { fill: var(--tv-Tag-close-icon-color-disabled); } }This simplification will maintain the same specificity while improving readability.
<script> | ||
import { Tag } from '@opentiny/vue' | ||
import { IconHeartempty } from '@opentiny/vue-icon' | ||
|
||
export default { | ||
components: { | ||
TinyTag: Tag | ||
TinyTag: Tag, | ||
TinyIconHeartempty: IconHeartempty() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script changes look good, but there's a small issue in component registration.
The script changes are mostly appropriate:
- Removal of the
jsx
language attribute - Import of the
IconHeartempty
component
However, there's a potential issue in the component registration:
TinyIconHeartempty: IconHeartempty()
This syntax suggests calling the IconHeartempty
as a function, which is likely incorrect.
Consider changing it to:
TinyIconHeartempty: IconHeartempty
This registers the component directly without calling it as a function.
--tv-Tag-bg-color-plain-success: var(--tv-color-success-text-white); | ||
// success 主题时标签plain的边框色 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use appropriate background color variable for 'plain' success tag
The background color variable --tv-Tag-bg-color-plain-success
is set to var(--tv-color-success-text-white)
, which is a text color variable. Background colors should use background color variables to ensure correct styling.
Consider updating the background color variable to use the appropriate background color variable. For example:
--tv-Tag-bg-color-plain-success: var(--tv-color-success-text-white);
+--tv-Tag-bg-color-plain-success: var(--tv-color-success-bg-white);
📝 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.
--tv-Tag-bg-color-plain-success: var(--tv-color-success-text-white); | |
// success 主题时标签plain的边框色 | |
--tv-Tag-bg-color-plain-success: var(--tv-color-success-bg-white); | |
// success 主题时标签plain的边框色 |
--tv-Tag-bg-color-plain-warning: var(--tv-color-warn-text-white); | ||
// warning 主题时标签plain的边框色 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use appropriate background color variable for 'plain' warning tag
The background color variable --tv-Tag-bg-color-plain-warning
is set to var(--tv-color-warn-text-white)
, which is a text color variable. Background colors should use background color variables to ensure proper styling.
Consider updating it to use the correct background color variable. For example:
--tv-Tag-bg-color-plain-warning: var(--tv-color-warn-text-white);
+--tv-Tag-bg-color-plain-warning: var(--tv-color-warn-bg-white);
📝 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.
--tv-Tag-bg-color-plain-warning: var(--tv-color-warn-text-white); | |
// warning 主题时标签plain的边框色 | |
--tv-Tag-bg-color-plain-warning: var(--tv-color-warn-bg-white); | |
// warning 主题时标签plain的边框色 |
--tv-Tag-text-color-brown: #a64d00; | ||
// 棕色时标签背景色 | ||
--tv-Tag-bg-color-brown: #ffebd1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate background color for 'orange' and 'brown' tags
The background color for the 'brown' tag (--tv-Tag-bg-color-brown
) is set to #ffebd1
, which is the same as the 'orange' tag's background color (--tv-Tag-bg-color-orange
). This may lead to visual confusion or incorrect theming.
Consider updating --tv-Tag-bg-color-brown
to a distinct color that represents the 'brown' theme more accurately. For example:
--tv-Tag-bg-color-brown: #ffebd1;
+--tv-Tag-bg-color-brown: #e8d8c3; // Suggested brown background color
Committable suggestion was skipped due to low confidence.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
重构tag主题
移除了动态添加TAG的示例
调整了基本示例和配置示例的位置。
增加了only-icon属性
Summary by CodeRabbit
New Features
only-icon
property for tag components, allowing a pure icon mode.Bug Fixes
Style
Chores