Skip to content

feat: ✨ 新增 FloatingPanel 浮动面板组件#616

Merged
Moonofweisheng merged 3 commits into
Moonofweisheng:masterfrom
RYGRIT:feat/floating-panel
Sep 24, 2024
Merged

feat: ✨ 新增 FloatingPanel 浮动面板组件#616
Moonofweisheng merged 3 commits into
Moonofweisheng:masterfrom
RYGRIT:feat/floating-panel

Conversation

@RYGRIT

@RYGRIT RYGRIT commented Sep 20, 2024

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?(至少选择一个)

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

🔗 相关 Issue

可以添加一个FloatingPanel 浮动面板
Discussions

💡 需求背景和解决方案

1、新增 FloatingPanel 浮动面板组件。
2、API实现和用法可参见对应文档。

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

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

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新功能

    • 添加了浮动面板组件的文档和示例,用户可以在页面底部拖动面板以查看额外内容。
    • 新增浮动面板页面,包含特定样式和导航标题。
    • 引入了浮动面板的 Vue 组件,支持高度调整和拖动功能。
  • 文档

    • 更新了文档以包含浮动面板组件的详细使用说明和自定义选项。
  • 样式

    • 为浮动面板组件添加了新的样式变量,增强了样式定制能力。

@vercel

vercel Bot commented Sep 20, 2024

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 9:38am

@coderabbitai

coderabbitai Bot commented Sep 20, 2024

Copy link
Copy Markdown

Walkthrough

该拉取请求引入了一个新的“FloatingPanel”组件,更新了文档配置以包含该组件的链接和文本。新文件floating-panel.md提供了关于该组件的详细文档,包括其用法、定制选项和交互功能。同时,更新了应用程序的导航结构,新增了浮动面板页面,并添加了相应的样式和变量定义,以支持该组件的外观和功能。

Changes

文件路径 更改摘要
docs/.vitepress/config.mts 添加了“FloatingPanel”组件的链接和文本。
docs/component/floating-panel.md 新增了floating-panel.md文件,提供了关于“FloatingPanel”组件的详细文档。
src/pages.json src/pages.json中添加了浮动面板页面的配置。
src/pages/floatingPanel/Index.vue 新增了Index.vue文件,介绍了浮动面板的基本用法和自定义选项。
src/pages/index/Index.vue 在组件列表中添加了“FloatingPanel 浮动面板”的新条目。
src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss 新增了与浮动面板相关的样式变量。
src/uni_modules/wot-design-uni/components/common/util.ts 添加了closest函数,用于查找数组中最接近目标值的元素。
src/uni_modules/wot-design-uni/components/wd-floating-panel/index.scss 新增了浮动面板的样式,支持深色主题和默认主题。
src/uni_modules/wot-design-uni/components/wd-floating-panel/type.ts 新增了浮动面板组件的属性定义。
src/uni_modules/wot-design-uni/components/wd-floating-panel/wd-floating-panel.vue 新增了wd-floating-panel组件,支持拖动和高度调整的浮动面板界面。

Possibly related PRs

Poem

🐰 在浮动面板的世界里,
新增功能如春风吹,
文档更新,样式齐,
组件交互乐无比。
兔子欢跳,庆新生,
浮动面板,真有趣! 🌼


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.

@netlify

netlify Bot commented Sep 20, 2024

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7f07d30
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/66ed42572c460d000877a25c
😎 Deploy Preview https://deploy-preview-616--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a7fc229 and 7f07d30.

Files selected for processing (10)
  • docs/.vitepress/config.mts (1 hunks)
  • docs/component/floating-panel.md (1 hunks)
  • src/pages.json (1 hunks)
  • src/pages/floatingPanel/Index.vue (1 hunks)
  • src/pages/index/Index.vue (1 hunks)
  • src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss (1 hunks)
  • src/uni_modules/wot-design-uni/components/common/util.ts (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-floating-panel/index.scss (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-floating-panel/type.ts (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-floating-panel/wd-floating-panel.vue (1 hunks)
Additional comments not posted (26)
src/uni_modules/wot-design-uni/components/wd-floating-panel/type.ts (1)

4-30: props 设计合理,涵盖了常见需求

floatingPanelProps 对象定义了 FloatingPanel 组件的所有 prop,包括:

  • height:用于设置面板高度
  • anchors:自定义面板的锚点位置
  • safeAreaInsetBottom:是否开启底部安全区域
  • showScrollbar:是否显示滚动条
  • duration:自定义动画时长
  • contentDraggable:内容区域是否可拖拽

这些 prop 涵盖了 FloatingPanel 组件的常见需求,并提供了一定的灵活性,可以满足不同场景下的使用要求。

同时,通过使用 makeXXXProp 等工具函数定义 prop,可以确保其类型的正确性。

总的来说,这部分的 props 设计是合理的。

src/uni_modules/wot-design-uni/components/wd-floating-panel/index.scss (4)

1-3: 代码看起来不错!

common/abstracts 目录导入 SCSS 变量和 mixins 是一个很好的做法,可以提高代码的复用性和可维护性。


4-12: 暗黑模式下的样式定义正确

代码片段正确地为暗黑模式下的浮动面板组件定义了样式:

  • 使用 .wot-theme-dark 类选择器包裹样式,表明这些样式特定于暗黑主题。
  • 将浮动面板及其内容的背景色设置为 $-dark-background2 变量。
  • 使用 @include b(floating-panel) mixin 生成组件的基类。
  • 使用 @include e(content) mixin 生成组件内容元素的类。

14-65: 浮动面板组件的主要样式定义正确

代码片段正确地定义了浮动面板组件的主要样式:

  • 使用 @include b(floating-panel) mixin 生成组件的基类。
  • 设置了浮动面板的定位、尺寸、背景色、圆角等属性。
  • 使用 @include when(safe) mixin 在面板底部添加安全区域的内边距。
  • 使用 &::after 伪元素创建了一个超出面板高度的背景色。
  • 使用 @include e(header) mixin 设置了面板头部的样式,包括头部栏。
  • 使用 @include e(content) mixin 设置了面板内容区域的样式。

62-63: 请确认是否需要设置面板内容的字体颜色

代码中注释掉的第 62 行表明开发者可能打算设置面板内容的字体颜色,但后来决定不这样做。请确认是否需要设置面板内容的字体颜色,如果不需要,可以删除注释掉的代码以保持代码的整洁。

src/pages/floatingPanel/Index.vue (3)

1-26: 模板部分看起来不错!

FloatingPanel 组件在不同的选项卡中以不同的配置进行了演示,覆盖了各种使用场景。组件的使用方式看起来是正确的。


28-52: 脚本部分实现得很好!

脚本部分导入了必要的依赖项,并定义了组件中使用的数据和方法。handleHeightChange 方法处理面板高度变化时的逻辑,onLoad 生命周期钩子用于初始化数据。代码逻辑和语法都没有明显的问题。


54-61: 样式部分没有问题!

样式部分为 FloatingPanel 的内容区定义了样式,包括内边距、文本对齐、字体大小和字重。样式很简单,没有明显的问题。

docs/component/floating-panel.md (5)

1-6: 介绍部分看起来不错!

介绍部分对 FloatingPanel 组件的用途和使用场景进行了清晰简洁的概述。内容没有明显问题。


7-22: 基本用法部分没有问题!

基本用法部分对组件的默认行为以及用户如何与之交互进行了清晰的说明。代码示例有助于理解组件的使用方法。内容没有明显问题。


23-58: 自定义锚点部分说明清晰!

自定义锚点部分对如何自定义锚点位置以及控制面板高度提供了清晰的说明。代码示例全面,包含了所有必要的部分。内容没有明显问题。


60-77: 仅头部拖拽部分说明清楚!

仅头部拖拽部分对如何禁用内容区域拖拽提供了清晰的说明。代码示例简单明了,包含了必要的部分。内容没有明显问题。


79-107: API 部分列举全面!

API 部分全面列出了组件的属性、插槽、事件和外部样式类。表格格式清晰易读。描述简洁且信息丰富。内容没有明显问题。

docs/.vitepress/config.mts (1)

329-331: 变更符合预期,没有问题!

新增的 FloatingPanel 组件条目的格式和位置都是正确的,与现有的组件条目保持一致。这个变更扩展了文档的覆盖范围,将 FloatingPanel 组件纳入其中。

src/uni_modules/wot-design-uni/components/common/util.ts (1)

731-733: 代码看起来不错!

该函数使用 reduce 方法遍历数组,并比较每个元素与目标值之间的绝对差值,以找到最接近目标值的元素。逻辑正确,实现简洁。JSDoc 注释也提供了清晰的函数说明。

src/pages.json (1)

825-833: LGTM!

新增的 "floatingPanel" 页面配置看起来不错:

  • 页面路径和名称一致,符合其他页面的命名约定。
  • 针对 "mp-alipay" 平台禁用垂直反弹与其他页面的配置一致。
  • 导航栏标题设置得当。
src/pages/index/Index.vue (1)

237-240: 改动没问题,不过请注意确保FloatingPanel组件的实现和文档都已就绪。

list数组中添加这个新的对象用于表示FloatingPanel组件本身是没有问题的。不过要注意确保该组件的实现代码、文档等其他相关改动也都完成并提交了。

可以运行下面的命令来检查FloatingPanel组件的实现和文档是否已经提交:

Verification successful

FloatingPanel组件已实现并有相应文档,但位置可能与预期不同。

经过验证,我们发现:

  • FloatingPanel组件的实现文件位于 src/uni_modules/wot-design-uni/components/wd-floating-panel/type.ts
  • 组件的文档存在于 docs/component/floating-panel.md
  • src/pages/index/Index.vue 文件中也包含了对FloatingPanel的引用

建议:

  • 检查 src/uni_modules/wot-design-uni/components/wd-floating-panel/ 目录下是否有完整的组件实现(如 .vue 文件)
  • 确保组件的实现与文档内容一致
  • 验证 Index.vue 中对FloatingPanel的使用是否正确
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查FloatingPanel组件的实现文件
fd -e vue -e js FloatingPanel src/components
# 检查FloatingPanel组件的文档
fd -e md FloatingPanel docs

Length of output: 76


Script:

#!/bin/bash
# 在整个src目录中搜索包含"FloatingPanel"的文件
echo "Searching for FloatingPanel in src directory:"
rg -l "FloatingPanel" src

# 在整个docs目录中搜索包含"FloatingPanel"的文件
echo "Searching for FloatingPanel in docs directory:"
rg -l "FloatingPanel" docs

# 列出src/components目录下的所有.vue和.js文件
echo "Listing all .vue and .js files in src/components:"
fd -e vue -e js . src/components

# 列出docs目录下的所有.md文件
echo "Listing all .md files in docs:"
fd -e md . docs

Length of output: 3024

src/uni_modules/wot-design-uni/components/common/abstracts/variable.scss (9)

948-948: 变量定义正确

$-floating-panel-bg 变量用于设置浮动面板的背景色,默认值 $-color-white 是一个合适的选择。


949-949: 变量定义正确

$-floating-panel-radius 变量用于设置浮动面板的圆角大小,默认值 16px 可以让面板呈现较为圆润的形状。


950-950: 变量定义正确

$-floating-panel-z-index 变量用于设置浮动面板的层级,默认值 99 可以让面板悬浮于其他内容之上。


951-951: 变量定义正确

$-floating-panel-header-height 变量用于设置浮动面板头部的高度,默认值 30px 是一个合理的高度。


952-952: 变量定义正确

$-floating-panel-bar-width 变量用于设置浮动面板 bar 的宽度,默认值 20px 可以让 bar 呈现合适的宽度。


953-953: 变量定义正确

$-floating-panel-bar-height 变量用于设置浮动面板 bar 的高度,默认值 3px 可以让 bar 呈现合适的高度。


954-954: 变量定义正确

$-floating-panel-bar-bg 变量用于设置浮动面板 bar 的背景色,默认值 $-color-gray-5 可以让 bar 呈现出灰色的外观。


955-955: 变量定义正确

$-floating-panel-bar-radius 变量用于设置浮动面板 bar 的圆角大小,默认值 4px 可以让 bar 呈现较为圆润的形状。


956-956: 变量定义正确

$-floating-panel-content-bg 变量用于设置浮动面板内容区的背景色,默认值 $-color-white 是一个合适的选择。

@Moonofweisheng Moonofweisheng merged commit e2966fd into Moonofweisheng:master Sep 24, 2024
@coderabbitai coderabbitai Bot mentioned this pull request Oct 30, 2024
19 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jan 11, 2025
19 tasks
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