Last active
September 10, 2021 13:34
-
-
Save riccardo-forina/ce0b603466c5e292f369669b72950bac to your computer and use it in GitHub Desktop.
VSCode snippet to create a Storybook story
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Create a Storybook story": { | |
"prefix": "story", | |
"body": [ | |
"import { ComponentStory, ComponentMeta } from '@storybook/react';", | |
"import React from 'react';", | |
"", | |
"import { ${1:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}} } from './${2:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}}';", | |
"", | |
"export default {", | |
" title: '${3:Components}/${4:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}}',", | |
" component: ${1:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}},", | |
" args: {},", | |
"} as ComponentMeta<typeof ${1:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}}>;", | |
"", | |
"const Template: ComponentStory<typeof ${1:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}}> = (args) => (", | |
" <${1:${TM_FILENAME/(.*).stories.[t|j]sx/${1}/}} {...args} />", | |
");", | |
"", | |
"export const ${5:Story} = Template.bind({});", | |
"$5.args = {};", | |
"$0", | |
], | |
"description": "Create a Storybook story" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment