Skip to content

Instantly share code, notes, and snippets.

@nicolasparada
Last active April 3, 2017 10:17
Show Gist options
  • Save nicolasparada/1389de5cd393ca3414ebedb44637c9e6 to your computer and use it in GitHub Desktop.
Save nicolasparada/1389de5cd393ca3414ebedb44637c9e6 to your computer and use it in GitHub Desktop.
VSCode Snippets
{
"Document": {
"prefix": "!",
"body": [
"<!DOCTYPE html>",
"<meta charset=\"utf-8\">",
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">",
"",
"<title>${1:Document}</title>",
"",
"<link rel=\"icon\" href=\"data:,\">",
"",
"$2"
]
}
}
{
"Bind": {
"prefix": "bind",
"body": "this.$1 = this.$1.bind(this)"
},
"Custom Element": {
"prefix": "customElement",
"body": [
"(doc => {",
" class $1 extends HTMLElement {",
" static get is() { return '$2' }",
" ",
" static get observedAttributes() {",
" return []",
" }",
" ",
" constructor() {",
" super()",
" const template = doc.getElementById($1.is + '-template')",
" const instance = template.content.cloneNode(true)",
" const shadowRoot = this.attachShadow({ mode: 'open' })",
" shadowRoot.appendChild(instance)",
" $3",
" }",
" ",
" connectedCallback() {",
" ",
" }",
" ",
" disconnectedCallback() {",
" ",
" }",
" ",
" attributeChangedCallback(attrName, newVal, oldVal, namespace) {",
" ",
" }",
" ",
" adoptedCallback(oldDoc, newDoc) {",
" ",
" }",
" }",
" ",
" customElements.define($1.is, $1)",
"})(document.currentScript.ownerDocument)"
]
},
"Redux Reducer": {
"prefix": "reducer",
"body": [
"const initialState = $2",
"",
"const $1 = (state = initialState, action) => {",
" switch (action.type) {",
" case '$3': return $4",
" default: return state",
" }",
"}",
"",
"export default $1"
]
}
}
{
"Bind": {
"prefix": "bind",
"body": "this.$1 = this.$1.bind(this)"
},
"Stateful Component": {
"prefix": "sfc",
"body": [
"import { Component, h } from 'preact'",
"",
"class $1 extends Component {",
" constructor(props, context) {",
" super(props, context)",
" }",
"",
" render(props, state) {",
" return (",
" $2",
" )",
" }",
"}",
"",
"export default $1"
]
},
"Stateless Component": {
"prefix": "slc",
"body": [
"import { h } from 'preact'",
"",
"const $1 = props => (",
" $2",
")",
"",
"export default $1"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment