diff --git a/plugins/woocommerce-blocks/.eslintrc.js b/plugins/woocommerce-blocks/.eslintrc.js index 6dbbe97731a..5e1e4e1843c 100644 --- a/plugins/woocommerce-blocks/.eslintrc.js +++ b/plugins/woocommerce-blocks/.eslintrc.js @@ -124,6 +124,7 @@ module.exports = { extends: [ 'plugin:@woocommerce/eslint-plugin/recommended', 'plugin:you-dont-need-lodash-underscore/compatible', + 'plugin:storybook/recommended', ], globals: { wcBlocksMiddlewareConfig: 'readonly', diff --git a/plugins/woocommerce-blocks/assets/js/base/components/button/stories/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/button/stories/index.stories.tsx similarity index 94% rename from plugins/woocommerce-blocks/assets/js/base/components/button/stories/index.tsx rename to plugins/woocommerce-blocks/assets/js/base/components/button/stories/index.stories.tsx index ecf3c5242c5..f445dbdca86 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/button/stories/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/button/stories/index.stories.tsx @@ -10,7 +10,7 @@ import Button, { ButtonProps } from '..'; const availableTypes = [ 'button', 'input', 'submit' ]; export default { - title: 'WooCommerce Blocks/@base-components/Button', + title: 'Base Components/Button', argTypes: { children: { control: 'text', diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/coupon/stories/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/coupon/stories/index.stories.tsx similarity index 95% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/coupon/stories/index.tsx rename to plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/coupon/stories/index.stories.tsx index e5bae041855..4806602caf4 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/coupon/stories/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/coupon/stories/index.stories.tsx @@ -13,7 +13,7 @@ import { VALIDATION_STORE_KEY } from '@woocommerce/block-data'; import { TotalsCoupon, TotalsCouponProps } from '..'; export default { - title: 'WooCommerce Blocks/@base-components/cart-checkout/totals/Coupon', + title: 'Base Components/Totals/Coupon', component: TotalsCoupon, args: { initialOpen: true, diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/stories/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/stories/index.stories.tsx similarity index 97% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/stories/index.tsx rename to plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/stories/index.stories.tsx index 15525b95f57..7b274b27e72 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/stories/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/stories/index.stories.tsx @@ -67,7 +67,7 @@ function extractValuesFromCoupons( } export default { - title: 'WooCommerce Blocks/@base-components/cart-checkout/totals/Discount', + title: 'Base Components/Totals/Discount', component: Discount, argTypes: { currency: currencyControl, diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/footer-item/stories/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/footer-item/stories/index.stories.tsx similarity index 95% rename from plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/footer-item/stories/index.tsx rename to plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/footer-item/stories/index.stories.tsx index 80b05c092a4..6442babe6c7 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/footer-item/stories/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/footer-item/stories/index.stories.tsx @@ -21,7 +21,7 @@ const NZD: Currency = { }; export default { - title: 'WooCommerce Blocks/@base-components/cart-checkout/totals/FooterItem', + title: 'Base Components/Totals/FooterItem', component: FooterItem, args: { currency: NZD, diff --git a/plugins/woocommerce-blocks/assets/js/base/components/country-input/stories/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/country-input/stories/index.stories.tsx similarity index 96% rename from plugins/woocommerce-blocks/assets/js/base/components/country-input/stories/index.tsx rename to plugins/woocommerce-blocks/assets/js/base/components/country-input/stories/index.stories.tsx index 1818b52aa76..5afc34b79c2 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/country-input/stories/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/country-input/stories/index.stories.tsx @@ -15,7 +15,7 @@ import { countries } from './countries-filler'; type CountryCode = keyof typeof countries; export default { - title: 'WooCommerce Blocks/@base-components/CountryInput', + title: 'Base Components/CountryInput', component: CountryInput, args: { countries, diff --git a/plugins/woocommerce-blocks/assets/js/base/components/form-token-field/stories/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/form-token-field/stories/index.stories.tsx similarity index 92% rename from plugins/woocommerce-blocks/assets/js/base/components/form-token-field/stories/index.tsx rename to plugins/woocommerce-blocks/assets/js/base/components/form-token-field/stories/index.stories.tsx index b3e20e21461..00d66f6b7ec 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/form-token-field/stories/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/form-token-field/stories/index.stories.tsx @@ -10,7 +10,7 @@ import { useState } from '@wordpress/element'; import FormTokenField, { Props } from '..'; export default { - title: 'WooCommerce Blocks/@base-components/FormTokenField', + title: 'Base Components/FormTokenField', argTypes: {}, component: FormTokenField, } as Meta< Props >; diff --git a/plugins/woocommerce-blocks/assets/js/base/components/notice-banner/README.md b/plugins/woocommerce-blocks/assets/js/base/components/notice-banner/README.md deleted file mode 100644 index 9345d194672..00000000000 --- a/plugins/woocommerce-blocks/assets/js/base/components/notice-banner/README.md +++ /dev/null @@ -1,138 +0,0 @@ -# NoticeBanner Component - -An informational UI displayed near the top of the store pages. - -## Table of contents - -- [Design Guidelines](#design-guidelines) -- [Development Guidelines](#development-guidelines) - - [Usage](#usage) - - [Props](#props) - - [`children`: `React.ReactNode`](#children-reactreactnode) - - [`className`: `string`](#classname-string) - - [`isDismissible`: `boolean`](#isdismissible-boolean) - - [`onRemove`: `() => void`](#onremove---void) - - [`politeness`: `'polite' | 'assertive'`](#politeness-polite--assertive) - - [`spokenMessage`: `string`](#spokenmessage-string) - - [`status`: `'success' | 'error' | 'info' | 'warning' | 'default'`](#status-success--error--info--warning--default) - - [`summary`: `string`](#summary-string) - - [Example](#example) - -## Design Guidelines - -Notices are informational UI displayed near the top of store pages. Notices are used to indicate the result of an action, or to draw the user’s attention to necessary information. - -Notices are color-coded to indicate the type of message being communicated, and also show an icon to reinforce the meaning of the message. The color and icon used for a notice are determined by the `status` prop. - -### Informational - -Blue notices used for general information for buyers that are not blocking and do not require action. - -![Informational notice](./screenshots/info.png) - -### Error - -Red notices to show that an error has occurred and that the user needs to take action. - -![Error notice](./screenshots/error.png) - -### Success - -Green notices that show an action was successful. - -![Success notice](./screenshots/success.png) - -### Warning - -Yellow notices that show that the user may need to take action, or needs to be aware of something important. - -![Warning notice](./screenshots/warning.png) - -### Default - -Gray notice, similar to info, but used for less important messaging. - -![Default notice](./screenshots/default.png) - -## Development Guidelines - -### Usage - -To display a plain notice, pass the notice message as a string: - -```jsx -import { NoticeBanner } from '@woocommerce/base-components'; - -Your message here; -``` - -For more complex markup, you can pass any JSX element: - -```jsx -import { NoticeBanner } from '@woocommerce/base-components'; - - -

- An error occurred: { errorDetails }. -

-
; -``` - -### Props - -#### `children`: `React.ReactNode` - -The displayed message of a notice. Also used as the spoken message for assistive technology, unless `spokenMessage` is provided as an alternative message. - -#### `className`: `string` - -Additional class name to give to the notice. - -#### `isDismissible`: `boolean` - -Determines whether the notice can be dismissed by the user. When set to true, a close icon will be displayed on the banner. - -#### `onRemove`: `() => void` - -Function called when dismissing the notice. When the close icon is clicked or the Escape key is pressed, this function will be called. - -#### `politeness`: `'polite' | 'assertive'` - -Determines the level of politeness for the notice for assistive technology. Acceptable values are 'polite' and 'assertive'. Default is 'polite'. - -#### `spokenMessage`: `string` - -Optionally provided to change the spoken message for assistive technology. If not provided, the `children` prop will be used as the spoken message. - -#### `status`: `'success' | 'error' | 'info' | 'warning' | 'default'` - -Status determines the color of the notice and the icon. Acceptable values are `success`, `error`, `info`, `warning`, and `default`. - -#### `summary`: `string` - -Optional summary text shown above notice content, used when several notices are listed together. - -##### Example - -```tsx -import { NoticeBanner } from '@woocommerce/base-components'; - -const errorMessages = [ - 'First error message', - 'Second error message', - 'Third error message', -]; - - - -; -``` - -In this example, the summary prop is used to indicate to the user that there are errors in the form submission. The list of error messages is rendered within the NoticeBanner component using an unordered list (`