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): [tree] remove __content-box dom, compact with AUI code #2247

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

shenjunjian
Copy link
Collaborator

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

  • 移除 content-box 这一层dom, 保持与aui一致,避免未来再提更多的问题单
  • api中增加一个属性说明

Summary by CodeRabbit

  • New Features

    • Added a show-checked-mark property to display a checkmark next to selected nodes.
  • Improvements

    • Enhanced semantic clarity in the tree component's template structure.
    • Updated hover state styles for better visual consistency across tree nodes.
  • Bug Fixes

    • Minor adjustments to the highlight-query property description for improved clarity.
  • Chores

    • Removed unused CSS variables related to hover background colors, streamlining the styles.

Copy link

coderabbitai bot commented Oct 12, 2024

Walkthrough

The changes in this pull request focus on enhancing the tree component's API and styling. A new property, show-checked-mark, is added to the tree.js file, allowing checkmarks next to selected nodes. The LESS stylesheets for tree and link menus are updated, including a class name change for improved semantic clarity. The tree-node.vue component sees structural modifications for better handling of child nodes. Additionally, certain CSS variables related to hover effects are removed to streamline the styling without affecting functionality.

Changes

File Path Change Summary
examples/sites/demos/apis/tree.js Added new property show-checked-mark in props; updated description of highlight-query.
packages/theme-saas/src/tree-menu/index.less, packages/theme/src/link-menu/index.less Renamed class from __content-box to __label and updated hover state styling.
packages/theme-saas/src/tree/index.less, packages/theme/src/tree/index.less Updated selector for highlighted tree nodes from __content-box to __label; modified hover state styles.
packages/vue/src/tree/src/tree-node.vue Improved template structure; added handling for child nodes with collapse-transition; emitted radio-change event.
packages/theme/src/tree/vars.less Removed CSS variables --ti-tree-node-hover-outter-bg-color and --ti-tree-node-hover-inner-bg-color.

Possibly related PRs

Suggested labels

bug, refactoring

Suggested reviewers

  • zzcr

Poem

🐇 In the trees where rabbits play,
New marks to show, bright as day.
With labels clear and styles refined,
Our leafy paths are now aligned.
Hop along, the changes cheer,
A better tree for all to steer! 🌳✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the bug Something isn't working label Oct 12, 2024
@shenjunjian shenjunjian added refactoring Refactoring and removed bug Something isn't working labels Oct 12, 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

@shenjunjian shenjunjian changed the title fix(tree): remove __content-box dom, compact with AUI code fix(tree): [tree] remove __content-box dom, compact with AUI code Oct 12, 2024
@github-actions github-actions bot added bug Something isn't working and removed refactoring Refactoring labels Oct 12, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
packages/theme/src/link-menu/index.less (1)

Old class name tiny-tree-node__content-box still in use.

The class name was changed from .tiny-tree-node__content-box to .tiny-tree-node__label, but instances of the old class remain in the following file:

  • examples/sites/src/views/layout/layout.vue

Please update these references to ensure consistency and prevent potential styling issues.

🔗 Analysis chain

Line range hint 149-159: Approve class name change, but verify usage across codebase.

The change from .tiny-tree-node__content-box to .tiny-tree-node__label improves semantic clarity. However, ensure that this class name change is consistently applied across the entire codebase to prevent any styling issues.

Run the following script to check for any remaining usage of the old class name:


Let's update the verification script to search for the old class name in .less, .vue, and .js files explicitly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of the old class name

# Test: Search for the old class name. Expect: No results.
rg --type less --type vue --type js 'tiny-tree-node__content-box'

Length of output: 93


Script:

#!/bin/bash
# Description: Check for any remaining usage of the old class name in .less, .vue, and .js files

# Search for the old class name in specified file types. Expect: No results.
rg 'tiny-tree-node__content-box' --glob '*.less' --glob '*.vue' --glob '*.js'

Length of output: 153

packages/vue/src/tree/src/tree-node.vue (3)

Line range hint 168-220: Enhanced child node handling

The addition of the template for rendering child nodes significantly improves the component's ability to handle nested structures. The use of collapse-transition provides smooth animations, and the conditional rendering based on renderAfterExpand and state.expanded can enhance performance by only rendering child nodes when necessary.

Consider extracting the child node rendering logic into a separate component to improve maintainability and reduce the complexity of this component. This would also make it easier to test the child node rendering independently.


Line range hint 304-308: New prop for focus background visibility

The addition of the isShowFocusBg prop enhances the component's flexibility by allowing users to control the visibility of the focus background. This is a good improvement for accessibility and customization.

Consider adding a comment explaining the purpose of this prop in more detail, including when a user might want to set it to false. This would improve the self-documentation of the component and make it easier for other developers to understand and use this feature.


Line range hint 309-315: New icon components added

The addition of new icon components (IconFinish, IconEdit, IconDel, IconPlusSquare) enhances the visual functionality of the tree nodes, providing clear indicators for actions like editing, deleting, and adding nodes. This improves the user interface and interaction capabilities of the component.

Consider using a dynamic import for these icon components to potentially improve the initial load time of the component, especially if not all icons are used in every instance of the tree node. This could be implemented using Vue's defineAsyncComponent for lazy loading.

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

Line range hint 340-346: Improved hover effect consistency and code simplification

The changes to the .@{tree-node-prefix-cls}__content hover selector improve the consistency of the hover effect by targeting the content-left and content-right elements directly. This aligns with the removal of the content-box DOM element and simplifies the background color application.

However, there's a minor redundancy in the code:

.@{tree-node-prefix-cls}__content-right {
  background-color: var(--ti-tree-node-content-hover-bg-color);
}

This block is unnecessary as it's already covered by the previous selector.

Consider removing the redundant block to further simplify the code:

- .@{tree-node-prefix-cls}__content-right {
-   background-color: var(--ti-tree-node-content-hover-bg-color);
- }
examples/sites/demos/apis/tree.js (2)

506-517: LGTM: New show-checked-mark property adds useful functionality

The new show-checked-mark property is a valuable addition to the tree component. It allows for better visual feedback when nodes are selected in non-multiple selection mode.

Consider adding an example usage in the pcDemo field to help developers understand how to implement this feature. For example:

  mode: ['pc'],
- pcDemo: ''
+ pcDemo: 'show-checked-mark'

This assumes you have or will create a demo named 'show-checked-mark' to showcase this feature.


Line range hint 1-1180: Suggestion: Consider adding more comprehensive examples

While the changes made improve the API documentation, it might be beneficial to enhance the overall documentation with more comprehensive examples. This could include:

  1. Adding code snippets demonstrating the usage of various properties, especially newly added ones like show-checked-mark.
  2. Providing examples of common use cases or patterns for the tree component.
  3. Including cross-references between related properties or methods to help developers understand how different parts of the API work together.

These additions would make the documentation more user-friendly and help developers better understand and utilize the tree component's capabilities.

Would you like assistance in drafting some example code snippets or use cases to include in the documentation?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 98246dd and 90a0adf.

📒 Files selected for processing (9)
  • examples/sites/demos/apis/tree.js (1 hunks)
  • packages/theme-saas/src/tree-menu/index.less (1 hunks)
  • packages/theme-saas/src/tree/index.less (0 hunks)
  • packages/theme/src/link-menu/index.less (2 hunks)
  • packages/theme/src/toggle-menu/index.less (1 hunks)
  • packages/theme/src/tree-menu/index.less (1 hunks)
  • packages/theme/src/tree/index.less (3 hunks)
  • packages/theme/src/tree/vars.less (0 hunks)
  • packages/vue/src/tree/src/tree-node.vue (3 hunks)
💤 Files with no reviewable changes (2)
  • packages/theme-saas/src/tree/index.less
  • packages/theme/src/tree/vars.less
🧰 Additional context used
🔇 Additional comments (8)
packages/theme/src/tree-menu/index.less (1)

195-197: LGTM! Verify hover effect after class renaming.

The change from __content-box to __label aligns with the PR objective of removing the __content-box DOM element. This modification enhances consistency with AUI code as intended.

Please verify that the hover effect on tree nodes still works as expected after this class renaming. You can use the following steps:

  1. Build and run the component in a test environment.
  2. Navigate through the tree menu and hover over various nodes.
  3. Ensure that the visual feedback on hover is consistent and meets design requirements.

If you notice any unexpected behavior, please update the styling accordingly.

packages/theme-saas/src/tree-menu/index.less (1)

167-169: Approve: Improved class naming and layout.

The renaming of .@{tree-node-prefix-cls}__content-box to .@{tree-node-prefix-cls}__label enhances the semantic clarity of the code. The flex-1 property ensures the label fills available space, which is appropriate for tree node layouts.

packages/vue/src/tree/src/tree-node.vue (2)

48-48: Improved code documentation

The added comment provides a clear explanation of the structure for the current node's row. This enhances code readability and helps other developers understand the layout quickly.


132-134: Improved template structure

The replacement of the <div> element with a <template> element and the restructuring of the conditional rendering improve the code organization and reduce unnecessary DOM elements. This change enhances both the performance and readability of the component.

packages/theme/src/tree/index.less (3)

Line range hint 94-98: Improved highlighting specificity for current tree node

The changes to the .@{tree-prefix-cls}--highlight-current selector improve the specificity of the highlighting behavior. By targeting the .@{tree-node-prefix-cls}__label and .@{tree-node-prefix-cls}__content-right elements directly, instead of the previously used content-box, this change aligns with the PR objective of removing the __content-box DOM. This approach provides better control over the highlighting and ensures consistency with the AUI code.


Line range hint 355-359: Improved handling of long labels in tree nodes

The addition of the .@{tree-node-prefix-cls}__label selector with overflow handling properties is a good improvement. This ensures that long labels in tree nodes don't break the layout and are truncated with an ellipsis when necessary, enhancing the overall appearance and usability of the tree component.


Line range hint 1-524: Summary of changes

The modifications to the tree component styles in this file successfully achieve the PR objective of removing the __content-box DOM and ensuring consistency with AUI code. The changes improve the specificity of node highlighting, enhance hover effect consistency, and add better handling for long labels. These updates contribute to a more maintainable and efficient styling structure for the tree component.

A minor optimization was suggested to remove a redundant style block, but overall, the changes are well-implemented and improve the component's styling.

examples/sites/demos/apis/tree.js (1)

500-501: LGTM: Improved formatting for highlight-query description

The removal of the line break in the Chinese description improves readability without changing the meaning. This is a good cleanup.

Comment on lines +134 to +135
:not(.show-checkbox) > .@{tree-node-prefix-cls}__content .@{tree-node-prefix-cls}__label,
.@{tree-node-prefix-cls}__content-right {
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Issue Found: Remaining __content-box usage detected.

An occurrence of __content-box remains in examples/sites/src/views/layout/layout.vue, indicating that the removal may be incomplete. Please address this to ensure consistent styling and complete removal across the codebase.

🔗 Analysis chain

LGTM! Verify visual consistency and check for side effects.

The changes align with the PR objective of removing the __content-box DOM element. The new selector targets more specific elements (__label and __content-right), which should lead to more precise styling.

Please verify the following:

  1. Ensure that the hover effects still work as expected for all tree node elements.
  2. Check if this change affects any other components or styles that might have depended on the old selector.
  3. Consider adding before/after screenshots to the PR description to demonstrate that the visual appearance remains consistent.

To help with verification, you can run the following command to check for any other occurrences of __content-box in the codebase:

This will help ensure that the removal is complete and consistent across the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining occurrences of __content-box
rg --type less --type vue --type js '__content-box'

Length of output: 79


Script:

#!/bin/bash
# Search for any remaining occurrences of __content-box in .less, .vue, and .js files
rg '__content-box' --glob '*.less' --glob '*.vue' --glob '*.js'

Length of output: 139

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