Skip to content

chore: back of missing preview.rootClassName #384

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

Merged
merged 1 commit into from
Mar 17, 2025
Merged

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Mar 17, 2025

Summary by CodeRabbit

  • 新功能
    • 预览组件现支持更灵活的样式定制。用户可通过配置传入额外的样式类,实现更个性化的界面风格。

Copy link

vercel bot commented Mar 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
image ❌ Failed (Inspect) Mar 17, 2025 11:45am

Copy link

coderabbitai bot commented Mar 17, 2025

Walkthrough

此次修改在预览配置中引入了新的可选属性 rootClassName。在 Image 组件中,该属性与 previewRootClassName 通过 classnames 工具合并后用于渲染预览视图。同时,在 src/Preview/index.tsx 中,rootClassName 被从 PreviewProps 接口中移除,并添加到 InternalPreviewConfig 接口中。测试文件也新增用例,验证该属性是否正确应用于预览元素。

Changes

文件 更改摘要
src/Image.tsx, src/Preview/index.tsx 修改了预览配置接口:在 Image 中添加 rootClassName 属性,并在 Preview 中调整接口声明和类名合并逻辑。
tests/preview.test.tsx 新增测试用例验证 rootClassName 在预览组件中的正确应用,同时简化了现有测试代码。

Sequence Diagram(s)

sequenceDiagram
    participant Image
    participant Preview
    participant classnames
    Image->>Preview: 传入包含 rootClassName 与 previewRootClassName 的 preview 配置
    Preview->>classnames: 调用 classnames 合并类名
    classnames-->>Preview: 返回合并后的类名
    Preview-->>Image: 渲染预览元素并应用合并类名
Loading

Possibly related PRs

Poem

我是一只快乐的小兔子,
在代码森林里跳跃追寻新奇,
新添的 rootClassName 给预览添色,
类名合并如同花开的美丽,
测试奏响成功的旋律 —— 🐰🎶

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.

src/Preview/index.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

src/Image.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

tests/preview.test.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 ea030fd and af94c38.

📒 Files selected for processing (3)
  • src/Image.tsx (2 hunks)
  • src/Preview/index.tsx (1 hunks)
  • tests/preview.test.tsx (2 hunks)
🔇 Additional comments (5)
src/Preview/index.tsx (1)

71-72: 良好的代码注释!

这个注释清晰地说明了应该使用 classNames.root 而不是直接使用 rootClassName,有助于引导开发者使用更推荐的API方式。

src/Image.tsx (2)

122-122: 适当的属性解构

从 preview 对象中解构 rootClassNamepreviewRootClassName,为后面在 Preview 组件上使用做准备。


266-266: 良好的类名组合逻辑

使用 classnamespreviewRootClassName 和全局 rootClassName 组合在一起,确保两者都能应用于预览组件,增强了组件的灵活性。

tests/preview.test.tsx (2)

646-646: 代码简化

移除了未使用的 container 变量解构,简化了代码。


715-728: 很好的测试用例

新增测试用例验证了 preview.rootClassName 能够正确应用于预览元素,这确保了在 PR 中添加的新功能得到了充分测试。

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • 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 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.

Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.40%. Comparing base (ea030fd) to head (af94c38).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #384   +/-   ##
=======================================
  Coverage   99.40%   99.40%           
=======================================
  Files          17       17           
  Lines         502      502           
  Branches      148      148           
=======================================
  Hits          499      499           
  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.

@zombieJ zombieJ merged commit 5f361cf into master Mar 17, 2025
9 of 10 checks passed
@zombieJ zombieJ deleted the rootClassName branch March 17, 2025 11:55
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.

1 participant