From 5b81cbc66c5d52f9603f77a60ec7864150173dd0 Mon Sep 17 00:00:00 2001 From: Miguel Torres Date: Wed, 8 Aug 2018 09:39:43 +0200 Subject: [PATCH] Add components examples in README.md files - Part 2 (#8338) * Components examples: Modal * Components examples: Modal * Components examples assigned to const variables * Components examples: Notice * Components examples: Panel * Components examples: Placeholder * Components examples: Popover * Components examples: QueryControls * Components examples: RadioControl * Components examples: RangeControl * Components examples: ResponsiveWrapper * Components examples: SandBox * Components examples: ScrollLock * Components examples: SelectControl * Components examples: ServerSideRender * Add metadata using YAML front matter so examples can be extracted dynamically * Add metadata using YAML front matter so examples can be extracted dynamically * Remove YAML front matter * Components examples: SlotFill * Components examples: Spinner * Components examples: TabPanel * Components examples: TextControl * Components examples: TextareaControl * Components examples: ToggleControl * Components examples: Toolbar * Components examples: Tooltip * Components examples: TreeSelect * Components examples: NavigableContainer * Components examples: navigateRegions * Components examples: withConstrainedTabbing * Components examples: withContext * Components examples: withFallbackStyles * Components examples: withFilters * Components examples: withFocusOutside * Components examples: withFocusReturn * Components examples: withNotices * Components examples: withSpokenMessages * Components examples: withAPIData * Contributing guidelines for the components * Contributing guidelines for the components * Contributing guidelines for the components * Add dummy attributes to ServerSideRender example --- CONTRIBUTING.md | 4 + packages/components/CONTRIBUTING.md | 15 ++++ .../components/src/autocomplete/README.md | 2 +- .../components/src/base-control/README.md | 22 +++-- .../components/src/button-group/README.md | 14 ++-- packages/components/src/button/README.md | 12 ++- .../components/src/checkbox-control/README.md | 4 +- .../components/src/clipboard-button/README.md | 2 +- .../components/src/color-indicator/README.md | 8 +- .../components/src/color-palette/README.md | 6 +- packages/components/src/dashicon/README.md | 16 ++-- packages/components/src/date-time/README.md | 10 ++- packages/components/src/disabled/README.md | 4 +- packages/components/src/draggable/README.md | 30 ++++--- packages/components/src/drop-zone/README.md | 2 +- .../components/src/dropdown-menu/README.md | 58 +++++++------ packages/components/src/dropdown/README.md | 36 ++++---- .../components/src/external-link/README.md | 8 +- .../components/src/focusable-iframe/README.md | 14 ++-- .../components/src/font-size-picker/README.md | 2 +- .../components/src/form-file-upload/README.md | 18 ++-- packages/components/src/form-toggle/README.md | 4 +- .../components/src/form-token-field/README.md | 4 +- .../higher-order/navigate-regions/README.md | 12 +-- .../src/higher-order/with-api-data/README.md | 51 +++++++++-- .../with-constrained-tabbing/README.md | 34 ++++++++ .../src/higher-order/with-context/README.md | 37 ++++++-- .../with-fallback-styles/README.md | 25 ++++++ .../src/higher-order/with-filters/README.md | 26 +++--- .../higher-order/with-focus-outside/README.md | 12 +-- .../higher-order/with-focus-return/README.md | 41 +++++++++ .../src/higher-order/with-notices/README.md | 19 +++++ .../with-spoken-messages/README.md | 14 ++++ packages/components/src/icon-button/README.md | 14 ++-- .../src/keyboard-shortcuts/README.md | 2 +- packages/components/src/menu-group/README.md | 14 ++-- packages/components/src/menu-item/README.md | 2 +- .../src/menu-items-choice/README.md | 4 +- packages/components/src/modal/README.md | 84 +++++-------------- .../src/navigable-container/README.md | 52 +++++------- packages/components/src/notice/README.md | 19 +++-- packages/components/src/panel/README.md | 13 +++ packages/components/src/placeholder/README.md | 13 +++ packages/components/src/popover/README.md | 23 ++--- .../components/src/query-controls/README.md | 42 ++++++++++ .../components/src/radio-control/README.md | 30 ++++--- .../components/src/range-control/README.md | 12 ++- .../src/responsive-wrapper/README.md | 16 ++++ packages/components/src/sandbox/README.md | 23 ++--- packages/components/src/scroll-lock/README.md | 20 +++-- .../components/src/select-control/README.md | 23 +++-- .../src/server-side-render/README.md | 12 ++- packages/components/src/slot-fill/README.md | 59 +++++++------ packages/components/src/spinner/README.md | 11 +++ packages/components/src/tab-panel/README.md | 48 +++++------ .../components/src/text-control/README.md | 15 +++- .../components/src/textarea-control/README.md | 23 +++-- .../components/src/toggle-control/README.md | 18 ++-- packages/components/src/toolbar/README.md | 25 ++++++ packages/components/src/tooltip/README.md | 23 +++-- packages/components/src/tree-select/README.md | 14 +++- 61 files changed, 768 insertions(+), 452 deletions(-) create mode 100644 packages/components/CONTRIBUTING.md create mode 100644 packages/components/src/higher-order/with-fallback-styles/README.md create mode 100644 packages/components/src/higher-order/with-focus-return/README.md create mode 100644 packages/components/src/higher-order/with-notices/README.md create mode 100644 packages/components/src/higher-order/with-spoken-messages/README.md create mode 100644 packages/components/src/panel/README.md create mode 100644 packages/components/src/placeholder/README.md create mode 100644 packages/components/src/query-controls/README.md create mode 100644 packages/components/src/responsive-wrapper/README.md create mode 100644 packages/components/src/spinner/README.md create mode 100644 packages/components/src/toolbar/README.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69c7174fea19fd..45c340220472f6 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 00000000000000..cebec43084b1ee --- /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 fe7a467dfd30ba..1a14bf63237245 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 1dd091908176d1..b79ee413e21905 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 ( - ( + +