-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grid: Convert component to TypeScript (#41923)
* Grid: Convert component to TypeScript * Update CHANGELOG.md * Add `columnGap` to readme * Sort props * Update types * Apply suggestions from code review Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Move changelog entry to unreleased section Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
- Loading branch information
1 parent
24acf99
commit 4b4d709
Showing
11 changed files
with
154 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { View } from '../../view'; | ||
import { Grid } from '..'; | ||
|
||
const meta: ComponentMeta< typeof Grid > = { | ||
component: Grid, | ||
title: 'Components (Experimental)/Grid', | ||
argTypes: { | ||
as: { control: { type: 'text' } }, | ||
align: { control: { type: 'text' } }, | ||
children: { control: { type: null } }, | ||
columnGap: { control: { type: 'text' } }, | ||
columns: { | ||
table: { type: { summary: 'number' } }, | ||
control: { type: 'number' }, | ||
}, | ||
justify: { control: { type: 'text' } }, | ||
rowGap: { control: { type: 'text' } }, | ||
rows: { | ||
table: { type: { summary: 'number' } }, | ||
control: { type: 'number' }, | ||
}, | ||
templateColumns: { control: { type: 'text' } }, | ||
templateRows: { control: { type: 'text' } }, | ||
}, | ||
parameters: { | ||
controls: { | ||
expanded: true, | ||
}, | ||
docs: { source: { state: 'open' } }, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
const Item = ( props: { children: string } ) => ( | ||
<View | ||
style={ { | ||
borderRadius: 8, | ||
background: '#eee', | ||
padding: 8, | ||
textAlign: 'center', | ||
} } | ||
{ ...props } | ||
/> | ||
); | ||
|
||
const Template: ComponentStory< typeof Grid > = ( props ) => ( | ||
<Grid { ...props }> | ||
<Item>One</Item> | ||
<Item>Two</Item> | ||
<Item>Three</Item> | ||
<Item>Four</Item> | ||
<Item>Five</Item> | ||
<Item>Six</Item> | ||
<Item>Seven</Item> | ||
<Item>Eight</Item> | ||
</Grid> | ||
); | ||
|
||
export const Default: ComponentStory< typeof Grid > = Template.bind( {} ); | ||
Default.args = { | ||
alignment: 'bottom', | ||
columns: 4, | ||
gap: 2, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.