-
Notifications
You must be signed in to change notification settings - Fork 278
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
fix(icon): [icon] added the content of the show-title example #2390
Conversation
WalkthroughThe changes in this pull request involve modifications to the icon demo component's structure, styling, and testing. The Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 (
|
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: 1
🧹 Outside diff range and nitpick comments (4)
examples/sites/demos/pc/app/icon/show-title.spec.ts (1)
Line range hint
1-9
: Consider expanding test coverage.According to the changes made in the Vue components, a second icon with title "不可见提示" was added. Consider adding an additional assertion to verify this new element as well.
test('显示title', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('icon#show-title') await expect(page.getByTitle('可见提示')).toHaveCount(1) + await expect(page.getByTitle('不可见提示')).toHaveCount(1) })
examples/sites/demos/pc/app/icon/show-title-composition-api.vue (1)
18-22
: Consider accessibility improvements for icon sizing.While the layout changes look good, consider adding these accessibility improvements:
- The fixed font-size of 24px might not scale well with user's font size preferences
- The fixed margin might cause layout issues on smaller screens
Consider these improvements:
.icon-demo { display: flex; + flex-wrap: wrap; + gap: 1rem; } .icon-demo .tiny-svg { - margin: 20px 40px; - font-size: 24px; + margin: 1.25rem 2.5rem; + font-size: 1.5rem; }packages/theme/build/release.js (1)
24-24
: LGTM! Consider standardizing comment format.The added comment clearly explains the purpose of writing to dist/old-theme-index.js. For consistency with other comments in the file, consider using Chinese like the numbered section comments above.
-fs.writeFileSync(path.resolve(root, 'dist/old-theme-index.js'), jsStr) // 打包发布用 +fs.writeFileSync(path.resolve(root, 'dist/old-theme-index.js'), jsStr) // 用于打包发布packages/theme/src/button/vars.less (1)
81-81
: Well-structured variable additions for icon support.The new variables are well-organized and follow the established patterns. They provide comprehensive support for various icon-button scenarios while maintaining consistency with the design system.
Consider the following suggestions for long-term maintainability:
- Document these variables in the component's API documentation to ensure proper usage.
- Consider adding a visual regression test suite to catch any unintended changes to these styles.
- Consider creating a style guide page showcasing all possible icon-button combinations to help developers understand the available options.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (6)
- examples/sites/demos/pc/app/icon/show-title-composition-api.vue (2 hunks)
- examples/sites/demos/pc/app/icon/show-title.spec.ts (1 hunks)
- examples/sites/demos/pc/app/icon/show-title.vue (2 hunks)
- examples/sites/demos/pc/app/icon/webdoc/icon.js (1 hunks)
- packages/theme/build/release.js (1 hunks)
- packages/theme/src/button/vars.less (2 hunks)
✅ Files skipped from review due to trivial changes (1)
- examples/sites/demos/pc/app/icon/webdoc/icon.js
🔇 Additional comments (7)
examples/sites/demos/pc/app/icon/show-title.spec.ts (1)
7-7
: LGTM! Test correctly updated to match component changes.The test assertion has been properly updated to verify the new title "可见提示", maintaining alignment with the changes made in the related Vue components.
examples/sites/demos/pc/app/icon/show-title-composition-api.vue (2)
Line range hint
10-15
: LGTM! Clean implementation using Vue 3 Composition API.The script setup implementation is concise and follows best practices.
2-7
:⚠️ Potential issueStandardize title implementation and improve demo clarity.
The demo shows two different ways to add titles to icons, which might confuse users about the recommended approach:
- Wrapper div with title (lines 3-5)
- Direct title on the component (line 7)
Consider:
- Using a consistent approach for both examples
- Adding comments or documentation to explain the difference between these approaches
- Clarifying the purpose of "可见提示" (visible hint) vs "不可见提示" (invisible hint)
Let's check if there's documentation about the recommended approach:
✅ Verification successful
Let me search for more specific documentation about icon titles in the component's documentation:
Let me check the content of both title-related icon demos to understand the intended pattern:
The implementation is consistent with the demo's purpose
The demo intentionally shows two different approaches for adding titles to icons:
- Using a wrapper div with title (shows tooltip on the container)
- Using title directly on the icon component (shows tooltip on the icon)
The Chinese text "可见提示" (visible hint) and "不可见提示" (invisible hint) are descriptive labels that help users understand the difference between these two approaches in the demo.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for icon title documentation rg -g '*.md' -g '*.vue' -i 'title.*icon|icon.*title'Length of output: 9276
Script:
#!/bin/bash # Search for icon title documentation in the Icon component's documentation cat examples/sites/demos/pc/app/icon/webdoc/icon.cn.md examples/sites/demos/pc/app/icon/webdoc/icon.en.md # Look for other title-related examples in icon demos fd -e vue -p 'icon.*title|title.*icon' examples/sites/demos/pc/app/icon/Length of output: 410
Script:
#!/bin/bash # Check both title-related demos cat examples/sites/demos/pc/app/icon/show-title.vue examples/sites/demos/pc/app/icon/show-title-composition-api.vueLength of output: 982
examples/sites/demos/pc/app/icon/show-title.vue (2)
22-26
: Verify icon spacing consistency.The CSS changes look good for local styling, but please verify that:
- The 40px margin aligns with the design system's spacing guidelines
- The flex layout provides proper alignment for all icon sizes
Let's check for consistent margin usage across icon components:
#!/bin/bash # Search for margin definitions in icon-related components rg -g '*.vue' -g '*.less' "margin:.*40px" --multiline
16-16
:⚠️ Potential issueFix component registration inconsistencies.
The component registration has two issues:
- The import uses
IconCopy
but it's registered asTinyIconCopy
- Unusual component initialization using function call syntax
IconCopy()
Apply this fix to maintain consistency:
- TinyIconCopy: IconCopy() + IconCopyLet's verify if this is a pattern used across the codebase:
packages/theme/src/button/vars.less (2)
29-29
: LGTM! Clear section header update.The comment header update appropriately reflects the addition of icon-size related variables.
81-81
: Verify referenced design token definitions.Let's ensure all referenced design tokens (e.g.,
--tv-color-bg
,--tv-border-radius-md
) are properly defined in the system.✅ Verification successful
Based on the search results, I can now provide a definitive response about the design token references in the button component.
All design tokens are properly defined and consistent
The button component's variables in
vars.less
reference standard design tokens that are all properly defined in the base theme. The referenced tokens include:
- Color tokens (e.g.
--tv-color-text
,--tv-color-bg-secondary
)- Font tokens (e.g.
--tv-font-size-md
,--tv-font-weight-regular
)- Size tokens (e.g.
--tv-size-height-md
,--tv-border-width
)- Spacing tokens (e.g.
--tv-space-sm
,--tv-space-md
)- Border radius tokens (e.g.
--tv-border-radius-round
)All these tokens have corresponding definitions in the base theme with appropriate values and documentation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if all referenced design tokens are defined # Search for token definitions echo "Searching for design token definitions..." rg --type=less "(:root|\.theme-default|\.inject-.*vars)" -A 5 -B 5 # List all referenced tokens echo "Referenced tokens in button variables:" rg --type=less "var\(--tv-(?!Button)" packages/theme/src/button/vars.lessLength of output: 184196
Script:
#!/bin/bash # Search for design token references in button/vars.less echo "Searching for design token references in button/vars.less:" rg --type=less "var\(--tv-" packages/theme/src/button/vars.less # Search for base token definitions echo -e "\nSearching for base token definitions:" rg --type=less "^[[:space:]]*--tv-(color|font|size|border|line|space)" packages/theme/src/base/vars.lessLength of output: 28556
<div class="icon-demo"> | ||
<div title="可见提示"> | ||
<tiny-icon-copy></tiny-icon-copy> | ||
</div> | ||
|
||
<tiny-icon-copy title="不可见提示"></tiny-icon-copy> |
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.
Improve consistency and accessibility of icon implementations.
There are several concerns with the current implementation:
- Inconsistent title implementation: one uses a wrapper div with title, another uses direct title attribute
- Missing ARIA labels for better accessibility
- Component naming inconsistency between import (IconCopy) and usage (tiny-icon-copy)
Consider applying these improvements:
<div class="icon-demo">
- <div title="可见提示">
- <tiny-icon-copy></tiny-icon-copy>
- </div>
-
- <tiny-icon-copy title="不可见提示"></tiny-icon-copy>
+ <tiny-icon-copy
+ title="可见提示"
+ aria-label="可见提示"
+ ></tiny-icon-copy>
+
+ <tiny-icon-copy
+ title="不可见提示"
+ aria-label="不可见提示"
+ ></tiny-icon-copy>
</div>
📝 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.
<div class="icon-demo"> | |
<div title="可见提示"> | |
<tiny-icon-copy></tiny-icon-copy> | |
</div> | |
<tiny-icon-copy title="不可见提示"></tiny-icon-copy> | |
<div class="icon-demo"> | |
<tiny-icon-copy | |
title="可见提示" | |
aria-label="可见提示" | |
></tiny-icon-copy> | |
<tiny-icon-copy | |
title="不可见提示" | |
aria-label="不可见提示" | |
></tiny-icon-copy> | |
</div> |
…everal comments
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
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Style