Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide: Remove knobs in stories #46773

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.';

Comment on lines -31 to -33
Copy link
Member Author

Choose a reason for hiding this comment

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

No strong opinion, but I removed this lorem ipsum for simplicity.

By the way the CSS in the modal seems pretty broken, but this is an existing problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way the CSS in the modal seems pretty broken, but this is an existing problem.

Absolutely, In fact, in the current example on trunk, the dots are not click-able (while they are in this PR).

Overall the component is not looking in its best shape either

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, {
Copy link
Member Author

Choose a reason for hiding this comment

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

numberOfPages is not an actual component prop. It was being used as a Storybook-only utility prop to generate the pages array.

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>,
} ) ),
};