Skip to content

Commit

Permalink
fix(media-object): add min-width to body
Browse files Browse the repository at this point in the history
When content in the media object body is very long, the content will
breakout of it's container if you don't set min-width:0 on the flex
child.

Also update the snapshots
  • Loading branch information
SiTaggart committed Mar 28, 2020
1 parent 3f6d496 commit 5281863
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
Expand Up @@ -17,10 +17,10 @@ exports[`MediaBody should render 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
min-width: 0;
}
<div
Expand Down Expand Up @@ -51,10 +51,10 @@ exports[`MediaBody should render as any HTML element 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
min-width: 0;
}
<div
Expand Down Expand Up @@ -85,7 +85,6 @@ exports[`MediaFigure should render 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -125,7 +124,6 @@ exports[`MediaFigure should render as any HTML element 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -165,7 +163,6 @@ exports[`MediaFigure should render with spacing on the left for end alignment 1`
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -205,7 +202,6 @@ exports[`MediaFigure should render with spacing on the right for default alignme
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -245,7 +241,6 @@ exports[`MediaObject should render 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -285,7 +280,6 @@ exports[`MediaObject should render as another HTML element 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -325,7 +319,6 @@ exports[`MediaObject should render bottom margin 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -366,7 +359,6 @@ exports[`MediaObject should render top margin 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -407,7 +399,6 @@ exports[`MediaObject should render with center aligned children 1`] = `
.emotion-0 {
box-sizing: border-box;
min-width: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/layout/media-object/src/index.tsx
Expand Up @@ -69,7 +69,7 @@ export type MediaBodyProps = Pick<BoxProps, 'as'>;

const MediaBody: React.FC<MediaBodyProps> = ({as = 'span', children}) => {
return (
<Box as={as} flex={1}>
<Box as={as} flex={1} minWidth="size0">
{children}
</Box>
);
Expand Down
21 changes: 21 additions & 0 deletions packages/paste-core/layout/media-object/stories/index.stories.tsx
Expand Up @@ -3,6 +3,7 @@ import {storiesOf} from '@storybook/react';
import {withKnobs, select, text} from '@storybook/addon-knobs';
import {Text} from '@twilio-paste/text';
import {Box} from '@twilio-paste/box';
import {Truncate} from '@twilio-paste/truncate';
import {DefaultTheme, ThemeShape} from '@twilio-paste/theme';
import {MediaObject, MediaFigure, MediaBody} from '../src';

Expand Down Expand Up @@ -62,4 +63,24 @@ storiesOf('Layout|Media Object', module)
</MediaFigure>
</MediaObject>
);
})
.add('Constrained width', () => {
return (
<Box width="size60">
<MediaObject as="div" verticalAlign="center">
<MediaFigure as="div" spacing="space100">
<Box backgroundColor="colorBackgroundSuccess" size="size20" />
</MediaFigure>
<MediaBody as="div">
<Text as="p">Some media Object body text</Text>
<Text as="p">
<Truncate>http://www.extremelylongurlthatmightbreakthelayout.com</Truncate>
</Text>
</MediaBody>
<MediaFigure as="div" align="end" spacing="space70">
<Box backgroundColor="colorBackgroundSuccess" height="size10" minWidth="size10" />
</MediaFigure>
</MediaObject>
</Box>
);
});

1 comment on commit 5281863

@vercel
Copy link

@vercel vercel bot commented on 5281863 Mar 28, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.