diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69c7174fea19f..45c340220472f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -154,6 +154,10 @@ Documentation is automatically synced from master to the [Gutenberg Documentatio To add a new documentation page, you'll have to create a Markdown file in the [docs](https://github.com/WordPress/gutenberg/tree/master/docs) folder and add an item to the [manifest file](https://github.com/WordPress/gutenberg/blob/master/docs/manifest.json). +### `@wordpress/component` + +If you're contributing to the documentation of any component from the `@wordpress/component` package, take a look at its [guidelines for contributing](./packages/components/CONTRIBUTING.md). + ## Reporting Security Issues Please see [SECURITY.md](./SECURITY.md). diff --git a/packages/components/CONTRIBUTING.md b/packages/components/CONTRIBUTING.md new file mode 100644 index 0000000000000..cebec43084b1e --- /dev/null +++ b/packages/components/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +Thank you for taking the time to contribute. + +The following is a set of guidelines for contributing to the `@wordpress/components` package to be considered in addition to the general ones described in our [Contributing Policy](../../CONTRIBUTING.md). + +## Examples + +Each component needs to include an example in its README.md file to demonstrate the usage of the component. + +These examples can be consumed automatically from other projects in order to visualize them in their documentation. To ensure these examples are extractable, compilable and renderable, they should be structured in the following way: + +* It has to be included in a `jsx` code block. +* It has to work out-of-the-box. No additional code should be needed to have working the example. +* It has to define a React component called `My` which renders the example (i.e.: `MyButton`). Examples for the Higher Order Components should define a `MyComponent` component (i.e.: `MyComponentWithNotices`). diff --git a/packages/components/src/autocomplete/README.md b/packages/components/src/autocomplete/README.md index fe7a467dfd30b..1a14bf6323724 100644 --- a/packages/components/src/autocomplete/README.md +++ b/packages/components/src/autocomplete/README.md @@ -111,7 +111,7 @@ The following is a contrived completer for fresh fruit. ```jsx import { Autocomplete } from '@wordpress/components'; -function FreshFruitAutocomplete() { +const MyAutocomplete = () => { const autocompleters = [ { name: 'fruit', diff --git a/packages/components/src/base-control/README.md b/packages/components/src/base-control/README.md index 1dd091908176d..b79ee413e2190 100644 --- a/packages/components/src/base-control/README.md +++ b/packages/components/src/base-control/README.md @@ -9,19 +9,17 @@ Render a BaseControl for a textarea input: ```jsx import { BaseControl } from '@wordpress/components'; -function MyBaseControl() { - return ( - ( + +