Skip to content

Instantly share code, notes, and snippets.

@johnleider
Last active December 9, 2021 16:11
Show Gist options
  • Save johnleider/4bbab0a04495b0f0876dcba7d5d3f310 to your computer and use it in GitHub Desktop.
Save johnleider/4bbab0a04495b0f0876dcba7d5d3f310 to your computer and use it in GitHub Desktop.
{
"Import Vue": {
"prefix": "ivue",
"body": [
"import { $1 } from 'vue'$0"
]
},
"New TSX Component": {
"prefix": "bptsx",
"body": [
"// Utility",
"import { defineComponent } from 'vue'",
"import { useRender } from '@/util'",
"",
"export const $1 = defineComponent({",
" name: '$1',",
"",
" props: {",
" //",
" },",
"",
" setup (props, { slots }) {",
" useRender(() => (",
" <div>",
" { slots?.default?.() }",
" </div>",
" ))",
"",
" return {}",
" },",
"})",
"",
]
},
"New TSX Component w/ Slot": {
"prefix": "bptsxs",
"body": [
"// Utility",
"import { genericComponent, useRender } from '@/util'",
"",
"// Types",
"import type { MakeSlots } from '@/util'",
"",
"export const $1 = genericComponent<new <T>() => {",
" $$slots: MakeSlots<{",
" default: []",
" }>",
"}>()({",
" name: '$1',",
"",
" props: {",
" //",
" },",
"",
" setup (props, { slots }) {",
" useRender(() => (",
" <div>",
" { slots?.default?.() }",
" </div>",
" ))",
"",
" return {}",
" },",
"})",
"",
"export type $1 = InstanceType<typeof $1>",
""
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment