Skip to content

Commit

Permalink
feat: add basic storybook vue js and ts template
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetinate committed Apr 26, 2024
1 parent 0671f56 commit e3277ef
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/templates/storybook/vue/3/js/Component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { ArgTypes, Meta, StoryFn } from '@storybook/vue3'

import { toRefs } from 'vue'

import ResourceName from 'resourcePath'

type Props = InstanceType<typeof ResourceName>

const argTypes: Partial<ArgTypes<Props>> = {
// Describe your args type (component properties) here to autodocs show properly informations
}

const meta: Meta<Props> = {
component: ResourceName,
title: 'Components/UI/Card',
tags: ['autodocs'],
argTypes
}

export default meta

const Template: StoryFn<Props> = (args) => ({
components: { ResourceName },
setup() {
const reactiveArgs = toRefs(args)

return { args: reactiveArgs }
},
template: `
<ResourceName
// pass here yours props, e.g: (remove this comment)
:id="args.id"
>
<!-- If your component receive slots, pass them here, if not, remove this comment -->
</ResourceName>
`
})

export const Default = Template.bind({})
Default.args = {
id: 'clingon-generated-resource'
}
41 changes: 41 additions & 0 deletions src/templates/storybook/vue/3/ts/Component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { ArgTypes, Meta, StoryFn } from '@storybook/vue3'

import { toRefs } from 'vue'

import ResourceName from 'resourcePath'

const argTypes = {
// Describe your args type (component properties) here to autodocs show properly informations
}

const meta = {
component: ResourceName,
title: 'Components/UI/Card',
tags: ['autodocs'],
argTypes
}

export default meta

const Template = (args) => ({
components: { ResourceName },
setup() {
const reactiveArgs = toRefs(args)

return { args: reactiveArgs }
},
template: `
<ResourceName
// pass here yours props, e.g: (remove this comment)
:id="args.id"
>
<!-- If your component receive slots, pass them here, if not, remove this comment -->
</ResourceName>
`
})

export const Default = Template.bind({})
Default.args = {
id: 'clingon-generated-resource'
}

0 comments on commit e3277ef

Please sign in to comment.