menu icon indicating copy to clipboard operation
menu copied to clipboard

feat: add popupRender prop to support custom popup content

Open Zyf665 opened this issue 1 year ago • 3 comments

  • Add popupRender prop to Menu and SubMenu components
  • Support both global and individual SubMenu popup customization
  • popupRender receives node and info params for flexible rendering
  • Update types and context to support the new feature

This implements the RFC for customizable SubMenu popup content.

Summary by CodeRabbit

  • 新功能
    • 菜单及子菜单现支持自定义弹出内容渲染,提升了界面定制与交互体验。
    • 新示例展示了如何应用自定义弹出展示效果。
  • 文档
    • 添加了专门章节介绍自定义弹出效果,包括示例代码和使用指南。
  • 样式
    • 新增了弹出组件的样式,增强了视觉效果和交互体验。
  • 测试
    • 新增测试用例确保自定义弹出功能在各交互场景下稳定运行。

Zyf665 avatar Feb 17 '25 12:02 Zyf665

Walkthrough

新增了关于自定义弹出层渲染的文档章节、示例代码及样式文件,同时在核心组件(Menu、SubMenu、MenuContext 和接口定义)中增加了对 popupRender 属性的支持,并移除一些废弃的属性。各部分变更协同实现了弹出层渲染自定义化,并伴随相应的单元测试以验证新功能的正确性。

Changes

文件 变更摘要
docs/demo/customPopupRender.md, docs/examples/customPopupRender.tsx, docs/examples/customPopupRender.less 增加自定义弹出层渲染的文档说明、示例组件及对应样式
src/Menu.tsx, src/SubMenu/index.tsx, src/context/MenuContext.tsx, src/interface.ts 扩展接口,新增 popupRender 属性支持自定义弹出内容,同时移除旧属性并优化渲染逻辑
tests/popupRender.test.tsx 新增测试用例,覆盖不同场景下 popupRender 的渲染行为

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户
    participant M as Menu组件
    participant SM as 子菜单组件
    participant PR as popupRender函数
    participant D as 自定义渲染组件

    U->>M: 鼠标悬停或点击菜单项
    M->>SM: 通知显示子菜单
    SM->>PR: 检查并调用 popupRender(若定义)
    alt 使用自定义 popupRender
        PR->>D: 返回自定义渲染内容
        D-->>SM: 替换默认渲染
    else 未使用自定义
        SM-->>SM: 使用默认渲染
    end
    SM-->>M: 展示最终弹出层效果

Suggested reviewers

  • zombieJ
  • thinkasany

Poem

我是一只跳跃的小兔子,
在代码森林中漫步嬉戏。
自定义弹窗闪耀如星辰,
每一行代码舞动着诗意。
让我们欢庆这灵动更新 🐰✨!

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

.eslintrc.js

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js Error: Cannot find module '@umijs/fabric/dist/eslint' Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15) at Function.resolve (node:internal/modules/helpers:145:19) at Object. (/.eslintrc.js:2:21) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12)
src/Menu.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js Error: Cannot find module '@umijs/fabric/dist/eslint' Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15) at Function.resolve (node:internal/modules/helpers:145:19) at Object. (/.eslintrc.js:2:21) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12)
src/context/MenuContext.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js Error: Cannot find module '@umijs/fabric/dist/eslint' Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15) at Function.resolve (node:internal/modules/helpers:145:19) at Object. (/.eslintrc.js:2:21) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12)
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

coderabbitai[bot] avatar Feb 17 '25 12:02 coderabbitai[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.72%. Comparing base (d37a782) to head (b32753e). Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #747      +/-   ##
==========================================
+ Coverage   99.59%   99.72%   +0.13%     
==========================================
  Files          27       27              
  Lines         742      734       -8     
  Branches      203      198       -5     
==========================================
- Hits          739      732       -7     
+ Misses          3        2       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Feb 24 '25 01:02 codecov[bot]

CI 挂了

MadCcc avatar Mar 20 '25 03:03 MadCcc