Skip to content

Commit

Permalink
Update contributor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Oct 15, 2021
1 parent 74f2fd0 commit c9dd495
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions packages/components/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ This set of guidelines should apply especially to newly introduced components. I

For an example of a component that follows these requirements, take a look at [`ItemGroup`](/packages/components/src/item-group).

- [Compatibility](#compatibility)
- [Compound components](#compound-components)
- [Components & Hooks](#components--hooks)
- [TypeScript](#typescript)
- [Styling](#styling)
- [Context system](#context-system)
- [Unit tests](#unit-tests)
- [Storybook](#storybook)
- [Documentation](#documentation)
- [README example](#README-example)
- [Folder structure](#folder-structure)
- [Contributing](#contributing)
- [Compatibility](#compatibility)
- [Compound components](#compound-components)
- [Components & Hooks](#components--hooks)
- [TypeScript](#typescript)
- [Styling](#styling)
- [Context system](#context-system)
- [Unit tests](#unit-tests)
- [Storybook](#storybook)
- [Documentation](#documentation)
- [README example](#readme-example)
- [Props](#props)
- [`propName`: Typescript style type i.e `string`, `number`, `( nextValue: string ) => void`](#propname-typescript-style-type-ie-string-number--nextvalue-string---void)
- [Inherited props](#inherited-props)
- [Context](#context)

## Compatibility

Expand Down Expand Up @@ -277,14 +281,24 @@ import Button from '../';

export default { title: 'Components/Button', component: Button };

export const _default = () => <Button>Default Button</Button>;

export const primary = () => <Button variant="primary">Primary Button</Button>;

export const secondary = () => <Button variant="secondary">Secondary Button</Button>;
const Template = ( args ) => <Button { ...args } />;

export const Default = Template.bind( {} );
Default.args = {
text: 'Default Button',
isBusy: false,
isSmall: false,
};

export const Primary = Template.bind( {} );
Primary.args = {
...Default.args,
text: 'Primary Button',
variant: 'primary',
};
```

A great tool to use when writing stories is the [Storybook Controls addon](https://storybook.js.org/addons/@storybook/addon-controls). Ideally props should be exposed by using this addon, which provides a graphical UI to interact dynamically with the component without needing to write code.
A great tool to use when writing stories is the [Storybook Controls addon](https://storybook.js.org/addons/@storybook/addon-controls). Ideally props should be exposed by using this addon, which provides a graphical UI to interact dynamically with the component without needing to write code. Avoid using [Knobs](https://storybook.js.org/addons/@storybook/addon-knobs) for new stories, as this addon is deprecated.

The default value of each control should coincide with the default value of the props (i.e. it should be `undefined` if a prop is not required). A story should, therefore, also explicitly show how values from the Context System are applied to (sub)components. A good example of how this may look like is the [`Card` story](https://wordpress.github.io/gutenberg/?path=/story/components-card--default) (code [here](/packages/components/src/card/stories/index.js)).

Expand Down

0 comments on commit c9dd495

Please sign in to comment.