Last active
June 6, 2023 09:30
-
-
Save tonioloewald/fd73c6f84f38d9ba0638da5a2e639dbd to your computer and use it in GitHub Desktop.
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
Show hidden characters
{ | |
// xinjs snippets for vs-code | |
// | |
// to use these: | |
// 1. in VS Code > Settings > Configure User Snippets | |
// 2. select new global snippets file | |
// 3. name it whatever you like | |
// 4. paste in the contents of this file | |
"xin-html-component-stub": { | |
"scope": "typescript", | |
"prefix": "xinhtml", | |
"body": [ | |
"import {elements, ElementCreator, ElementPart} from 'xinjs'", | |
"const { div } = elements", | |
"", | |
"export const myHtmlComponent: ElementCreator<HTMLDivElement> = (...parts: ElementPart[]): HTMLDivElement => div(", | |
" ...parts", | |
")" | |
] | |
}, | |
"xin-component-stub": { | |
"scope": "typescript", | |
"prefix": "xincomponent", | |
"body": [ | |
"import { Component as WebComponent, elements, vars } from 'xinjs'", | |
"", | |
"const {fragment, h1, slot} = elements", | |
"", | |
"class ${1:TagName} extends WebComponent {", | |
" content = fragment(h1(), slot())", | |
"}", | |
"", | |
"export const ${2:tagName} = ${1:TagName}.elementCreator({tag: '${3:tag-name}'})" | |
] | |
}, | |
"xin-component-styleNode": { | |
"scope": "typescript", | |
"prefix": "xinstylenode", | |
"body": [ | |
"styleNode = WebComponent.StyleNode({", | |
" ':host': {", | |
" display: 'block',", | |
" padding: vars.spacing", | |
" }", | |
"})", | |
] | |
}, | |
"xin-component-constructor": { | |
"scope": "typescript", | |
"prefix": "xinconstructor", | |
"body": [ | |
"constructor() {", | |
" super()", | |
" this.initAttributes('anne', 'example')", | |
"}" | |
] | |
}, | |
"xin-component-connectedCallback": { | |
"scope": "typescript", | |
"prefix": "xinconnected", | |
"body": [ | |
"connectedCallback(): void {", | |
" super.connectedCallback()", | |
"}" | |
] | |
}, | |
"xin-component-render": { | |
"scope": "typescript", | |
"prefix": "xinrender", | |
"body": [ | |
"render(): void {", | |
" super.render()", | |
"}" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment