-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
@@ -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 }> | ||
|
@@ -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, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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>, | ||
} ) ), | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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