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(imagepreview): use nutui image #2793

Open
wants to merge 2 commits into
base: feat_v3.x
Choose a base branch
from

Conversation

xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented Nov 22, 2024

Summary by CodeRabbit

  • 新功能

    • 更新了图像预览组件的样式,以改进图像和视频元素的布局,确保内容在水平和垂直方向上居中。
  • 改进

    • 简化了图像预览组件的 JSX 结构,提升了代码可读性。

Copy link

coderabbitai bot commented Nov 22, 2024

Walkthrough

此次更改主要涉及 imagepreview.scssimagepreview.taro.tsx 文件。imagepreview.scss 文件中新增了 .nut-image.nut-video 类的样式,以实现内容的水平和垂直居中。imagepreview.taro.tsx 文件则更新了 Image 组件的导入路径,并简化了 JSX 结构,未对组件的核心功能和事件处理逻辑进行更改。

Changes

文件路径 更改摘要
src/packages/imagepreview/imagepreview.scss 新增 .nut-image.nut-video 类的样式,以实现内容的水平和垂直居中。
src/packages/imagepreview/imagepreview.taro.tsx 更新 Image 组件的导入路径,简化 JSX 结构,未更改核心功能或事件处理逻辑。

Possibly related PRs

Suggested labels

size/M, 3.x

Suggested reviewers

  • oasis-cloud

🐇 在图像预览中,
新样式让内容更美妙,
居中展示如梦幻,
组件更新更简单,
兔子欢跳庆变化,
让我们一起享受吧! 🌟


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 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 Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.99%. Comparing base (9332996) to head (e1a30f6).

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #2793   +/-   ##
==========================================
  Coverage      83.99%   83.99%           
==========================================
  Files            220      220           
  Lines          17885    17885           
  Branches        2679     2679           
==========================================
  Hits           15023    15023           
  Misses          2857     2857           
  Partials           5        5           

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

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

🧹 Outside diff range and nitpick comments (1)
src/packages/imagepreview/imagepreview.scss (1)

80-86: 样式实现合理,建议添加注释说明

新增的样式使用 flex 布局来实现内容居中,实现方式符合最佳实践。建议添加注释说明样式的用途,以提高代码可维护性。

建议添加如下注释:

      .nut-image,
      .nut-video {
+       // 使用 flex 布局实现内容水平垂直居中
        display: flex;
        justify-content: center;
        align-items: center;
      }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c77e619 and eff25f7.

📒 Files selected for processing (2)
  • src/packages/imagepreview/imagepreview.scss (1 hunks)
  • src/packages/imagepreview/imagepreview.taro.tsx (1 hunks)
🔇 Additional comments (3)
src/packages/imagepreview/imagepreview.taro.tsx (3)

Line range hint 91-157: 建议全面测试图片缩放功能

由于更换了底层 Image 组件的实现,请重点测试以下场景:

  1. 双指缩放手势的响应性
  2. 双击放大/缩小功能
  3. 缩放过程中的性能表现
  4. 边界条件下的行为(最大/最小缩放比例)

Line range hint 313-328: 图片预览实现符合预期

代码实现合理:

  1. 正确处理了平台特定属性(showMenuByLongpress)
  2. 保持了与原有功能的一致性
  3. 图片样式设置适当

10-10: 请验证 NutUI Image 组件 API 兼容性

从 @tarojs/components 切换到 NutUI 的 Image 组件是一个重要改动。建议:

  1. 确认新的 Image 组件支持所有必需的属性(mode、showMenuByLongpress 等)
  2. 验证在各类设备和场景下的兼容性

Also applies to: 14-14

✅ Verification successful

NutUI Image 组件 API 兼容性已确认

经过验证,NutUI Image 组件完全支持当前场景所需的功能:

  • 在 imagepreview.taro.tsx 中,Image 组件仅使用了 srcmode 和基础样式属性
  • NutUI Image 组件(image.taro.tsx)继承了 Taro Image 的所有属性(通过 Omit<TImageProps, 'style'>
  • 组件使用方式符合预期,不会影响现有功能
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查 NutUI Image 组件的 API 定义
ast-grep --pattern 'interface $ImageProps {
  $$$
}'

Length of output: 54


Script:

#!/bin/bash
# 搜索 Image 组件的属性定义和使用方式
rg -A 10 "type ImageProps" src/packages/image/
rg -A 10 "interface ImageProps" src/packages/image/

# 检查 ImagePreview 中 Image 组件的使用
rg -A 5 "Image" src/packages/imagepreview/imagepreview.taro.tsx

# 检查原始 Taro Image 组件的使用方式
rg -A 5 "Image.*from.*@tarojs/components" 

Length of output: 11454

@irisSong
Copy link
Collaborator

irisSong commented Nov 25, 2024

1、关闭按钮icon svg 色值不对 2、设置初始页码打开滑动在关闭,展示图片不对

@github-actions github-actions bot added the 3.x label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants