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: support loadingRender & rm useless margin #165

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Oct 23, 2024

效果:

截屏2024-10-23 15 52 53

Summary by CodeRabbit

  • 新功能

    • Bubble 组件中添加了可选的 loadingRender 属性,允许在加载状态下自定义渲染内容。
    • 引入了新的 bubble-custom.tsx 组件,展示了可定制的聊天界面。
  • 文档

    • 更新了 bubble-custom.md 文件,增加了中英文示例,增强了多语言支持。
    • index.en-US.mdindex.zh-CN.md 中添加了关于 loadingRender 属性的详细说明和示例代码。
  • 样式

    • 精简了 BubbleToken 接口,移除了 bubbleContentMaxWidth 属性。

Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

📝 Walkthrough

Walkthrough

此次更改为Bubble组件引入了一个新的可选属性loadingRender,允许在加载状态下自定义渲染内容。通过引入contentNode变量,管理加载状态下的渲染逻辑,简化了代码结构。此外,相关文档也进行了更新,增加了中英文示例,展示如何使用该新属性进行自定义。整体组件结构保持不变,未影响现有功能。

Changes

文件路径 更改摘要
components/bubble/Bubble.tsx 添加loadingRender属性;引入contentNode变量以管理加载状态渲染逻辑;更新fullContent变量。
components/bubble/interface.ts 添加loadingRender?: () => React.ReactNodeBubbleProps接口。
components/bubble/demo/bubble-custom.md 新增中英文部分,提供自定义气泡效果示例的简要描述。
components/bubble/demo/bubble-custom.tsx 新增bubble-custom.tsx文件,创建可自定义的聊天界面,包含加载状态和消息示例。
components/bubble/index.en-US.md 更新文档,新增“语义化自定义”示例;更新messageRender属性描述;新增loadingRender属性。
components/bubble/index.zh-CN.md 新增自定义气泡实现示例;新增loadingRender属性。
components/bubble/style/index.ts 更新BubbleToken接口,移除bubbleContentMaxWidth属性,简化样式准备过程。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Bubble
    participant LoadingComponent

    User->>Bubble: 触发加载
    Bubble->>Bubble: 设置loading为true
    Bubble->>Bubble: 判断loadingRender是否存在
    alt loadingRender存在
        Bubble->>Bubble: 使用loadingRender渲染内容
    else loadingRender不存在
        Bubble->>LoadingComponent: 渲染默认Loading组件
    end
Loading

🐰 在气泡中跳跃,加载不再烦恼,
自定义渲染,轻松又美好。
文档更新,示例齐全,
让开发者们欢声笑语连连!
🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0214fc6 and 20ef2d0.

📒 Files selected for processing (7)
  • components/bubble/Bubble.tsx (3 hunks)
  • components/bubble/demo/bubble-custom.md (1 hunks)
  • components/bubble/demo/bubble-custom.tsx (1 hunks)
  • components/bubble/index.en-US.md (2 hunks)
  • components/bubble/index.zh-CN.md (2 hunks)
  • components/bubble/interface.ts (1 hunks)
  • components/bubble/style/index.ts (2 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 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

github-actions bot commented Oct 23, 2024

Preview is ready

Copy link

cloudflare-workers-and-pages bot commented Oct 23, 2024

Deploying ant-design-x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 461ee5f
Status: ✅  Deploy successful!
Preview URL: https://607e8c67.ant-design-x.pages.dev
Branch Preview URL: https://rm-avatar-margin.ant-design-x.pages.dev

View logs

if (loading) {
contentNode = loadingRender ? loadingRender() : <Loading prefixCls={prefixCls} />;
} else {
contentNode = mergedContent as React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

最好别 as

Copy link
Member Author

Choose a reason for hiding this comment

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

mergedContent 上面跑完是 ReactNode,但是 TS 自己推断不出来,还会把 object 作为其中之一的类型。

Copy link
Collaborator

@YumoImer YumoImer left a comment

Choose a reason for hiding this comment

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

+1

@zombieJ zombieJ merged commit bf81cdd into main Oct 23, 2024
9 checks passed
@zombieJ zombieJ deleted the rm-avatar-margin branch October 23, 2024 09:55
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.

3 participants