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

fix(disclosure): remove wrapping box around heading content #1487

Merged
merged 2 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/beige-icons-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/disclosure': patch
'@twilio-paste/core': patch
---

DisclosureHeading now gracefully handles children and doesn't impose flex behavior. This makes it easier to pass MediaObjects and Truncate as children.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ const StyledDisclosureHeading = React.forwardRef<HTMLDivElement, StyledDisclosur
size={IconSizeFromHeading[variant] || 'sizeIcon20'}
/>
</Box>
<Box display="flex" flexGrow={1} minWidth="0px">
{children}
</Box>
{children}
</Box>
</Heading>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {Box} from '@twilio-paste/box';
import {Stack} from '@twilio-paste/stack';
import {Truncate} from '@twilio-paste/truncate';
import {Paragraph} from '@twilio-paste/paragraph';
import {ProductInternetOfThingsIcon} from '@twilio-paste/icons/esm/ProductInternetOfThingsIcon';
import {MediaObject, MediaBody, MediaFigure} from '@twilio-paste/media-object';
import {Disclosure, DisclosureContent, DisclosureHeading, useDisclosureState} from '../src';
import type {DisclosureHeadingProps, DisclosureInitialState, DisclosureStateReturn, DisclosureVariants} from '../src';

Expand Down Expand Up @@ -178,6 +180,33 @@ TruncatedHeader.story = {
name: 'Truncated Header',
};

export const MediaObjectHeading = (): React.ReactNode => {
return (
<Disclosure variant="contained">
<DisclosureHeading as="h2" variant="heading30">
<Box width="100%">
<MediaObject verticalAlign="center">
<MediaFigure spacing="space10">
<ProductInternetOfThingsIcon decorative={false} title="phone numbers" size="sizeIcon40" />
</MediaFigure>
<MediaBody as="div">
<Box display="flex" justifyContent="space-between" flexWrap="wrap">
<Box>Internet of Things</Box>
<Box>$808</Box>
</Box>
</MediaBody>
</MediaObject>
</Box>
</DisclosureHeading>
<DisclosureContent>It works!</DisclosureContent>
</Disclosure>
);
};

MediaObjectHeading.story = {
name: 'MediaObject in Heading',
};

export const ContainedHeadingVariant10 = (): React.ReactNode => {
return <ExampleDisclosures headingVariant="heading10" variant="contained" />;
};
Expand Down