-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addon-centered: Ability to disable for specific story (#7709)
Addon-centered: ability to disable on specific story
- Loading branch information
Showing
12 changed files
with
100 additions
and
10 deletions.
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 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const parameters = { | ||
name: 'centered', | ||
parameterName: 'centered', | ||
} as const; | ||
|
||
export default parameters; |
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,11 +1,18 @@ | ||
/** @jsx h */ | ||
import { Component, h } from 'preact'; | ||
import { makeDecorator } from '@storybook/addons'; | ||
import parameters from './parameters'; | ||
import styles from './styles'; | ||
|
||
export default function(storyFn: () => Component) { | ||
function centered(storyFn: () => Component) { | ||
return ( | ||
<div style={styles.style}> | ||
<div style={styles.innerStyle}>{storyFn()}</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default makeDecorator({ | ||
...parameters, | ||
wrapper: getStory => centered(getStory as any), | ||
}); |
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,14 +1,21 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { makeDecorator, StoryFn } from '@storybook/addons'; | ||
import parameters from './parameters'; | ||
import styles from './styles'; | ||
|
||
export default function(storyFn: () => ReactNode) { | ||
function centered(storyFn: () => ReactNode) { | ||
return ( | ||
<div style={styles.style}> | ||
<div style={styles.innerStyle}>{storyFn()}</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default makeDecorator({ | ||
...parameters, | ||
wrapper: getStory => centered(getStory as StoryFn), | ||
}); | ||
|
||
if (module && module.hot && module.hot.decline) { | ||
module.hot.decline(); | ||
} |
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