Skip to content

fix(navbar): 支持background的配置,补充了部分demo#3258

Merged
irisSong merged 1 commit intojdf2e:feat_v3.xfrom
xiaoyatong:fix3/navbar0609
Jun 9, 2025
Merged

fix(navbar): 支持background的配置,补充了部分demo#3258
irisSong merged 1 commit intojdf2e:feat_v3.xfrom
xiaoyatong:fix3/navbar0609

Conversation

@xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented Jun 9, 2025

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 样式

    • 导航栏默认背景色由原来的背景色变量调整为白色。
    • 导航栏默认阴影效果被移除,视觉上更加简洁。
    • 导航栏及其子组件的配色和间距通过 CSS 变量和样式优化,提升了主题一致性和可定制性。
  • 文档

    • 更新了导航栏相关文档,反映默认阴影效果的变更。
  • 示例优化

    • 导航栏示例组件布局结构优化,统一采用垂直间距容器,移除多余包裹元素,提升代码简洁性和示例一致性。

@xiaoyatong xiaoyatong requested a review from irisSong June 9, 2025 03:46
@coderabbitai
Copy link

coderabbitai bot commented Jun 9, 2025

Walkthrough

本次变更主要围绕 NavBar 组件的样式与演示用例结构优化。包括调整默认背景色与阴影、统一使用 Space 组件实现垂直布局、精简多余的容器结构,并通过 CSS 变量方式增强主题定制能力。文档内容同步更新以反映新的默认样式。

Changes

文件/分组 变更摘要
.../navbar/demos/h5/demo1.tsx
.../navbar/demos/taro/demo1.tsx
引入 Space 组件,顶层由 Fragment 改为 Space(direction="vertical"),统一布局。
.../navbar/demos/h5/demo2.tsx
.../navbar/demos/taro/demo2.tsx
移除多余 div/View 容器,NavBar 直接包裹于 Space,精简结构,title 渲染方式统一。
.../navbar/demos/h5/demo3.tsx
.../navbar/demos/taro/demo3.tsx
外层包裹 Space,NavBar 与 Tabs 样式通过 CSS 变量设置,增强主题灵活性。
.../navbar/doc*.md 默认 box-shadow 变量值由有阴影改为无阴影,文档同步调整说明。
.../navbar/navbar.scss .nut-navbar 增加 background 和 box-shadow,均用变量控制。
src/styles/variables.scss $navbar-background 默认值由 $color-background 改为 $white。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DemoComponent
    participant Space
    participant NavBar
    participant Tabs

    User->>DemoComponent: 访问演示页面
    DemoComponent->>Space: 渲染 Space(direction="vertical")
    Space->>NavBar: 依次渲染多个 NavBar
    NavBar-->>Tabs: (部分 NavBar 内嵌 Tabs)
    Tabs-->>NavBar: 展示标签页
    NavBar-->>Space: 完成渲染
    Space-->>DemoComponent: 完成垂直布局
Loading

Suggested reviewers

  • oasis-cloud

Poem

小兔子挥舞着爪爪,
Navbar 变得更优雅。
阴影褪去风更轻,
Space 垂直更清新。
变量加持易主题,
代码精简心欢喜。
兔子蹦跳来庆贺,
UI 焕新乐无比!


📜 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 3b03fa0 and eabadc2.

📒 Files selected for processing (12)
  • src/packages/navbar/demos/h5/demo1.tsx (3 hunks)
  • src/packages/navbar/demos/h5/demo2.tsx (1 hunks)
  • src/packages/navbar/demos/h5/demo3.tsx (5 hunks)
  • src/packages/navbar/demos/taro/demo1.tsx (3 hunks)
  • src/packages/navbar/demos/taro/demo2.tsx (1 hunks)
  • src/packages/navbar/demos/taro/demo3.tsx (5 hunks)
  • src/packages/navbar/doc.en-US.md (1 hunks)
  • src/packages/navbar/doc.md (1 hunks)
  • src/packages/navbar/doc.taro.md (1 hunks)
  • src/packages/navbar/doc.zh-TW.md (1 hunks)
  • src/packages/navbar/navbar.scss (1 hunks)
  • src/styles/variables.scss (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/packages/navbar/demos/taro/demo3.tsx (2)
src/utils/taro/platform.ts (1)
  • harmony (3-7)
src/packages/navbar/navbar.taro.tsx (1)
  • NavBar (19-136)
🪛 LanguageTool
src/packages/navbar/doc.taro.md

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ... --nutui-navbar-box-shadow | 头部导航的阴影 | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

src/packages/navbar/doc.en-US.md

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ...-navbar-box-shadow | Shadow of navbar | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

src/packages/navbar/doc.md

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ... --nutui-navbar-box-shadow | 头部导航的阴影 | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

src/packages/navbar/doc.zh-TW.md

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ... --nutui-navbar-box-shadow | 頭部導航的陰影 | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (28)
src/styles/variables.scss (1)

2239-2239: 检查默认 $navbar-background 的变更兼容性
将默认背景从 $color-background 改为 $white 可能导致现有主题背景失效,请确认此调整符合设计规范并在更新日志中记录该破坏性变更。

src/packages/navbar/navbar.scss (1)

10-11: 应用 $navbar-background$navbar-box-shadow 支持
新增 backgroundbox-shadow 样式,组件已正确支持通过 CSS 变量定制外观,符合预期。

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

65-65: 校对文档一致性
已将默认阴影值更新为 0px 0px transparent,请确认所有语言版本及 Taro 文档也已同步修改。

🧰 Tools
🪛 LanguageTool

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ... --nutui-navbar-box-shadow | 头部导航的阴影 | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

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

65-65: 校对英文文档一致性
已将默认阴影值更新为 0px 0px transparent,请确认 Taro 文档及其他相关示例已同步。

🧰 Tools
🪛 LanguageTool

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ...-navbar-box-shadow | Shadow of navbar | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

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

65-65: 校对繁体文档一致性
已将默认陰影值更新為 0px 0px transparent,請確認 Taro 文檔及其他相關範例也已同步調整。

🧰 Tools
🪛 LanguageTool

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ... --nutui-navbar-box-shadow | 頭部導航的陰影 | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

src/packages/navbar/doc.taro.md (1)

65-65: 样式变量更新正确

将导航栏的默认阴影效果移除(从可见阴影改为透明),这个变更与 PR 目标一致,文档描述准确。

🧰 Tools
🪛 LanguageTool

[duplication] ~65-~65: Possible typo: you repeated a word.
Context: ... --nutui-navbar-box-shadow | 头部导航的阴影 | 0px 0px transparent | | --nutui-navbar-color ...

(ENGLISH_WORD_REPEAT_RULE)

src/packages/navbar/demos/h5/demo2.tsx (1)

26-74: 布局结构优化很好

使用 Space 组件替代冗余的 div 包装器,简化了布局结构,提高了代码可读性。所有 NavBar 组件的功能和交互行为都得到保留。

src/packages/navbar/demos/taro/demo1.tsx (2)

4-4: 导入语句更新正确

正确添加了 Space 组件的导入,与其他演示文件保持一致。


28-87: 布局容器改进

使用 Space 组件替代 React fragment 提供垂直布局,与 H5 版本的演示保持一致,改善了组件间的间距处理。

src/packages/navbar/demos/h5/demo1.tsx (2)

2-2: 导入语句完善

正确添加 Space 组件导入,支持后续的布局改进。


24-66: 布局组织优化

使用 Space 组件包装 NavBar 实例,提供标准化的垂直间距,与其他演示文件保持一致的布局模式。

src/packages/navbar/demos/taro/demo3.tsx (6)

4-4: 导入更新正确

正确添加了 Space 组件的导入,用于实现垂直布局。


12-12: 布局结构优化

使用 Space 组件替代 React Fragment 来管理垂直间距是一个很好的改进,提供了更一致的布局控制。

Also applies to: 85-85


14-14: CSS变量主题化

使用 --nutui-navbar-background CSS变量来设置透明背景是正确的主题化方式,符合组件设计系统。


37-37: Tabs组件样式统一

将背景色设置改为使用CSS变量 --nutui-tabs-titles-background-color 保持了与NavBar一致的主题化方式。


47-50: 红色主题NavBar配置

通过CSS变量正确配置了红色背景和白色文字的主题,展示了组件的自定义能力。


67-72: 完整的Tabs主题配置

通过多个CSS变量完整配置了Tabs组件在深色背景下的样式,包括间距、背景色、文字颜色等,展示了组件的灵活性。

src/packages/navbar/demos/taro/demo2.tsx (5)

29-29: 布局结构优化

使用 Space 组件统一管理多个NavBar之间的垂直间距,简化了布局结构。

Also applies to: 107-107


30-46: 第一个NavBar配置正确

带返回按钮和分享图标的NavBar配置正确,标题作为children渲染是合理的结构。


48-58: 简化的NavBar结构

移除了不必要的容器包装,直接在NavBar中渲染标题内容,结构更加清晰。


59-84: 复杂布局的NavBar示例

展示了包含主标题和副标题的复杂布局,通过flexbox正确实现了垂直排列的标题结构。


85-106: 多操作按钮的NavBar

正确配置了包含编辑按钮和更多操作图标的NavBar,展示了右侧多个操作元素的布局。

src/packages/navbar/demos/h5/demo3.tsx (6)

2-2: H5平台导入更新

正确添加了 Space 组件的导入,与Taro版本保持一致。


9-9: 跨平台布局一致性

H5版本使用相同的 Space 组件布局方式,确保了跨平台的一致性体验。

Also applies to: 72-72


11-11: 透明背景主题配置

与Taro版本一致,使用CSS变量设置透明背景,保持了跨平台的主题化方式统一。


29-29: Tabs背景色CSS变量

统一使用CSS变量设置Tabs背景色,替代了直接的CSS属性,提高了主题化的一致性。


39-42: 红色主题样式配置

H5版本的红色主题配置与Taro版本完全一致,确保了跨平台的视觉一致性。


54-59: 完整的深色主题Tabs配置

通过CSS变量完整配置了深色背景下Tabs的所有样式属性,展示了组件在不同主题下的适配能力。

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@github-actions github-actions bot added 3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) labels Jun 9, 2025
@xiaoyatong xiaoyatong linked an issue Jun 9, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.75%. Comparing base (3b03fa0) to head (eabadc2).
Report is 1 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3258   +/-   ##
==========================================
  Coverage      87.75%   87.75%           
==========================================
  Files            290      290           
  Lines          19111    19111           
  Branches        2938     2938           
==========================================
  Hits           16771    16771           
  Misses          2335     2335           
  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.

@irisSong irisSong merged commit fd247f0 into jdf2e:feat_v3.x Jun 9, 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/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navbar 3.x 版本背景色css变量丢失

2 participants