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

feat(tree-menu): [tree-menu] Add static data and unused topic variables for rectification #2803

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

wuyiping0628
Copy link
Collaborator

@wuyiping0628 wuyiping0628 commented Jan 14, 2025

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: #2706

colses #2706

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated descriptions for tree menu demos to clarify data setting methods.
    • Refined terminology for data sources in menu API documentation.
  • Style

    • Enhanced tree menu styling with new CSS variables.
    • Improved theming flexibility for tree menu component.
    • Added dynamic styling options for input elements and node content.
  • Bug Fixes

    • Simplified tree menu component templates.
    • Removed redundant static data scenarios.
  • Refactor

    • Updated test cases for tree menu functionality.
    • Streamlined data resource handling in tree menu components.
    • Introduced a new hierarchical data structure for the tree menu component.

@wuyiping0628 wuyiping0628 added bug Something isn't working documentation 对文档的改进或补充 labels Jan 14, 2025
Copy link

coderabbitai bot commented Jan 14, 2025

Walkthrough

The pull request introduces modifications to the tree menu component across multiple files, focusing on updating data handling, descriptions, and styling. Changes include updating the Chinese description for the menu API's data property, adding structured tree data to Vue components, modifying test cases, and enhancing the component's CSS variables for more flexible theming. The modifications aim to improve the clarity and flexibility of the tree menu implementation.

Changes

File Change Summary
examples/sites/demos/apis/menu.js Updated Chinese description for data property from '数据源' to '服务端数据'
examples/sites/demos/pc/app/tree-menu/basic-usage-composition-api.vue Added treeData reactive reference for tree menu
examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts Updated test description and added more detailed assertions
examples/sites/demos/pc/app/tree-menu/basic-usage.vue Added treeData to populate tree menu
examples/sites/demos/pc/app/tree-menu/data-resource-composition-api.vue Removed static data display elements
examples/sites/demos/pc/app/tree-menu/data-resource.spec.ts Removed static data test case, modified tree menu locator
examples/sites/demos/pc/app/tree-menu/data-resource.vue Removed descriptive paragraphs about data scenarios
examples/sites/demos/pc/app/tree-menu/webdoc/tree-menu.js Updated demo descriptions for data handling
packages/theme/src/tree-menu/index.less Replaced hardcoded colors with CSS variables
packages/theme/src/tree-menu/vars.less Added and modified CSS custom properties for tree menu styling

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

🌳 A tree menu grows, branches unfurl,
With data dancing, each node a pearl.
Variables flex, descriptions shine bright,
CodeRabbit hops with pure delight! 🐰
Styling evolves, flexibility soars.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 429c81f and 3fe8b02.

📒 Files selected for processing (2)
  • packages/theme/src/tree-menu/index.less (5 hunks)
  • packages/theme/src/tree-menu/vars.less (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/theme/src/tree-menu/index.less
  • packages/theme/src/tree-menu/vars.less
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 enhancement New feature or request (功能增强) and removed documentation 对文档的改进或补充 bug Something isn't working labels Jan 14, 2025
Copy link

Walkthrough

This pull request introduces static data and unused topic variables to the tree-menu component. It includes updates to the documentation and fixes a bug related to data handling. The changes involve adding static data to the tree-menu component and modifying related test cases and styles.

Changes

Files Summary
examples/sites/demos/apis/menu.js Updated description for data source from '数据源' to '服务端数据'.
examples/sites/demos/pc/app/tree-menu/basic-usage-composition-api.vue, examples/sites/demos/pc/app/tree-menu/basic-usage.vue Added static data to the tree-menu component.
examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts Modified test cases to accommodate static data.
examples/sites/demos/pc/app/tree-menu/data-resource-composition-api.vue, examples/sites/demos/pc/app/tree-menu/data-resource.vue Removed static data example, focusing on server data.
examples/sites/demos/pc/app/tree-menu/data-resource.spec.ts Removed test cases for static data.
examples/sites/demos/pc/app/tree-menu/webdoc/tree-menu.js Updated documentation to reflect changes in data handling.
packages/theme/src/tree-menu/index.less, packages/theme/src/tree-menu/vars.less Updated styles to use CSS variables for better customization.

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

🧹 Nitpick comments (3)
examples/sites/demos/pc/app/tree-menu/basic-usage-composition-api.vue (1)

9-173: Standardize the tree data structure.

The tree data structure has inconsistencies that could affect maintainability:

  1. Inconsistent usage of the url property (present in some nodes, missing in others)
  2. Varying ID formats (e.g., 100 vs 60101)

Consider standardizing:

  1. Add url property consistently where applicable
  2. Use a consistent ID format across all nodes

Example standardization:

 {
   id: 100,
-  label: '组件总览'
+  label: '组件总览',
+  url: 'overview'
 }
examples/sites/demos/pc/app/tree-menu/basic-usage.vue (1)

12-179: Well-structured hierarchical data with good organization.

The treeData implementation:

  • Uses unique IDs for each node
  • Follows a logical grouping structure
  • Maintains consistent nesting levels
  • Includes optional URL property where needed

Consider adding JSDoc type definitions for better code documentation and type safety.

 data() {
   return {
+    /** @type {{ 
+      * id: number,
+      * label: string,
+      * url?: string,
+      * children?: Array<{
+      *   id: number,
+      *   label: string,
+      *   url?: string,
+      *   children?: Array<any>
+      * }>
+      * }[]} */
     treeData: [
packages/theme/src/tree-menu/index.less (1)

157-161: Consistent use of variables for layout and styling.

The implementation:

  • Uses variables for padding and scrollbar
  • Properly positions node numbers
  • Applies hover font weight
  • Sets node content height

Consider adding RTL (right-to-left) support for better internationalization.

Also applies to: 195-196, 211-211, 254-254

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1b566 and 429c81f.

📒 Files selected for processing (10)
  • examples/sites/demos/apis/menu.js (1 hunks)
  • examples/sites/demos/pc/app/tree-menu/basic-usage-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/tree-menu/basic-usage.vue (2 hunks)
  • examples/sites/demos/pc/app/tree-menu/data-resource-composition-api.vue (0 hunks)
  • examples/sites/demos/pc/app/tree-menu/data-resource.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/tree-menu/data-resource.vue (0 hunks)
  • examples/sites/demos/pc/app/tree-menu/webdoc/tree-menu.js (1 hunks)
  • packages/theme/src/tree-menu/index.less (5 hunks)
  • packages/theme/src/tree-menu/vars.less (2 hunks)
💤 Files with no reviewable changes (2)
  • examples/sites/demos/pc/app/tree-menu/data-resource.vue
  • examples/sites/demos/pc/app/tree-menu/data-resource-composition-api.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (8)
examples/sites/demos/pc/app/tree-menu/data-resource.spec.ts (1)

8-8: Consider using a more specific selector for the tree menu.

Removing .nth(1) makes the locator target all .tiny-tree-menu instances on the page. This could lead to flaky tests if multiple tree menus exist. Consider using a more specific selector or data-testid attribute.

examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts (1)

3-25: Well-structured test coverage for tree menu functionality!

The test cases comprehensively cover:

  • Tree node expansion/collapse
  • Node selection state
  • Filter functionality with both positive and negative cases
examples/sites/demos/pc/app/tree-menu/basic-usage-composition-api.vue (1)

2-2: LGTM! Proper usage of composition API.

The template correctly binds the reactive treeData to the component using the composition API.

examples/sites/demos/pc/app/tree-menu/basic-usage.vue (1)

1-3: LGTM! Component usage is clear and concise.

The template correctly implements the tiny-tree-menu component with appropriate props.

examples/sites/demos/pc/app/tree-menu/webdoc/tree-menu.js (1)

12-13: Documentation updates improve clarity and consistency.

The changes:

  • Clarify static data usage in basic demo
  • Rename "Data Source" to "Server data" for better clarity
  • Update descriptions to match implementation

The translations are accurate and maintain consistency between Chinese and English.

Also applies to: 20-21, 24-26

packages/theme/src/tree-menu/vars.less (2)

42-61: Well-structured CSS variables for input and node positioning.

Good use of design tokens and clear organization of related variables. The variables provide fine-grained control over input element positioning and node content layout.


76-83: Good addition of theme-related variables.

The new variables enhance theming capabilities:

  • Background color uses design token
  • Scrollbar dimensions are configurable
  • Font weight for hover state is customizable
packages/theme/src/tree-menu/index.less (1)

28-28: Good implementation of theming variables.

The changes properly implement the new CSS variables for:

  • Background color
  • Input padding and margins
  • Input line positioning

Also applies to: 140-152

examples/sites/demos/apis/menu.js Show resolved Hide resolved
@wuyiping0628 wuyiping0628 changed the title feat(tree-menu): [tree-menu] Add static data and unused topic variables for rectification closes #2706 feat(tree-menu): [tree-menu] Add static data and unused topic variables for rectification Jan 14, 2025
@zzcr zzcr merged commit d59b0ea into opentiny:dev Jan 17, 2025
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants