-
Notifications
You must be signed in to change notification settings - Fork 276
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(tree): [button,tree] update tree demos and the plain button's border color #2470
Conversation
WalkthroughThe changes in this pull request involve various updates to Vue components related to tree structures and styling. Key modifications include the addition of a radio button group for selecting tree node indentation, localization enhancements in labels, and adjustments to the Changes
Possibly related PRs
Suggested labels
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: 0
🧹 Outside diff range and nitpick comments (9)
examples/sites/demos/pc/app/tree/other-composition-api.vue (1)
Line range hint 8-12
: LGTM! Consider enhancing the demo's educational value.
The changes correctly implement a non-accordion tree with custom switch content, providing a good contrast to the accordion tree above it. The implementation is clean and follows Vue's best practices.
Consider adding comments in the tips to highlight the custom switch content feature, as it's a key demonstration point but not mentioned in the current tip text:
-<div class="tips">提示:非手风琴模式,自定义自动勾选的内容</div>
+<div class="tips">提示:非手风琴模式,自定义自动勾选的内容,并展示了如何自定义开关内容</div>
examples/sites/demos/pc/app/tree/other.vue (1)
Line range hint 8-12
: LGTM! Consider internationalizing the text content.
The changes effectively demonstrate the non-accordion mode with custom switch content. The removal of the accordion
prop provides a clear contrast with the first tree instance, making the demo more educational.
Consider internationalizing the hardcoded Chinese text in both the tips and custom switch content for better global accessibility. Example:
-<span>自定义开关的内容</span>
+<span>{{ t('tree.customSwitchContent') }}</span>
examples/sites/demos/pc/app/tree/edit.vue (3)
Line range hint 3-7
: Consider internationalizing button labels
The button labels are currently hardcoded in Chinese. Consider using a localization system to support multiple languages.
- <tiny-button @click="openEdit">进入编辑</tiny-button>
- <tiny-button @click="closeEdit">取消编辑</tiny-button>
- <tiny-button @click="saveEdit">保存编辑</tiny-button>
+ <tiny-button @click="openEdit">{{ t('tree.edit.enter') }}</tiny-button>
+ <tiny-button @click="closeEdit">{{ t('tree.edit.cancel') }}</tiny-button>
+ <tiny-button @click="saveEdit">{{ t('tree.edit.save') }}</tiny-button>
Line range hint 65-68
: Consider making the save timeout configurable
The 5-second timeout for saving nodes is hardcoded. Consider making this configurable through props or component settings.
+ props: {
+ saveTimeout: {
+ type: Number,
+ default: 5000
+ }
+ },
methods: {
saveNode() {
- setTimeout(() => this.$refs.treeRef.saveNode(), 5000)
+ setTimeout(() => this.$refs.treeRef.saveNode(), this.saveTimeout)
}
Add error handling for tree editing operations
Based on the code analysis, there is no error handling or validation implemented for the tree editing operations. The component should handle potential issues such as:
- Invalid node data during save
- Failed add/edit operations
- Node validation before saving
Recommended changes:
- Add try-catch blocks around edit operations
- Implement validation before saving changes
- Add error events to notify parent components of failures
🔗 Analysis chain
Line range hint 40-68
: Verify error handling for tree operations
The tree editing operations (add, edit, save) don't appear to have error handling. Let's verify if there's error handling in the parent components or if we need to add it here.
Let me try a different search strategy to check for error handling and validation in the tree component.
Let me try one final search to check for any validation or error handling in the tree component's edit-related functionality.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for error handling patterns in tree-related components
echo "Checking for error handling in tree components..."
rg -l "try.*catch" --type vue $(fd -e vue -p "tree")
# Check if there are any error events emitted from TinyTree
echo "Checking for error events in TinyTree component..."
ast-grep --pattern 'emit($_, "error")'
Length of output: 11151
Script:
#!/bin/bash
# Check the tree component implementation for validation and error handling
echo "Checking tree component implementation..."
rg -A 5 "openEdit|closeEdit|saveEdit|addNode|editNode" packages/vue/src/tree/src/pc.vue
# Check if there are any validation or error checks in the tree node operations
echo "Checking tree node operations..."
rg -A 5 "function (open|close|save|add|edit).*Node" packages/vue/src/tree/src/tree-node.vue
# Look for any error or validation related props/events
echo "Checking for error related props and events..."
rg "(props:|emits:)" packages/vue/src/tree/src/pc.vue -A 10
Length of output: 926
Script:
#!/bin/bash
# Check the implementation of edit-related methods in the tree component
echo "Checking edit-related implementations..."
rg -B 2 -A 10 "function.*Edit" packages/vue/src/tree/src/pc.vue
# Look for any validation methods or error states
echo "Checking for validation methods..."
rg "validate|isValid|error" packages/vue/src/tree/src/pc.vue
# Check if there are any edit-related events
echo "Checking edit-related events..."
rg "emit.*edit" packages/vue/src/tree/src/pc.vue
Length of output: 458
examples/sites/demos/pc/app/tree/slot-composition-api.vue (2)
81-81
: Consider using CSS variables for icon color
Good change replacing the red fill with a more subtle gray color. However, consider using a CSS variable for the color to maintain consistency across the application.
Consider updating to:
- {node.label} <TinyIconPlusSquare fill="#666" />
+ {node.label} <TinyIconPlusSquare fill="var(--ti-text-secondary)" />
Line range hint 1-99
: Consider adding JSDoc comments for the component and its methods
The component is well-structured, but could benefit from documentation explaining:
- The purpose of each slot
- The expected shape of the tree data
- The functionality of loadData and clearData methods
Would you like me to provide an example of the documentation structure?
examples/sites/demos/pc/app/tree/slot.vue (1)
25-26
: Consider consistent link styling
The first tiny-link
has no type specified while the second one uses type="danger"
. Consider explicitly setting a type for the first link for consistency, especially since they're part of the same operation group.
-<tiny-link :underline="true" title="一些功能操作"> 新增 </tiny-link>
+<tiny-link :underline="true" title="一些功能操作" type="primary"> 新增 </tiny-link>
packages/theme/src/button/vars.less (1)
153-181
: Good improvement to button state hierarchy.
The change to lighter border colors for plain buttons' default state, while maintaining darker colors for active states, creates better visual distinction between button states. This architectural decision:
- Improves visual feedback for user interactions
- Maintains consistency across all theme variants
- Better aligns with modern UI design patterns where default states are more subtle
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (10)
- examples/sites/demos/pc/app/tree/basic-usage-composition-api.vue (0 hunks)
- examples/sites/demos/pc/app/tree/basic-usage.vue (0 hunks)
- examples/sites/demos/pc/app/tree/edit-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tree/edit.vue (1 hunks)
- examples/sites/demos/pc/app/tree/other-composition-api.vue (1 hunks)
- examples/sites/demos/pc/app/tree/other.vue (1 hunks)
- examples/sites/demos/pc/app/tree/slot-composition-api.vue (3 hunks)
- examples/sites/demos/pc/app/tree/slot.vue (3 hunks)
- packages/theme/src/button/vars.less (1 hunks)
- packages/vue/src/tree/src/pc.vue (1 hunks)
💤 Files with no reviewable changes (2)
- examples/sites/demos/pc/app/tree/basic-usage-composition-api.vue
- examples/sites/demos/pc/app/tree/basic-usage.vue
✅ Files skipped from review due to trivial changes (2)
- examples/sites/demos/pc/app/tree/edit-composition-api.vue
- packages/vue/src/tree/src/pc.vue
🔇 Additional comments (6)
examples/sites/demos/pc/app/tree/edit.vue (1)
11-11
: LGTM! Simplified tree configuration
The removal of the show-checkbox
attribute streamlines the component's configuration while maintaining core editing functionality.
examples/sites/demos/pc/app/tree/slot-composition-api.vue (2)
16-16
: Improved node label styling
Good change. Replacing the red color with proper margin spacing improves the visual hierarchy and consistency of the tree nodes.
25-27
: Verify the removal of primary link type
The removal of type="primary"
from the "新增" (Add) link might reduce its visual prominence. Consider if this was intentional, as Add is typically a primary action.
Let's check if this is consistent with other tree demos:
examples/sites/demos/pc/app/tree/slot.vue (2)
16-16
: LGTM! Improved node label spacing
The margin adjustment provides better visual spacing between tree node elements compared to the previous red text styling.
90-91
: LGTM! Improved icon color contrast
The change from red to #666
provides a more subtle and professional appearance for the plus icon, which is more appropriate for a tree node indicator.
packages/theme/src/button/vars.less (1)
153-153
: LGTM! Consistent updates to plain button border colors.
The changes consistently update the border colors for plain button variants from active to light variants across all themes. This creates a more subtle and cohesive visual appearance for plain buttons.
Let's verify that all the new color variables exist:
Also applies to: 160-160, 167-167, 174-174, 181-181
✅ Verification successful
All color variables are properly defined and consistently used
The verification confirms that all the light border color variables (--tv-color-act-*-border-light
) are properly defined in the base theme files and correctly referenced across components. The variables are well-documented with color values and usage comments, showing a consistent pattern across all button variants (primary, success, warning, danger, and info).
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the new light border color variables are defined
# Expected: All variables should be found in the codebase
echo "Checking for light border color variables..."
rg --type less "tv-color-act-(primary|success|warning|danger|info)-border-light"
Length of output: 5697
…der color (#2470) * fix(tree): fix tree's demo, modify delete popover's button to mini * fix(button): fix the plain button's border color
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
更新了demo, button 的theme, tree的pc模板
Summary by CodeRabbit
Release Notes
New Features
Visual Enhancements
Bug Fixes
These updates enhance user experience by providing more customization options and improving the visual consistency of the application.