Skip to content

Commit

Permalink
Guide: Remove knobs in stories
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Dec 23, 2022
1 parent 96a8df7 commit c1759df
Showing 1 changed file with 14 additions and 41 deletions.
55 changes: 14 additions & 41 deletions packages/components/src/guide/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { text, number } from '@storybook/addon-knobs';

/**
* WordPress dependencies
*/
Expand All @@ -17,20 +12,19 @@ import Guide from '../';
export default {
title: 'Components/Guide',
component: Guide,
parameters: {
knobs: { disable: false },
argTypes: {
contentLabel: { control: 'text' },
finishButtonText: { control: 'text' },
onFinish: { action: 'onFinish' },
},
};

const ModalExample = ( { numberOfPages, ...props } ) => {
const Template = ( { onFinish, ...props } ) => {
const [ isOpen, setOpen ] = useState( false );

const openGuide = () => setOpen( true );
const closeGuide = () => setOpen( false );

const loremIpsum =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';

return (
<>
<Button variant="secondary" onClick={ openGuide }>
Expand All @@ -39,40 +33,19 @@ const ModalExample = ( { numberOfPages, ...props } ) => {
{ isOpen && (
<Guide
{ ...props }
onFinish={ closeGuide }
pages={ Array.from( { length: numberOfPages } ).map(
( _, page ) => ( {
content: (
<>
<h1>
Page { page + 1 } of { numberOfPages }
</h1>
<p>{ loremIpsum }</p>
</>
),
} )
) }
onFinish={ ( ...finishArgs ) => {
closeGuide( ...finishArgs );
onFinish( ...finishArgs );
} }
/>
) }
</>
);
};

export const _default = () => {
const finishButtonText = text( 'finishButtonText', 'Finish' );
const contentLabel = text( 'title', 'Guide title' );
const numberOfPages = number( 'numberOfPages', 3, {
range: true,
min: 1,
max: 10,
step: 1,
} );

const modalProps = {
finishButtonText,
contentLabel,
numberOfPages,
};

return <ModalExample { ...modalProps } />;
export const Default = Template.bind( {} );
Default.args = {
pages: Array.from( { length: 3 } ).map( ( _, page ) => ( {
content: <p>{ `Page ${ page + 1 }` }</p>,
} ) ),
};

1 comment on commit c1759df

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3767292528
📝 Reported issues:

Please sign in to comment.