diff --git a/.changeset/gold-apples-own.md b/.changeset/gold-apples-own.md new file mode 100644 index 0000000000..606ca84a2b --- /dev/null +++ b/.changeset/gold-apples-own.md @@ -0,0 +1,6 @@ +--- +'@twilio-paste/avatar': patch +'@twilio-paste/core': patch +--- + +[Avatar] add flexShrink 0 so it stays the correct size in a flex layout diff --git a/.changeset/stupid-feet-press.md b/.changeset/stupid-feet-press.md new file mode 100644 index 0000000000..7b1fa5c50d --- /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 ChatBubble to the width of the message diff --git a/packages/paste-core/components/avatar/__tests__/__snapshots__/avatar.test.tsx.snap b/packages/paste-core/components/avatar/__tests__/__snapshots__/avatar.test.tsx.snap index 6021cced12..6dd759793f 100644 --- a/packages/paste-core/components/avatar/__tests__/__snapshots__/avatar.test.tsx.snap +++ b/packages/paste-core/components/avatar/__tests__/__snapshots__/avatar.test.tsx.snap @@ -6,6 +6,9 @@ exports[`Avatar image should render responsive css with an image 1`] = ` box-sizing: border-box; overflow: hidden; text-align: center; + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; width: sizeIcon30; height: sizeIcon30; background-color: colorBackgroundUser; @@ -69,6 +72,9 @@ exports[`Avatar intials should render responsive css 1`] = ` box-sizing: border-box; overflow: hidden; text-align: center; + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; width: sizeIcon10; height: sizeIcon10; background-color: colorBackgroundUser; diff --git a/packages/paste-core/components/avatar/src/index.tsx b/packages/paste-core/components/avatar/src/index.tsx index 2779a17d9a..ddf7196cb3 100644 --- a/packages/paste-core/components/avatar/src/index.tsx +++ b/packages/paste-core/components/avatar/src/index.tsx @@ -90,6 +90,7 @@ const Avatar = React.forwardRef( element={element} overflow="hidden" textAlign="center" + flexShrink={0} ref={ref} size={size} {...colorVariants[color]} 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..9b34d8cd94 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,6 +30,7 @@ export const ChatBubble = React.forwardRef( return ( ( as="li" listStyleType="none" marginBottom="space80" + display="flex" + flexDirection="column" 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 .