μλ νμΈμ. λλ μμ‘μ΄κ° λ°μ μ μΌλ‘ μλνλλ‘ λ§λλ κ²μ΄ μ ν λ¨κ²μ§ μλ€. μΉμμλ μμ λ₯Ό μ°Ύμ§ λͺ»νμ΅λλ€.
λ΄ μ½λλ λ€μκ³Ό κ°μ΅λλ€.
import ElBtn from '../components/elements/buttons/el-btn.vue';
export default {
title: 'El-Btn',
component: ElBtn,
decorators: [() => `<section class="container"><story /></section>`],
argTypes: {
type: { control: { type: 'select', options: ['secondary', 'primary'] } },
round: { control: { type: 'boolean', default: false } },
},
};
export const primary = () => ({
components: { ElBtn },
template: `<el-btn>Text</el-btn>`,
});
export const secondary = () => ({
props: {
type: { control: { type: 'select', options: ['secondary', 'primary'] } },
},
render() {
return <ElBtn type="this.type">Test</ElBtn>;
},
});
Vue CLI 4.5.0 (vue μΆκ° μ€ν 리 λΆ)μ ν΅ν΄ μΆκ°λμμ΅λλ€.
κ΄λ ¨ κ°λ° μ’ μμ± :
"@storybook/addon-essentials": "^6.0.26",
"@storybook/addon-links": "^6.0.26",
"@storybook/vue": "^6.0.26",
λ μ€ν 리μ λ 컨νΈλ‘€μ΄ λͺ¨λ λνλμ§λ§ λ μ€ μ΄λ κ²λ μ€μ μνμ λ³κ²½νμ§ μμ΅λλ€.
λν vue λλ κ΄λ ¨ κ°μ΄λκ° ν¬ν¨ λ μ€ν μμ€ μ€ν 리 λΆ 6.0 μμ μ κ°μ¬λ립λλ€.
export const primary = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { ElBtn },
// v-bind by itself takes every key in the value and v-binds them to a field on this component
// $props is every prop on the `primary` component
template: `<el-btn v-bind="$props">Text</el-btn>`,
});
보쑰μ κ²½μ° μνμ λν΄μλμ΄ λ μ΄μμμ λ°λ₯Ό μ μμ΅λλ€.
μμΈν λ΄μ©μ μ¬κΈ°μ
https://storybook.js.org/docs/vue/writing-stories/args#story -args
κ°μ₯ μ μ©ν λκΈ
보쑰μ κ²½μ° μνμ λν΄μλμ΄ λ μ΄μμμ λ°λ₯Ό μ μμ΅λλ€.
μμΈν λ΄μ©μ μ¬κΈ°μ
https://storybook.js.org/docs/vue/writing-stories/args#story -args