Last active
January 19, 2021 15:49
-
-
Save dakom/77e9b8299870b71512e55fb9222c4535 to your computer and use it in GitHub Desktop.
components snippets
This file contains hidden or 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
{ | |
"ComponentSetup": { | |
"scope": "javascript,typescript", | |
"body": [ | |
"import {argsToAttrs} from \"@utils/attributes\";", | |
"import \"@elements/path/to/$2\";", | |
"", | |
"export default {", | |
"\ttitle: \"\"", | |
"}", | |
"", | |
"interface Args {", | |
"}", | |
"", | |
"const DEFAULT_ARGS:Args = {", | |
"}", | |
"", | |
"export const $1 = (props?:Args) => {", | |
"", | |
"\tprops = props ? {...DEFAULT_ARGS, ...props} : DEFAULT_ARGS;", | |
"\tconst {} = props", | |
"", | |
"\treturn `<$2 ${argsToAttrs(props)}></$2>`;", | |
"}", | |
"", | |
"$1.args = DEFAULT_ARGS;", | |
] | |
}, | |
"ArgTypesRadio": { | |
"scope": "javascript,typescript", | |
"body": [ | |
"$1.argTypes = {", | |
"\t$2: {", | |
"\t\tcontrol: {", | |
"\t\t\ttype: 'inline-radio',", | |
"\t\t\toptions: []", | |
"\t\t}", | |
"\t}", | |
"}" | |
] | |
}, | |
"ArrayCountString": { | |
"scope": "javascript,typescript", | |
"body": [ | |
"${mapToString(arrayCount($1), i => {", | |
"\treturn `", | |
"\t`;", | |
"})}" | |
] | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment