Skip to content

feat(indicator): 增加 UI 变体的类型 #3114

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 2 commits into from
Mar 28, 2025

Conversation

oasis-cloud
Copy link
Collaborator

@oasis-cloud oasis-cloud commented Mar 24, 2025

Summary by CodeRabbit

  • 新功能
    • 下拉刷新功能现已启用,改善了交互体验。
    • 指标组件新增“dualScreen”展示模式,为视觉效果和布局提供了更多灵活性。
  • 文档
    • 指标组件文档中更新了类型定义,新增“dualScreen”选项。

Copy link

coderabbitai bot commented Mar 24, 2025

Walkthrough

此次 PR 对配置和组件使用方式做出修改。在配置文件中,将 PullToRefresh 组件的 "dd" 属性从 false 改为 true;同时,在 indicator 组件的多个 demo 中删除了一些 Indicator 实例,简化了组件的展示。此外,更新了 maybeFixedWidth 函数的条件逻辑,将判断条件从基于 total 改为直接检测 type 是否为 'dualScreen''slide',并扩展了 IndicatorType 类型,新增 'dualScreen' 字面量。

Changes

文件路径 更改摘要
src/config.json 修改 PullToRefresh 配置,将 "dd" 属性从 false 改为 true,以启用相关功能。
src/packages/indicator/demos/{h5,taro}/demo1.tsx 删除多个 Indicator 组件实例,简化 Demo1 组件的展示。
src/packages/indicator/indicator.{taro,tsx} 更新 maybeFixedWidth 函数逻辑:原条件为 `total === 2
src/types/spec/indicator/base.ts 扩展 IndicatorType 类型,新增 'dualScreen' 选项,丰富类型定义。
src/packages/indicator/demos/{h5,taro}/demo6.tsx 修改 Indicator 组件实例,新增 type="dualScreen" 属性,并删除 direction 属性,增加了新的 Cell 组件。
src/packages/indicator/doc.{en-US,md,taro,zh-TW}.md 更新 Indicator 组件文档中的 type 属性定义,新增 'dualScreen' 选项。

Sequence Diagram(s)

sequenceDiagram
    participant App as 应用
    participant Config as 配置 (src/config.json)
    participant PTR as PullToRefresh组件
    App->>Config: 加载配置
    Config-->>App: 返回 {"dd": true}
    App->>PTR: 初始化 PullToRefresh(dd 启用)
Loading
sequenceDiagram
    participant I as Indicator组件
    participant L as maybeFixedWidth函数
    I->>L: 传入 type 属性
    alt type 为 'dualScreen' 或 'slide'
        L-->>I: 返回 fixed-width 样式
    else
        L-->>I: 返回默认样式
    end
Loading

Possibly related PRs

Suggested reviewers

  • xiaoyatong
  • irisSong

Poem

我是一只快乐的小兔,
代码里跳跃着新的步。
PullToRefresh 张开大门,
Indicator 显现新风度。
轻快跃动在逻辑间,
伴我写下美丽诗句 🐰✨

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

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels Mar 24, 2025
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.95%. Comparing base (9a903a0) to head (d3f97f3).
Report is 13 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3114   +/-   ##
==========================================
  Coverage      86.95%   86.95%           
==========================================
  Files            280      280           
  Lines          18456    18456           
  Branches        2786     2786           
==========================================
  Hits           16049    16049           
  Misses          2402     2402           
  Partials           5        5           

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

Copy link
Collaborator

@xiaoyatong xiaoyatong left a comment

Choose a reason for hiding this comment

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

1、建议叫 dualScreen
2、建议demo展示一致性,如 在 类型组,添加该demo

@xiaoyatong
Copy link
Collaborator

3、需要加一下文档

@oasis-cloud oasis-cloud requested a review from xiaoyatong March 25, 2025 04:16
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: 1

🧹 Nitpick comments (1)
src/packages/indicator/demos/h5/demo6.tsx (1)

5-18: 需要添加 dualScreen 类型的具体渲染逻辑

根据相关代码片段,目前 renderByType 函数只针对 slide 类型有特殊处理,而 dualScreen 类型将使用默认的点元素渲染逻辑。虽然 maybeFixedWidth 函数已更新以支持 dualScreen 类型的固定宽度,但可能需要实现专门的渲染逻辑。

建议检查 dualScreen 类型是否需要特殊的渲染逻辑:

const renderByType = (type: IndicatorType) => {
  switch (type) {
    case 'slide':
      return renderLineElement()
+   case 'dualScreen':
+     return renderDualScreenElement() // 实现适合双屏显示的渲染逻辑
    default:
      return renderDotElement()
  }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a6bce8 and d3f97f3.

📒 Files selected for processing (11)
  • src/packages/indicator/demos/h5/demo1.tsx (0 hunks)
  • src/packages/indicator/demos/h5/demo6.tsx (1 hunks)
  • src/packages/indicator/demos/taro/demo1.tsx (0 hunks)
  • src/packages/indicator/demos/taro/demo6.tsx (1 hunks)
  • src/packages/indicator/doc.en-US.md (1 hunks)
  • src/packages/indicator/doc.md (1 hunks)
  • src/packages/indicator/doc.taro.md (1 hunks)
  • src/packages/indicator/doc.zh-TW.md (1 hunks)
  • src/packages/indicator/indicator.taro.tsx (1 hunks)
  • src/packages/indicator/indicator.tsx (1 hunks)
  • src/types/spec/indicator/base.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • src/packages/indicator/demos/h5/demo1.tsx
  • src/packages/indicator/demos/taro/demo1.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/packages/indicator/indicator.tsx
  • src/packages/indicator/indicator.taro.tsx
  • src/types/spec/indicator/base.ts
🧰 Additional context used
🧬 Code Definitions (2)
src/packages/indicator/demos/h5/demo6.tsx (2)
src/packages/indicator/indicator.taro.tsx (1)
  • Indicator (17-97)
src/packages/indicator/indicator.tsx (1)
  • Indicator (15-92)
src/packages/indicator/demos/taro/demo6.tsx (2)
src/packages/indicator/indicator.taro.tsx (1)
  • Indicator (17-97)
src/packages/indicator/indicator.tsx (1)
  • Indicator (15-92)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (6)
src/packages/indicator/doc.taro.md (1)

71-71: 已更新文档以包含新的 UI 变体类型

在属性文档中正确添加了 dualScreen 类型,使文档与代码实现保持一致。

src/packages/indicator/doc.zh-TW.md (1)

71-71: 已更新繁體中文文档以包含新的 UI 變體類型

在屬性文檔中正確添加了 dualScreen 類型,使文檔與代碼實現保持一致。

src/packages/indicator/doc.md (1)

71-71: 已更新简体中文文档以包含新的 UI 变体类型

在属性文档中正确添加了 dualScreen 类型,使文档与代码实现保持一致。

src/packages/indicator/doc.en-US.md (1)

71-71: 已更新英文文档以包含新的 UI 变体类型

在属性文档中正确添加了 dualScreen 类型,使文档与代码实现保持一致。

src/packages/indicator/demos/h5/demo6.tsx (1)

11-15: 新类型 dualScreen 的示例实现

代码中添加了两个 dualScreen 类型的示例,分别展示了不同状态(current=0 和 current=1)和不同颜色设置。这有助于用户理解新类型的视觉效果和用法。

然而,根据 PR 评论,应该添加关于这个新类型的具体文档说明。

建议添加一段关于 dualScreen 类型的详细描述,解释其用途和与其他类型的区别。例如,可以在各语言版本的文档中的 "类型" 部分添加说明。

src/packages/indicator/demos/taro/demo6.tsx (1)

11-12: 新增的 dualScreen 类型示例展示良好

这里演示了新增的 dualScreen UI 变体类型的基本用法,当前选中为第一个点(current={0})。从代码可以看出,这个类型需要设置总数为2,符合"双屏幕"的设计理念。

Comment on lines +13 to +14
<Cell style={{ background: '#C2C4CC' }}>
<Indicator total={2} type="dualScreen" current={1} color="default" />
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

白色变体示例实现恰当

这个例子很好地展示了 dualScreen 类型在深色背景下的使用方式,并通过 color="default" 设置为白色变体,当前选中为第二个点(current={1})。这种搭配能让用户明确了解不同背景下的适用情况。

不过,建议考虑在文档中添加关于这个新类型的详细说明,包括其适用场景和设计理念。


🌐 Web query:

NutUI React 组件库中的 Indicator 组件有哪些类型和用法说明?

💡 Result:

NutUI React组件库的Indicator组件主要用于分页指示、步骤引导等场景,提供以下核心功能和用法:

组件类型

1. 分页指示器

  • 用于轮播图、图片预览等场景的分页标识
  • 支持圆形/方形/数字等多种样式[3][13]

2. 步骤指示器

  • 用于流程引导、多步骤表单场景
  • 支持水平/垂直布局[1][18]

基本用法

import { Indicator } from '@nutui/nutui-react-taro';

// 分页指示
<Indicator total={3} current={2} />

// 步骤指示
<Indicator type="step" current={1}>
  <div>第一步</div>
  <div>第二步</div>
  <div>第三步</div>
</Indicator>

关键配置项

属性 类型 说明 默认值
size number 指示点尺寸 6
activeColor string 激活状态颜色 #FA2C19
inactiveColor string 未激活状态颜色 #EBEBEB
align 'left'|'center'|'right' 对齐方式 center

进阶功能

  1. 自定义样式
    通过CSS变量修改基础样式:
:root {
  --nutui-indicator-color: #1989fa;
  --nutui-indicator-dot-size: 8px;
}
  1. 动态交互
    支持onChange事件监听步骤切换:
<Indicator 
  current={activeStep}
  onChange={(step) => setActiveStep(step)}
/>
  1. 组合使用
    与Popup、Swiper等组件配合使用时,可通过zIndex参数控制层级关系[3][19],最新版本已优化动态层级计算逻辑,减少手动设置需求[13][18]。

该组件在v2.7.x版本中持续优化样式表现和兼容性[3][13],建议通过npm install @nutui/nutui-react-taro@latest获取最新稳定版本。

Citations:


请更新文档说明以涵盖 dualScreen 类型

示例代码在深色背景下成功展示了白色变体的实现,代码实现正确。但建议在文档中补充对 dualScreen 类型的详细说明,包括其适用场景和设计理念,以便用户更全面地了解该新类型的使用场景。

  • 文件:src/packages/indicator/demos/taro/demo6.tsx (第 13-14 行)
  • 示例代码:
          <Cell style={{ background: '#C2C4CC' }}>
            <Indicator total={2} type="dualScreen" current={1} color="default" />

@oasis-cloud
Copy link
Collaborator Author

1、建议叫 dualScreen 2、建议demo展示一致性,如 在 类型组,添加该demo

fixed

@oasis-cloud
Copy link
Collaborator Author

3、需要加一下文档

fixed

@xiaoyatong xiaoyatong merged commit 99fac51 into jdf2e:feat_v3.x Mar 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants