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

chore: adjust classNames and styles #380

Closed
wants to merge 6 commits into from

Conversation

thinkasany
Copy link
Contributor

@thinkasany thinkasany commented Mar 11, 2025

Summary by CodeRabbit

  • 重构
    • 调整了图片预览和操作模块的样式配置及命名方式,实现风格上的统一和逻辑清晰。
  • 样式
    • 简化了预览界面的样式处理,移除了部分冗余配置,使对话框与遮罩的视觉效果更加清晰一致。
  • 测试
    • 更新了对图片组件的测试用例,移除了对根元素的样式和类名的验证,聚焦于遮罩和操作元素的测试。

Copy link

vercel bot commented Mar 11, 2025

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

Name Status Preview Comments Updated (UTC)
image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 6:53am

Copy link

coderabbitai bot commented Mar 11, 2025

Walkthrough

这个 PR 对与图片组件预览相关的类型和接口进行了重构。主要修改包括:

  • src/Image.tsx 中,引入 PreviewSemanticName 类型,并调整了 ImagePreviewTypeImageProps 接口中与样式相关的属性命名,同时在内部组件中更新了解构赋值。
  • src/Operations.tsx 中,更新了类型导入和相应属性定义,从 SemanticName 替换为 PreviewSemanticName
  • src/Preview.tsx 中,移除了 Dialog 组件的 style 属性并调整了 rootClassName 的逻辑。
  • 测试文件 tests/preview.test.tsx 中,更新了断言和选择器名称。

Changes

文件 更改摘要
src/Image.tsx 修改 ImagePreviewType 接口,将 classNamesstyles 属性由 SemanticName 改为 PreviewSemanticName;新增 PreviewSemanticName 类型;在 ImageProps 接口中添加了 classNamesstyles 属性;调整了 ImageInternal 组件的属性解构。
src/Operations.tsx 更新类型导入,将 SemanticName 替换为 PreviewSemanticName;修改 OperationsPropsclassNamesstyles 属性的定义。
src/Preview.tsx 移除 Dialog 组件的 style 属性;修改 rootClassName 逻辑,仅包含 classnames(rootClassName),不再组合 imageClassNames
tests/preview.test.tsx 调整测试断言:修改自定义类名元素数量判断,移除对 root 类名及其样式的断言;更新 mask 选择器名称从 .rc-image-mask.rc-image-preview-mask

Possibly related PRs

Suggested reviewers

  • zombieJ

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.

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.

src/Operations.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/Preview.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.


📜 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 9e6d4cc and 185b997.

📒 Files selected for processing (3)
  • src/Image.tsx (9 hunks)
  • src/Operations.tsx (3 hunks)
  • src/Preview.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/Preview.tsx
  • src/Operations.tsx
  • src/Image.tsx

🪧 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 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.79%. Comparing base (65df623) to head (185b997).
Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #380   +/-   ##
=======================================
  Coverage   99.79%   99.79%           
=======================================
  Files          15       15           
  Lines         486      486           
  Branches      139      139           
=======================================
  Hits          485      485           
  Misses          1        1           

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

src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
width="200"
/>
<div>
Copy link
Member

Choose a reason for hiding this comment

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

见上,不能加这个 div。rootClassName 是分别加到 inline 和 popup 最外层

src/Preview.tsx Outdated
@@ -51,6 +51,9 @@ export interface PreviewProps extends Omit<IDialogPropTypes, 'onClose' | 'styles
};
fallback?: string;
movable?: boolean;
/**
* @deprecated please use `Image.rootClassName` instead
*/
Copy link
Member

Choose a reason for hiding this comment

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

在 Image 里改成了:

rootClassName={classNames(rootClassName, imageClassNames?.root)}

到这里又写了个 @deprecated 感觉很奇怪。这里理论上来说 Preview 组件是外面不能直接使用的,也没有 @depreactead 说法。

src/Preview.tsx Outdated
@@ -311,8 +314,7 @@ const Preview: React.FC<PreviewProps> = props => {
mask: styles?.mask,
wrapper: styles?.wrapper,
}}
style={styles?.root}
rootClassName={classnames(rootClassName, imageClassNames?.root)}
rootClassName={classnames(rootClassName)}
Copy link
Member

Choose a reason for hiding this comment

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

单个 className 不需要 classnames 方法

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