From 2584262751de5553ee9c6e69b6263e28c1d0feff Mon Sep 17 00:00:00 2001 From: shleewhite Date: Mon, 26 Sep 2022 16:37:50 -0700 Subject: [PATCH] fix(chat-log): chatMessage/chatBubble hug contents --- .changeset/stupid-feet-press.md | 6 +++ .../__tests__/ChatMessageMeta.spec.tsx | 38 +++++++++---------- .../components/chat-log/src/ChatBubble.tsx | 8 ++-- .../components/chat-log/src/ChatLog.tsx | 2 +- .../components/chat-log/src/ChatMessage.tsx | 10 +++-- .../chat-log/src/ChatMessageMeta.tsx | 6 +-- .../chat-log/src/ChatMessageMetaItem.tsx | 1 - .../components/ChatMessageMeta.stories.tsx | 37 +++++++++++++++++- .../chat-log/stories/index.stories.tsx | 18 ++++----- .../src/component-examples/ChatLogExamples.ts | 22 ++++------- .../src/pages/components/chat-log/index.mdx | 17 +++++---- 11 files changed, 95 insertions(+), 70 deletions(-) create mode 100644 .changeset/stupid-feet-press.md diff --git a/.changeset/stupid-feet-press.md b/.changeset/stupid-feet-press.md new file mode 100644 index 0000000000..0693737528 --- /dev/null +++ b/.changeset/stupid-feet-press.md @@ -0,0 +1,6 @@ +--- +'@twilio-paste/chat-log': patch +'@twilio-paste/core': patch +--- + +[Chat Message] hug the width of the ChatMessage to the width of the message diff --git a/packages/paste-core/components/chat-log/__tests__/ChatMessageMeta.spec.tsx b/packages/paste-core/components/chat-log/__tests__/ChatMessageMeta.spec.tsx index 55c8548bc0..7a52c81d3f 100644 --- a/packages/paste-core/components/chat-log/__tests__/ChatMessageMeta.spec.tsx +++ b/packages/paste-core/components/chat-log/__tests__/ChatMessageMeta.spec.tsx @@ -71,32 +71,28 @@ describe('ChatMessageMeta', () => { expect(screen.getByTestId('test-meta')).toHaveAttribute('aria-label', 'said by Gibby Radki at 5:04pm'); }); - it('should have justifyContent flex-end if there is one child', () => { + it('should have justifyContent flex-start it is inbound and flex-end if it is outbound', () => { render( - - - 5:04pm - - - ); - expect(screen.getByTestId('test-meta')).toHaveStyleRule('justify-content', 'flex-end'); - }); - - it('should have justifyContent space-between if there is more than one child', () => { - render( - - - Gibby Radki - 5:04pm - - + <> + + + 5:04pm + + + + + 5:04pm + + + ); - expect(screen.getByTestId('test-meta')).toHaveStyleRule('justify-content', 'space-between'); + expect(screen.getByTestId('in-test-meta')).toHaveStyleRule('justify-content', 'flex-start'); + expect(screen.getByTestId('out-test-meta')).toHaveStyleRule('justify-content', 'flex-end'); }); - it('should have textAlign right if there is one child', () => { + it('should have textAlign right if it is outbound', () => { render( - + 5:04pm diff --git a/packages/paste-core/components/chat-log/src/ChatBubble.tsx b/packages/paste-core/components/chat-log/src/ChatBubble.tsx index aa55d2ba01..bddba00c43 100644 --- a/packages/paste-core/components/chat-log/src/ChatBubble.tsx +++ b/packages/paste-core/components/chat-log/src/ChatBubble.tsx @@ -12,15 +12,15 @@ export interface ChatBubbleProps { } const bubbleVariantStyles: { - [key in MessageVariants]: { - backgroundColor: BoxStyleProps['backgroundColor']; - }; + [key in MessageVariants]: BoxStyleProps; } = { inbound: { backgroundColor: 'colorBackground', + alignSelf: 'flex-start', }, outbound: { backgroundColor: 'colorBackgroundPrimaryWeakest', + alignSelf: 'flex-end', }, }; @@ -30,12 +30,12 @@ export const ChatBubble = React.forwardRef( return ( (({children, element = 'CHAT_LOG', ...props}, ref) => { return ( - + {children} diff --git a/packages/paste-core/components/chat-log/src/ChatMessage.tsx b/packages/paste-core/components/chat-log/src/ChatMessage.tsx index 7e9e643543..49855081bb 100644 --- a/packages/paste-core/components/chat-log/src/ChatMessage.tsx +++ b/packages/paste-core/components/chat-log/src/ChatMessage.tsx @@ -13,16 +13,15 @@ export interface ChatMessageProps { } const messageVariantStyles: { - [key in MessageVariants]: { - marginLeft?: BoxStyleProps['marginLeft']; - marginRight?: BoxStyleProps['marginRight']; - }; + [key in MessageVariants]: BoxStyleProps; } = { inbound: { marginRight: 'space70', + alignSelf: 'flex-start', }, outbound: { marginLeft: 'space70', + alignSelf: 'flex-end', }, }; @@ -34,6 +33,9 @@ export const ChatMessage = React.forwardRef( as="li" listStyleType="none" marginBottom="space80" + display="flex" + flexDirection="column" + rowGap="space30" ref={ref} element={element} variant={variant} diff --git a/packages/paste-core/components/chat-log/src/ChatMessageMeta.tsx b/packages/paste-core/components/chat-log/src/ChatMessageMeta.tsx index 01f61c2650..d5a2d8b475 100644 --- a/packages/paste-core/components/chat-log/src/ChatMessageMeta.tsx +++ b/packages/paste-core/components/chat-log/src/ChatMessageMeta.tsx @@ -15,15 +15,13 @@ export const ChatMessageMeta = React.forwardRef { const variant = React.useContext(MessageVariantContext); - const hasMultipleChildren = React.Children.count(children) > 1; - return ( {children} diff --git a/packages/paste-core/components/chat-log/stories/components/ChatMessageMeta.stories.tsx b/packages/paste-core/components/chat-log/stories/components/ChatMessageMeta.stories.tsx index 7a3c74d27b..773141fbb9 100644 --- a/packages/paste-core/components/chat-log/stories/components/ChatMessageMeta.stories.tsx +++ b/packages/paste-core/components/chat-log/stories/components/ChatMessageMeta.stories.tsx @@ -17,9 +17,8 @@ export const InboundMessageWithMeta: Story = () => ( - Gibby Radki + Gibby Radki ・ 4 minutes ago - 4 minutes ago @@ -40,3 +39,37 @@ export const OutboundMessageWithMeta: Story = () => ( ); + +export const MessageWithLongMeta: Story = () => ( + + + + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + + + + + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + + + + + + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + + + + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + + + + +); diff --git a/packages/paste-core/components/chat-log/stories/index.stories.tsx b/packages/paste-core/components/chat-log/stories/index.stories.tsx index 39a191bf89..4112821e02 100644 --- a/packages/paste-core/components/chat-log/stories/index.stories.tsx +++ b/packages/paste-core/components/chat-log/stories/index.stories.tsx @@ -81,13 +81,12 @@ export const ScrollingChatLog: Story = () => { - Gibby Radki + Gibby Radki ・ 4:30 PM - 4:30 PM - Lauren Gardner, Lee White, Loreina Chew have joined the chat ・4:31 PM + Lauren Gardner, Lee White, Loreina Chew have joined the chat ・ 4:31 PM Nulla sit amet elit mauris. @@ -112,8 +111,7 @@ export const ScrollingChatLog: Story = () => { Donec sit amet orci hendrerit, varius diam in, porttitor felis. - Gibby Radki - 5:04 PM + Gibby Radki ・ 5:04 PM @@ -165,19 +163,18 @@ export const KitchenSink: Story = () => ( - Lauren Gardner has joined the chat ・4:26 PM + Lauren Gardner has joined the chat ・ 4:26 PM - Gibby Radki sent transfer request to Technical Support Team ・3:42 PM + Gibby Radki sent transfer request to Technical Support Team ・ 3:42 PM Lorem ipsum dolor sit amet, consectetur adipiscing elit. - Gibby Radki + Gibby Radki ・ 4:30 PM - 4:30 PM @@ -209,8 +206,7 @@ export const KitchenSink: Story = () => ( Donec sit amet orci hendrerit, varius diam in, porttitor felis. - Gibby Radki - 5:04 PM + Gibby Radki ・ 5:04 PM diff --git a/packages/paste-website/src/component-examples/ChatLogExamples.ts b/packages/paste-website/src/component-examples/ChatLogExamples.ts index 32662c957c..932cfadda3 100644 --- a/packages/paste-website/src/component-examples/ChatLogExamples.ts +++ b/packages/paste-website/src/component-examples/ChatLogExamples.ts @@ -41,9 +41,8 @@ const MessageWithMeta = () => { - Gibby Radki + Gibby Radki ・ 4 minutes ago - 4 minutes ago @@ -131,9 +130,8 @@ const ComplexMessage = () => { - Gibby Radki + Gibby Radki ・ 11:27 AM - 11:27 AM @@ -177,7 +175,7 @@ const BasicChatEvent = () => { return ( - Gibby Radki has joined the chat・11:56 AM + Gibby Radki has joined the chat ・ 11:56 AM ); @@ -194,7 +192,7 @@ const ChatStartedBookend = () => { Today - Chat Started・3:34pm + Chat Started ・ 3:34pm @@ -226,9 +224,8 @@ const SampleChat = () => { - Gibby Radki + Gibby Radki ・ 3:35 PM - 3:35 PM @@ -252,9 +249,8 @@ const SampleChat = () => { - Gibby Radki + Gibby Radki ・ 3:37 PM - 3:37 PM @@ -286,9 +282,8 @@ const SampleChat = () => { - Gibby Radki + Gibby Radki ・ 11:29 AM - 11:29 AM @@ -298,9 +293,8 @@ const SampleChat = () => { - Gibby Radki + Gibby Radki ・ 11:36 AM - 11:36 AM diff --git a/packages/paste-website/src/pages/components/chat-log/index.mdx b/packages/paste-website/src/pages/components/chat-log/index.mdx index a394722400..bec0dcf2a2 100644 --- a/packages/paste-website/src/pages/components/chat-log/index.mdx +++ b/packages/paste-website/src/pages/components/chat-log/index.mdx @@ -108,9 +108,8 @@ export const pageQuery = graphql` - Gibby Radki + Gibby Radki ・ 3:35 PM - 3:35 PM @@ -345,8 +344,7 @@ export const Basic = () => { Ahoy! - Gibby Radki - 4 minutes ago + Gibby Radki ・ 4 minutes ago @@ -451,11 +449,14 @@ ChatAttachmentLink inherits the same props as [Anchor](/components/anchor) as we ### Figma - Chat Log components are not in the Paste Component Library yet + Figma usage guidelines coming soon - To find the Stage 1 components, see{' '} - - the Conversations UI Kit Figma file + You can find the Chat Log components in{' '} + + the Paste Components library .