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

fix(tree): [button,tree] update tree demos and the plain button's border color #2470

Merged
merged 2 commits into from
Nov 2, 2024

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Oct 30, 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

更新了demo, button 的theme, tree的pc模板

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a radio button group for selecting tree node indentation levels (18px, 28px, 38px).
    • Enhanced localization with Chinese labels for radio components.
  • Visual Enhancements

    • Adjusted styling of tree node labels for improved presentation.
    • Updated button styles for better visual differentiation in various states.
  • Bug Fixes

    • Removed unnecessary properties from tree components to simplify configurations.

These updates enhance user experience by providing more customization options and improving the visual consistency of the application.

Copy link

coderabbitai bot commented Oct 30, 2024

Walkthrough

The 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 <tiny-tree> component's props. The CSS variables for button themes have been updated to lighter colors, and several components have undergone minor formatting changes. Overall, these updates enhance user interaction and visual presentation across multiple tree-related components.

Changes

File Path Change Summary
examples/sites/demos/pc/app/tree/basic-usage-composition-api.vue Added radio buttons for indentation selection; updated show-line prop for tiny-tree; initialized indent variable.
examples/sites/demos/pc/app/tree/basic-usage.vue Updated tiny-radio labels to Chinese; modified show-line prop for tiny-tree.
examples/sites/demos/pc/app/tree/edit-composition-api.vue Reformatted <tiny-tree> component tags without changing functionality.
examples/sites/demos/pc/app/tree/edit.vue Removed show-checkbox attribute from <tiny-tree> component.
examples/sites/demos/pc/app/tree/other-composition-api.vue Removed accordion prop from second <tiny-tree> instance; added custom slot content.
examples/sites/demos/pc/app/tree/other.vue Removed accordion prop from second <tiny-tree> instance; added custom slot content.
examples/sites/demos/pc/app/tree/slot-composition-api.vue Changed node label styling; modified tiny-link component; updated icon fill color in renderContent.
examples/sites/demos/pc/app/tree/slot.vue Changed node label styling; modified tiny-link component; updated icon fill color in renderContent.
packages/theme/src/button/vars.less Updated button theme CSS variables to lighter colors for various states.
packages/vue/src/tree/src/pc.vue Added size="mini" attribute to <tiny-button> components.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • zzcr

Poem

In the forest where trees grow tall,
A radio button now stands for all.
With colors bright and labels clear,
Adjust your view, bring the nodes near.
A hop and a skip, let’s style with glee,
For every tree, there’s a place to be! 🌳🐇


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.

@shenjunjian shenjunjian changed the title fix(tree): update tree demos and the plain button's border color fix(tree): [button,tree] update tree demos and the plain button's border color Oct 30, 2024
@github-actions github-actions bot added the bug Something isn't working label Oct 30, 2024
Copy link

[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

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: 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> &nbsp;
+<tiny-link :underline="true" title="一些功能操作" type="primary"> 新增 </tiny-link> &nbsp;
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:

  1. Improves visual feedback for user interactions
  2. Maintains consistency across all theme variants
  3. Better aligns with modern UI design patterns where default states are more subtle
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 299d7fe and 879bca7.

📒 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants