@storybook/react
v3.2.4@storybook/addon-info
v3.2.4๊ณต์ ์์์ด ํญ๋ชฉ
storiesOf('Button').addWithInfo(
'simple usage (custom propTables)',
`
This is the basic usage with the button with providing a label to show the text.
Since, the story source code is wrapped inside a div, info addon can't figure out propTypes on it's own.
So, we need to give relevant React component classes manually using \`propTypes\` option as shown below:
~~~js
storiesOf('Button')
.addWithInfo(
'simple usage (custom propTables)',
<info>,
<storyFn>,
{ inline: true, propTables: [Button]}
);
~~~
`,
() => (
<div>
<Button label="The Button" onClick={action('onClick')} />
<br />
</div>
),
{ inline: true, propTables: [Button] }
);
propTypes
๋ ๋ฐฑํฑ์ผ๋ก ๋ฌถ์ฌ ์์ต๋๋ค.
propTypes
๋จ์ด๋ ํด๋น ๋จ์ด๊ฐ ์ํ ๋ฌธ์ฅ๊ณผ ํจ๊ป ๊ณ ์ ํญ ๊ธ๊ผด๋ก ํ์๋ฉ๋๋ค.
propTypes
๋ผ๋ ๋จ์ด๋ ์๋์ ๊ฐ์ด ๋น <pre><code></code></pre>
์์๊ฐ๋ฉ๋๋ค.
<Code>
์ด๋ฉฐ, <code>
๋ด๋ถ์์ <pre>
<code>
๋ก ๊ตฌํ๋๋ฉฐ, ์ด๋ ๋ฌธ์ฅ์ ๋๋ก ๋๋๋ ๋ธ๋ก ์์์
๋๋ค.<Code>
๋ this.props.code
ํ
์คํธ๋ฅผ ๋ ๋๋งํ์ง๋ง ์ค์ ํ
์คํธ๋ this.props.children
์์ต๋๋ค.@MrOrz ์ ๋์ด ๋ฌธ์ ์ ์ง๋ฉด
๋์ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
๊ทธ ๋ง์ ๋ค์ผ๋ ๋ฐ๊ฐ์ต๋๋ค!
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด marksyConf
์ (๋ฅผ) ๋ฎ์ด ์ธ ์ ์์ผ๋ฏ๋ก PR์ ์๋๋ฅด์ง ๋ง์ญ์์ค.
์ ์:
import React from 'react';
import { configure } from '@storybook/react';
import { setDefaults } from '@storybook/addon-info';
function Code({ children }) {
return <code>{children}</code>;
}
function loadStories() {/* loading stories here */}
setDefaults({ marksyConf: { code: Code } });
configure(loadStories, module);
์ธ๋ผ์ธ ๋ฐ ๋ธ๋ก ์ฝ๋ ์น์
๋ชจ๋์ ์ฌ์ฉ๋๋ code
์ฒ๋ผ ๋ณด์
๋๋ค.
์ธ๋ผ์ธ ์ฝ๋์ ๊ฒฝ์ฐ props.children
๋ ๋๋งํด์ผํ์ง๋ง ์ฝ๋ ๋ธ๋ก props.code
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ธ๋ผ์ธ ๋ฐ ๋ธ๋ก ์ฝ๋ ์น์ ๋ชจ๋์ ์ฌ์ฉ๋๋
code
์ฒ๋ผ ๋ณด์ ๋๋ค.์ธ๋ผ์ธ ์ฝ๋์ ๊ฒฝ์ฐ
props.children
๋ ๋๋งํด์ผํ์ง๋ง ์ฝ๋ ๋ธ๋กprops.code