Skip to content

Instantly share code, notes, and snippets.

@dakom
Last active January 19, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakom/77e9b8299870b71512e55fb9222c4535 to your computer and use it in GitHub Desktop.
Save dakom/77e9b8299870b71512e55fb9222c4535 to your computer and use it in GitHub Desktop.
components snippets
{
"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