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

ItemGroup: add story showcasing more complex layouts #34708

Merged
merged 2 commits into from
Sep 13, 2021
Merged
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
92 changes: 90 additions & 2 deletions packages/components/src/item-group/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@
import { boolean, select } from '@storybook/addon-knobs';

/**
* Internal dependencies
* WordPress dependencies
*/
import { typography } from '@wordpress/icons';

/**
* Internal dependencies
*/
import { ItemGroup, Item } from '..';
import { Flyout } from '../../flyout';
import Button from '../../button';
import { FlexItem, FlexBlock } from '../../flex';
import { Flyout } from '../../flyout';
import { HStack } from '../../h-stack';
import Icon from '../../icon';
import { Text } from '../../text';
import { Truncate } from '../../truncate';
import { ZStack } from '../../z-stack';

export default {
component: ItemGroup,
Expand Down Expand Up @@ -97,4 +105,84 @@ export const dropdown = () => (
</ItemGroup>
</Flyout>
);

export const SimpleColorSwatch = ( { color, style } ) => (
<div
style={ {
...style,
borderRadius: '50%',
border: '1px solid rgba(0, 0, 0, 0.2)',
width: '24px',
height: '24px',
backgroundColor: color,
} }
/>
);

export const complexLayouts = () => {
const colors = [
{
color: '#00A19D',
id: 'teal',
},
{
color: '#FFF8E5',
id: 'cream',
},
{
color: '#FFB344',
id: 'yellow',
},
{
color: '#E05D5D',
id: 'red',
},
];

return (
<ItemGroup isBordered isSeparated style={ { width: '250px' } }>
<Item isAction onClick={ () => alert( 'Color palette' ) }>
<HStack>
<FlexBlock>
<ZStack isLayered={ false } offset={ -8 }>
{ colors.map( ( { color, id } ) => (
<SimpleColorSwatch key={ id } color={ color } />
) ) }
</ZStack>
</FlexBlock>
<FlexItem as={ Text } variant="muted">
23 colors
</FlexItem>
</HStack>
</Item>

<Item isAction onClick={ () => alert( 'Single color setting' ) }>
<HStack justify="flex-start">
<FlexItem
as={ SimpleColorSwatch }
color="#22577A"
style={ { flexShrink: 0 } }
/>
<FlexItem as={ Truncate }>
Single color setting with very long description
</FlexItem>
</HStack>
</Item>

<Item
isAction
onClick={ () => alert( 'Single typography setting' ) }
>
<HStack justify="flex-start">
<FlexItem>
<Icon icon={ typography } size={ 24 } />
</FlexItem>
<FlexItem as={ Truncate }>
Single typography setting
</FlexItem>
</HStack>
</Item>
</ItemGroup>
);
};
/* eslint-enable no-alert */