From 663494c045e89d6ffab036354ff870f58747b582 Mon Sep 17 00:00:00 2001 From: layitf <18884265057@163.com> Date: Sat, 4 Jan 2025 11:46:55 +0800 Subject: [PATCH 1/4] feat: Bubble support extra --- components/bubble/Bubble.tsx | 22 ++++++++++++++++++++ components/bubble/demo/header-and-footer.tsx | 10 ++++++++- components/bubble/index.en-US.md | 1 + components/bubble/index.zh-CN.md | 1 + components/bubble/interface.ts | 3 ++- components/bubble/style/index.ts | 13 ++++++++++++ 6 files changed, 48 insertions(+), 2 deletions(-) diff --git a/components/bubble/Bubble.tsx b/components/bubble/Bubble.tsx index 48285161..380943c4 100644 --- a/components/bubble/Bubble.tsx +++ b/components/bubble/Bubble.tsx @@ -40,6 +40,7 @@ const Bubble: React.ForwardRefRenderFunction = (props, r onTypingComplete, header, footer, + extra, ...otherHtmlProps } = props; @@ -142,6 +143,27 @@ const Bubble: React.ForwardRefRenderFunction = (props, r ); + if (extra) { + fullContent = ( +
+ {fullContent} +
+ {extra} +
+
+ ); + } + if (header || footer) { fullContent = (
diff --git a/components/bubble/demo/header-and-footer.tsx b/components/bubble/demo/header-and-footer.tsx index dd458c8b..f28f7a6c 100644 --- a/components/bubble/demo/header-and-footer.tsx +++ b/components/bubble/demo/header-and-footer.tsx @@ -1,4 +1,4 @@ -import { CopyOutlined, SyncOutlined, UserOutlined } from '@ant-design/icons'; +import { CopyOutlined, MoreOutlined, SyncOutlined, UserOutlined } from '@ant-design/icons'; import { Bubble } from '@ant-design/x'; import { Button, Space, theme } from 'antd'; import React from 'react'; @@ -17,6 +17,14 @@ const App: React.FC = () => {
- Hello, welcome to use Ant Design X! Just ask if you have any questions. +
+ Hello, welcome to use Ant Design X! Just ask if you have any questions. +
+
+ +
+ ); if (header || footer) { fullContent = ( diff --git a/components/bubble/style/index.ts b/components/bubble/style/index.ts index 8c58247c..d017a12e 100644 --- a/components/bubble/style/index.ts +++ b/components/bubble/style/index.ts @@ -101,19 +101,6 @@ const genBubbleStyle: GenerateStyle = (token) => { maxWidth: '100%', }, - [`& ${componentCls}-content-container`]: { - display: 'flex', - columnGap: token.paddingXS, - }, - - [`&-end ${componentCls}-content-container`]: { - flexDirection: 'row-reverse', - }, - - [`& ${componentCls}-extra`]: { - alignSelf: 'flex-end', - }, - [`& ${componentCls}-content`]: { position: 'relative', boxSizing: 'border-box', @@ -155,6 +142,19 @@ const genBubbleStyle: GenerateStyle = (token) => { }, }, }, + + [`& ${componentCls}-extra`]: { + position: 'absolute', + bottom: 0, + }, + + [`&-start ${componentCls}-extra`]: { + left: `calc(100% + ${token.paddingXS})`, + }, + + [`&-end ${componentCls}-extra`]: { + right: `calc(100% + ${token.paddingXS})`, + }, }, }; }; From 6b94a5d86e816b33d07ef4272171b6962a1d62f0 Mon Sep 17 00:00:00 2001 From: layitf <18884265057@163.com> Date: Wed, 8 Jan 2025 00:53:36 +0800 Subject: [PATCH 4/4] test: Update snapshot file --- .../__tests__/__snapshots__/demo-extend.test.ts.snap | 8 ++------ .../bubble/__tests__/__snapshots__/demo.test.ts.snap | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/components/bubble/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/bubble/__tests__/__snapshots__/demo-extend.test.ts.snap index e9c21814..edb7fa1b 100644 --- a/components/bubble/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/bubble/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -1050,13 +1050,9 @@ exports[`renders components/bubble/demo/header-and-footer.tsx extend context cor Ant Design X
-
- Hello, welcome to use Ant Design X! Just ask if you have any questions. -
+ Hello, welcome to use Ant Design X! Just ask if you have any questions.
diff --git a/components/bubble/__tests__/__snapshots__/demo.test.ts.snap b/components/bubble/__tests__/__snapshots__/demo.test.ts.snap index 01f3d8fb..6fbc594a 100644 --- a/components/bubble/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/bubble/__tests__/__snapshots__/demo.test.ts.snap @@ -1049,13 +1049,9 @@ exports[`renders components/bubble/demo/header-and-footer.tsx correctly 1`] = ` Ant Design X
-
- Hello, welcome to use Ant Design X! Just ask if you have any questions. -
+ Hello, welcome to use Ant Design X! Just ask if you have any questions.