-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
♻️Migrate Stories 62..65 to args
#37730
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cf79d74
Remove knobs and add args to amp-layout, context, wrappers.
rbeckthomas 34ed769
Merge branch 'main' of github.com:ampproject/amphtml into remove-knob…
rbeckthomas c372738
Move all inferrable type controls from argTypes to args.
rbeckthomas 1149b57
Return accidentally removed 'withA11y' error.
rbeckthomas 647d267
Re-order attributes to include {...args} first because subsequent values
rbeckthomas e16cbad
Add default value for wrapperStyle.
rbeckthomas 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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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,62 +1,76 @@ | ||
// @ts-ignore | ||
import {boolean, object, text, withKnobs} from '@storybook/addon-knobs'; | ||
|
||
// @ts-nocheck | ||
import * as Preact from '#preact'; | ||
import {ContainWrapper, Wrapper} from '#preact/component'; | ||
|
||
export default { | ||
title: '0/Wrappers', | ||
decorators: [withKnobs], | ||
}; | ||
|
||
export const wrapper = () => { | ||
const asProp = text('As', 'span'); | ||
const className = text('className', ''); | ||
const style = object('style', {border: '1px solid'}); | ||
const wrapperClassName = text('wrapperClassName', ''); | ||
const wrapperStyle = object('wrapperStyle', {}); | ||
const ariaLabel = text('ariaLabel', 'aria label'); | ||
export const wrapper = ({ariaLabel, asProp, className, ...args}) => { | ||
return ( | ||
<Wrapper | ||
as={asProp} | ||
class={className} | ||
style={style} | ||
wrapperClassName={wrapperClassName} | ||
wrapperStyle={wrapperStyle} | ||
aria-label={ariaLabel} | ||
> | ||
<Wrapper {...args} as={asProp} class={className} aria-label={ariaLabel}> | ||
content | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export const containWrapper = () => { | ||
const asProp = text('As', 'div'); | ||
const className = text('className', ''); | ||
const style = object('style', {border: '1px solid', width: 200, height: 50}); | ||
const wrapperClassName = text('wrapperClassName', ''); | ||
const wrapperStyle = object('wrapperStyle', {padding: 4}); | ||
const contentClassName = text('contentClassName', 'content'); | ||
const contentStyle = object('contentStyle', {border: '1px dotted'}); | ||
const size = boolean('size', true); | ||
const layout = boolean('layout', true); | ||
const paint = boolean('paint', true); | ||
const ariaLabel = text('ariaLabel', 'aria label'); | ||
wrapper.args = { | ||
asProp: 'span', | ||
ariaLabel: 'aria Label', | ||
className: '', | ||
wrapperClassName: '', | ||
}; | ||
|
||
wrapper.argTypes = { | ||
style: { | ||
name: 'style', | ||
defaultValue: {border: '1px solid'}, | ||
control: {type: 'object'}, | ||
}, | ||
wrapperStyle: { | ||
name: 'wrapperStyle', | ||
control: {type: 'object'}, | ||
}, | ||
}; | ||
|
||
export const containWrapper = ({ariaLabel, asProp, className, ...args}) => { | ||
return ( | ||
<ContainWrapper | ||
{...args} | ||
as={asProp} | ||
class={className} | ||
style={style} | ||
wrapperClassName={wrapperClassName} | ||
wrapperStyle={wrapperStyle} | ||
contentClassName={contentClassName} | ||
contentStyle={contentStyle} | ||
size={size} | ||
layout={layout} | ||
paint={paint} | ||
aria-label={ariaLabel} | ||
> | ||
content | ||
</ContainWrapper> | ||
); | ||
}; | ||
|
||
containWrapper.args = { | ||
asProp: 'div', | ||
ariaLabel: 'aria Label', | ||
className: '', | ||
contentClassName: 'content', | ||
wrapperClassName: '', | ||
size: true, | ||
layout: true, | ||
paint: true, | ||
}; | ||
|
||
containWrapper.argTypes = { | ||
style: { | ||
name: 'style', | ||
defaultValue: {border: '1px solid', width: 200, height: 50}, | ||
control: {type: 'object'}, | ||
}, | ||
wrapperStyle: { | ||
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. does this need the default value of 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. ah yes! thank you :) |
||
name: 'wrapperStyle', | ||
defaultValue: {padding: 4}, | ||
control: {type: 'object'}, | ||
}, | ||
contentStyle: { | ||
name: 'contentStyle', | ||
defaultValue: {border: '1px dotted'}, | ||
control: {type: 'object'}, | ||
}, | ||
}; |
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.
FMI: why is this named _default? Does that do something?
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.
As a convention we name the first story
_default
to make it clear its one that gets default selected when you navigate to the story. It doesnt do anything special in the storybook its more just for usthe
default
on line 9/6 That one does some storybook internal magic and is important to be named that way