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: migrate Storybook to controls, refactor to TypeScript #46945

Merged
merged 10 commits into from
Jan 9, 2023
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `ColorPicker` & `QueryControls`: Replace bottom margin overrides with `__nextHasNoMarginBottom` ([#46448](https://github.com/WordPress/gutenberg/pull/46448)).
- `SandBox`: Convert to TypeScript ([#46478](https://github.com/WordPress/gutenberg/pull/46478)).
- `ResponsiveWrapper`: Convert to TypeScript ([#46480](https://github.com/WordPress/gutenberg/pull/46480)).
- `ItemGroup`: migrate Storybook to controls, refactor to TypeScript ([46945](https://github.com/WordPress/gutenberg/pull/46945)).

### Bug Fix

Expand Down
27 changes: 25 additions & 2 deletions packages/components/src/item-group/item-group/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ItemGroupContext, useItemGroupContext } from '../context';
import { View } from '../../view';
import type { ItemGroupProps } from '../types';

function ItemGroup(
function UnconnectedItemGroup(
props: WordPressComponentProps< ItemGroupProps, 'div' >,
forwardedRef: ForwardedRef< any >
) {
Expand Down Expand Up @@ -40,4 +40,27 @@ function ItemGroup(
);
}

export default contextConnect( ItemGroup, 'ItemGroup' );
/**
* `ItemGroup` displays a list of `Item`s grouped and styled together.
*
* @example
* ```jsx
* import {
* __experimentalItemGroup as ItemGroup,
* __experimentalItem as Item,
* } from '@wordpress/components';
*
* function Example() {
* return (
* <ItemGroup>
* <Item>Code</Item>
* <Item>is</Item>
* <Item>Poetry</Item>
* </ItemGroup>
* );
* }
* ```
*/
export const ItemGroup = contextConnect( UnconnectedItemGroup, 'ItemGroup' );

export default ItemGroup;
28 changes: 26 additions & 2 deletions packages/components/src/item-group/item/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useItem } from './hook';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import { View } from '../../view';

function Item(
function UnconnectedItem(
props: WordPressComponentProps< ItemProps, 'div' >,
forwardedRef: ForwardedRef< any >
) {
Expand All @@ -24,4 +24,28 @@ function Item(
);
}

export default contextConnect( Item, 'Item' );
/**
* `Item` is used in combination with `ItemGroup` to display a list of items
* grouped and styled together.
*
* @example
* ```jsx
* import {
* __experimentalItemGroup as ItemGroup,
* __experimentalItem as Item,
* } from '@wordpress/components';
*
* function Example() {
* return (
* <ItemGroup>
* <Item>Code</Item>
* <Item>is</Item>
* <Item>Poetry</Item>
* </ItemGroup>
* );
* }
* ```
*/
export const Item = contextConnect( UnconnectedItem, 'Item' );

export default Item;
270 changes: 0 additions & 270 deletions packages/components/src/item-group/stories/index.js

This file was deleted.

Loading