рдирдорд╕реНрддреЗред рдореБрдЭреЗ рдиреЛрдм рдХреЛ рдкреНрд░рддрд┐рдХреНрд░рд┐рдпрд╛рд╢реАрд▓ рд░реВрдк рд╕реЗ рдХрд╛рдо рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдЧрд░реНрдо рдХрд░рдиреЗ рдХрд╛ рдмрд┐рд▓реНрдХреБрд▓ рдкрддрд╛ рдирд╣реАрдВ рд╣реИред рд╡реЗрдм рдкрд░ рднреА рдХреЛрдИ рдЙрджрд╛рд╣рд░рдг рдирд╣реАрдВ рдорд┐рд▓рд╛ред
рдпрд╣рд╛рдБ рдореЗрд░рд╛ рдХреЛрдб рд╣реИ:
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 add storybook) рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рдЬреЛрдбрд╝рд╛ рдЧрдпрд╛ред
рдкреНрд░рд╛рд╕рдВрдЧрд┐рдХ рджреЗрд╡ рдирд┐рд░реНрднрд░рддрд╛рдПрдБ:
"@storybook/addon-essentials": "^6.0.26",
"@storybook/addon-links": "^6.0.26",
"@storybook/vue": "^6.0.26",
рджреЛрдиреЛрдВ рдХрд╣рд╛рдирд┐рдпреЛрдВ рдкрд░ рджреЛрдиреЛрдВ рдирд┐рдпрдВрддреНрд░рдг рджрд┐рдЦрд╛рдИ рджреЗрддреЗ рд╣реИрдВ, рд▓реЗрдХрд┐рди рдЙрдирдореЗрдВ рд╕реЗ рдХреЛрдИ рднреА рд╡рд╛рд╕реНрддрд╡рд┐рдХ рд╕рд╣рд╛рд░рд╛ рдирд╣реАрдВ рдмрджрд▓рддрд╛ рд╣реИред
рдЗрд╕рдХреЗ рдЕрд▓рд╛рд╡рд╛, рдХрд┐рд╕реА рднреА рдУрдкрдирд╕реЛрд░реНрд╕ рд╕реНрдЯреЛрд░реАрдмреБрдХ 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