From cd347163707dc3f493a98e3d6fd1e94484aabc62 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Fri, 18 Oct 2019 23:03:24 +0200 Subject: [PATCH] Storybook: Apply a set of enhancements to the existing stories --- .../components/src/animate/stories/index.js | 17 +++++--- .../src/button-group/stories/index.js | 5 ++- .../components/src/button/stories/index.js | 34 ++++++++++----- .../src/checkbox-control/stories/index.js | 5 ++- .../src/clipboard-button/stories/index.js | 5 ++- .../src/color-indicator/stories/index.js | 1 + .../components/src/dashicon/stories/index.js | 5 ++- .../src/icon-button/stories/index.js | 24 +++++++++-- packages/components/src/icon/stories/index.js | 39 +++++++++++------ .../src/scroll-lock/stories/index.js | 43 +++++++++---------- 10 files changed, 119 insertions(+), 59 deletions(-) diff --git a/packages/components/src/animate/stories/index.js b/packages/components/src/animate/stories/index.js index 84227837e7a3ff..7cd8d58d2cf548 100644 --- a/packages/components/src/animate/stories/index.js +++ b/packages/components/src/animate/stories/index.js @@ -4,7 +4,10 @@ import Animate from '../'; import Notice from '../../notice'; -export default { title: 'Animate', component: Animate }; +export default { + title: 'Animate', + component: Animate, +}; export const _default = () => ( @@ -30,12 +33,12 @@ const Appear = ( { origin } ) => ( ); -export const appearTopLeft = () => ; -export const appearTopRight = () => ; -export const appearBottomLeft = () => ; -export const appearBottomRight = () => ; +export const AppearTopLeft = () => ; +export const AppearTopRight = () => ; +export const AppearBottomLeft = () => ; +export const AppearBottomRight = () => ; -export const loading = () => ( +export const Loading = () => ( { ( { className } ) => ( @@ -45,7 +48,7 @@ export const loading = () => ( ); -export const slideIn = () => ( +export const SlideIn = () => ( { ( { className } ) => ( diff --git a/packages/components/src/button-group/stories/index.js b/packages/components/src/button-group/stories/index.js index 1e1646e0268d15..413fea8132ecca 100644 --- a/packages/components/src/button-group/stories/index.js +++ b/packages/components/src/button-group/stories/index.js @@ -4,7 +4,10 @@ import Button from '../../button'; import ButtonGroup from '../'; -export default { title: 'Button Group', component: ButtonGroup }; +export default { + title: 'Button Group', + component: ButtonGroup, +}; export const _default = () => { const style = { margin: '0 4px' }; diff --git a/packages/components/src/button/stories/index.js b/packages/components/src/button/stories/index.js index ae949a1cd72906..dc86a6a3eb83b0 100644 --- a/packages/components/src/button/stories/index.js +++ b/packages/components/src/button/stories/index.js @@ -1,35 +1,49 @@ +/** + * External dependencies + */ +import { text } from '@storybook/addon-knobs'; + /** * Internal dependencies */ import Button from '../'; -export default { title: 'Button', component: Button }; +export default { + title: 'Button', + component: Button, +}; + +export const _default = () => { + const label = text( 'Label', 'Hello Button' ); -export const _default = () => ; + return ( + + ); +}; -export const primary = () => ; +export const Primary = () => ; -export const large = () => ; +export const Large = () => ; -export const largePrimary = () => ( +export const LargeAndPrimary = () => ( ); -export const small = () => ; +export const Small = () => ; -export const toggled = () => ; +export const Toggled = () => ; -export const disabled = () => ; +export const Disabled = () => ; -export const link = () => ( +export const Link = () => ( ); -export const disabledLink = () => ( +export const DisabledLink = () => ( diff --git a/packages/components/src/checkbox-control/stories/index.js b/packages/components/src/checkbox-control/stories/index.js index 184abbfe8b1614..2e9690ca4452c2 100644 --- a/packages/components/src/checkbox-control/stories/index.js +++ b/packages/components/src/checkbox-control/stories/index.js @@ -13,7 +13,10 @@ import { useState } from '@wordpress/element'; */ import CheckboxControl from '../'; -export default { title: 'Checkbox Control', component: CheckboxControl }; +export default { + title: 'CheckboxControl', + component: CheckboxControl, +}; export const _default = () => { const [ isChecked, setChecked ] = useState( true ); diff --git a/packages/components/src/clipboard-button/stories/index.js b/packages/components/src/clipboard-button/stories/index.js index 25632614eb249d..7fb2bbea5e8c25 100644 --- a/packages/components/src/clipboard-button/stories/index.js +++ b/packages/components/src/clipboard-button/stories/index.js @@ -8,7 +8,10 @@ import { useState } from '@wordpress/element'; */ import ClipboardButton from '../'; -export default { title: 'Clipboard Button', component: ClipboardButton }; +export default { + title: 'ClipboardButton', + component: ClipboardButton, +}; export const _default = () => { const [ copied, setCopied ] = useState( false ); diff --git a/packages/components/src/color-indicator/stories/index.js b/packages/components/src/color-indicator/stories/index.js index d14f180abbe25a..12f773c3eec1f1 100644 --- a/packages/components/src/color-indicator/stories/index.js +++ b/packages/components/src/color-indicator/stories/index.js @@ -15,6 +15,7 @@ export default { export const _default = () => { const color = text( 'Color', '#0073aa' ); + return ( ); diff --git a/packages/components/src/dashicon/stories/index.js b/packages/components/src/dashicon/stories/index.js index 5ba7d7be98cbcb..1e557ffdb0c857 100644 --- a/packages/components/src/dashicon/stories/index.js +++ b/packages/components/src/dashicon/stories/index.js @@ -8,7 +8,10 @@ import { number, text } from '@storybook/addon-knobs'; */ import Dashicon from '../'; -export default { title: 'Dashicon', component: Dashicon }; +export default { + title: 'Dashicon', + component: Dashicon, +}; export const _default = () => { const icon = text( 'Icon', 'wordpress' ); diff --git a/packages/components/src/icon-button/stories/index.js b/packages/components/src/icon-button/stories/index.js index d093876a20e0a4..fc59b445d5782d 100644 --- a/packages/components/src/icon-button/stories/index.js +++ b/packages/components/src/icon-button/stories/index.js @@ -1,13 +1,31 @@ +/** + * External dependencies + */ +import { text } from '@storybook/addon-knobs'; + /** * Internal dependencies */ import IconButton from '../'; -export default { title: 'IconButton', component: IconButton }; +export default { + title: 'IconButton', + component: IconButton, +}; + +export const _default = () => { + const icon = text( 'Icon', 'ellipsis' ); + const label = text( 'Label', 'More' ); -export const _default = () => ; + return ( + + ); +}; -export const grouped = () => { +export const Grouped = () => { const GroupContainer = ( { children } ) => (
{ children }
); diff --git a/packages/components/src/icon/stories/index.js b/packages/components/src/icon/stories/index.js index be4e9fed65787f..e3a5234aeba3da 100644 --- a/packages/components/src/icon/stories/index.js +++ b/packages/components/src/icon/stories/index.js @@ -1,21 +1,34 @@ +/** + * External dependencies + */ +import { number, text } from '@storybook/addon-knobs'; + /** * Internal dependencies */ import Icon from '../'; -import { SVG, Path } from '../../'; +import { SVG, Path } from '../../primitives/svg'; -export default { title: 'Icon', component: Icon }; +export default { + title: 'Icon', + component: Icon, +}; const IconSizeLabel = ( { size } ) =>
{ size }px
; -export const _default = () => ( -
- - -
-); +export const _default = () => { + const icon = text( 'Icon', 'screenoptions' ); + const size = number( 'Size', '24' ); + + return ( +
+ + +
+ ); +}; -export const sizes = () => { +export const Sizes = () => { const iconSizes = [ 14, 16, 20, 24, 28, 32, 40, 48, 56 ]; return ( @@ -30,7 +43,7 @@ export const sizes = () => { ); }; -export const colors = () => { +export const Colors = () => { const iconColors = [ 'blue', 'purple', 'green' ]; /** @@ -52,7 +65,7 @@ export const colors = () => { ); }; -export const withAFunction = () => ( +export const WithAFunction = () => ( ( @@ -62,7 +75,7 @@ export const withAFunction = () => ( /> ); -export const withAComponent = () => { +export const WithAComponent = () => { const MyIconComponent = () => ( @@ -72,7 +85,7 @@ export const withAComponent = () => { return ; }; -export const withAnSVG = () => { +export const WithAnSVG = () => { return ( { - const [ isScrollLocked, setScrollLocked ] = useState( false ); - const toggleLock = () => setScrollLocked( ! isScrollLocked ); - - return ( - -
Start scrolling down...
- - - { isScrollLocked && } -

- Scroll locked: { isScrollLocked ? 'Yes' : 'No' } -

-
- - ); +export default { + title: 'ScrollLock', + component: ScrollLock, }; function StripedBackground( props ) { @@ -66,5 +49,21 @@ function ToggleContainer( props ) { } export const _default = () => { - return ; + const [ isScrollLocked, setScrollLocked ] = useState( false ); + const toggleLock = () => setScrollLocked( ! isScrollLocked ); + + return ( + +
Start scrolling down...
+ + + { isScrollLocked && } +

+ Scroll locked: { isScrollLocked ? 'Yes' : 'No' } +

+
+
+ ); };