Storybook: 6.0μ—μ„œ vue μ»΄ν¬λ„ŒνŠΈ 용 λ…ΈλΈŒλ₯Ό μΆ”κ°€ν•˜λŠ” 방법은 λ¬΄μ—‡μž…λ‹ˆκΉŒ?

에 λ§Œλ“  2020λ…„ 11μ›” 25일  Β·  1논평  Β·  좜처: storybookjs/storybook

μ•ˆλ…•ν•˜μ„Έμš”. λ‚˜λŠ” μ†μž‘μ΄κ°€ λ°˜μ‘ 적으둜 μž‘λ™ν•˜λ„λ‘ λ§Œλ“œλŠ” 것이 μ „ν˜€ λœ¨κ²μ§€ μ•Šλ‹€. μ›Ήμ—μ„œλ„ 예제λ₯Ό 찾지 λͺ»ν–ˆμŠ΅λ‹ˆλ‹€.

λ‚΄ μ½”λ“œλŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

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 μ˜ˆμ œμ— κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.

PN controls vue question / support

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

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

>λͺ¨λ“  λŒ“κΈ€

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

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰