Skip to content

refactor: optimize style type #508

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zbw-zbw
Copy link

@zbw-zbw zbw-zbw commented Aug 21, 2025

优化 style 类型声明

Summary by CodeRabbit

  • 重构
    • 将对话框的 wrapStyle、bodyStyle、maskStyle 属性改为使用 CSSProperties,统一样式类型定义并增强类型提示与校验。该变更不影响现有渲染效果,但在严格类型项目中可能出现编译提示,需要按标准 CSS 属性传递样式对象。升级后请自检相关调用与样式参数。

Copy link

vercel bot commented Aug 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dialog Ready Ready Preview Comment Aug 21, 2025 10:20am

Copy link

coderabbitai bot commented Aug 21, 2025

Walkthrough

在 src/IDialogPropTypes.tsx 中,将 wrapStyle、bodyStyle、maskStyle 三个公开属性的类型由 Record<string, any> 更改为 CSSProperties。

Changes

Cohort / File(s) Change Summary
类型收紧:对话框样式属性
src/IDialogPropTypes.tsx
wrapStylebodyStylemaskStyle 的类型从 Record<string, any> 更新为 CSSProperties

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

小兔提笔把样式细,
三处衣裳换新衣。
any 化身 CSS 样,
身披规范更合宜。
代码耳语风中立,
类型如绳系得齐。

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @zbw-zbw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

本次拉取请求重构了样式类型声明,以使用 CSSProperties,从而提高类型安全性和代码清晰度。

Highlights

  • 类型优化: 在 src/IDialogPropTypes.tsx 中,将 wrapStyle、bodyStyle 和 maskStyle 的通用类型 Record<string, any> 替换为 CSSProperties。这增强了样式属性的类型检查。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

你好,感谢你的贡献。这次的 Pull Request 优化了 IDialogPropTypes.tsx 文件中的样式属性类型,将 wrapStylebodyStylemaskStyle 从宽泛的 Record<string, any> 类型修改为更精确的 CSSProperties 类型。这是一个很好的重构,可以提高类型安全,为使用这些属性的开发者提供更好的代码提示和编译时检查。代码改动方向正确,没有发现问题。

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

🧹 Nitpick comments (4)
src/IDialogPropTypes.tsx (4)

40-42: 减少 API 重复:引导使用 styles 统一入口(文档/注释层面即可)

当前既有 wrapStyle/bodyStyle/maskStyle,也有聚合的 styles?: ModalStyles。为降低重复与歧义,建议在这三个单独样式 prop 上添加轻量 JSDoc 注释,提示优先使用 styles.wrapper/body/mask。不改变行为,仅作引导:

-  wrapStyle?: CSSProperties;
-  bodyStyle?: CSSProperties;
-  maskStyle?: CSSProperties;
+  /** 建议优先使用 styles.wrapper 以统一管理样式 */
+  wrapStyle?: CSSProperties;
+  /** 建议优先使用 styles.body 以统一管理样式 */
+  bodyStyle?: CSSProperties;
+  /** 建议优先使用 styles.mask 以统一管理样式 */
+  maskStyle?: CSSProperties;

48-49: 将 bodyProps/maskProps/wrapProps 从 any 收紧,提升可维护性

这三个 any 容易掩盖错误,且难以获益于智能提示。若底层渲染元素是 div,建议收紧为标准属性类型:

-  bodyProps?: any;
-  maskProps?: any;
+  bodyProps?: React.HTMLAttributes<HTMLDivElement>;
+  maskProps?: React.HTMLAttributes<HTMLDivElement>;
   ...
-  wrapProps?: any;
+  wrapProps?: React.HTMLAttributes<HTMLDivElement>;

若底层并非 div,请据实际元素替换为相应的 HTMLAttributes<...>

Also applies to: 53-53


51-52: 在 styles 上补充注释,明确其为推荐的样式入口

为配合前述指引,可在 styles 字段上加一句注释,帮助使用者优先迁移至聚合 API:

-  styles?: ModalStyles;
+  /** 推荐:统一样式入口,可替代 wrapStyle/bodyStyle/maskStyle 的分别传入 */
+  styles?: ModalStyles;

40-42: 静态排查结果:未发现内部使用中存在 null、数组或字符串赋给 wrapStyle/bodyStyle/maskStyle 的场景,但因其为对外暴露的 API,仍需评估破坏性变更影响。

  • 脚本排查(rg)未在 src/ 下检出以下可疑用法:
    1. 样式项含 : null
    2. 样式值为数组(例如 boxShadow: [...]
    3. 整体将字符串或数组赋给 wrapStyle/bodyStyle/maskStyle
  • 由于这些 prop 定义在公共接口中,虽然当前代码库内部无不合规范用法,但下游用户可能仍在样式对象中使用 null、数组或其它非标准值。

建议按照语义化版本管理原则,将此次类型收紧视为破坏性变更并在下一个主版本(major)中发布;若希望提供更平滑的过渡,可短期放宽为联合类型:

-  wrapStyle?: CSSProperties;
-  bodyStyle?: CSSProperties;
-  maskStyle?: CSSProperties;
+  // 过渡期:兼容历史 any,用于消化存量调用;后续再移除 Record
+  wrapStyle?: CSSProperties | Record<string, any>;
+  bodyStyle?: CSSProperties | Record<string, any>;
+  maskStyle?: CSSProperties | Record<string, any>;

此方案可在主版本中先提供兼容,待下游完成升级后再移除 Record<string, any>

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between acf2569 and ba7256d.

📒 Files selected for processing (1)
  • src/IDialogPropTypes.tsx (1 hunks)
🔇 Additional comments (1)
src/IDialogPropTypes.tsx (1)

40-42: 将 wrapStyle/bodyStyle/maskStyle 强类型化为 CSSProperties 很棒

  • 与已有的 style/rootStyle 一致,类型更严谨。
  • 获得完备的 TS 补全与校验(避免拼写错误与非法取值),对 CSS 变量也友好(CSSProperties 含索引签名)。

Copy link

codecov bot commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (acf2569) to head (ba7256d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #508   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files           8        8           
  Lines         195      195           
  Branches       68       68           
=======================================
  Hits          192      192           
  Misses          3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants