Created
September 9, 2020 08:29
-
-
Save PaulieScanlon/f2cbbe85b02ddf03f579d034aceb2df1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { useState } from 'react' | |
// import { YourComponent } from 'your-directory' | |
export default { | |
title: 'components/Hackerman-1', | |
parameters: { | |
// component: YourComponent, | |
componentSubtitle: | |
'The Component Subtitle appears at the top of the .stories file. I usually create a default export for "Usage" to show how the component can be used without any props. It\'s common for each story to start with a capital letter', | |
}, | |
} | |
export const Usage = () => <input /> | |
export const Placeholder = () => <input placeholder="Boogy Time" /> | |
Placeholder.parameters = { | |
docs: { | |
description: { | |
story: | |
'I usually create one "Story" per `prop` showing just how that prop is used, which is also nice when you expand the "Show code" thingy', | |
}, | |
}, | |
} | |
export const OnChange = () => { | |
const [stateValue, setStateValue] = useState('') | |
return ( | |
<input | |
value={stateValue} | |
onChange={(event) => setStateValue(event.target.value)} | |
/> | |
) | |
} | |
OnChange.parameters = { | |
docs: { | |
description: { | |
story: | |
"Storybook's CSF (Component Story Format) is an ES6 function so you can pretty much do with it what you want... like React hooks", | |
}, | |
}, | |
} | |
export const SomeDiv = () => <input placeholder="I haz a parent" /> | |
SomeDiv.parameters = { | |
docs: { | |
description: { | |
story: | |
'Decorators can wrap your story with whatever you like but... whatever you wrap them in won\'t appear in the code snippet when you exapnd the "Show code" thingy. You could even put the state in a decorator so the code snippet looks cleaner', | |
}, | |
}, | |
} | |
SomeDiv.decorators = [ | |
(Story) => ( | |
<div style={{ outline: '3px solid red' }}> | |
<Story /> | |
</div> | |
), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment