From 52cb59179ef733e885ae7cdd0ef830f9e61a2c3f Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sun, 18 Sep 2022 13:05:18 +0300 Subject: [PATCH 1/5] feat: Add more `Nuxt` snippets (#28) * Nuxt Plugin snippet #27 * Nuxt middleware snippet #27 * Nuxt Server Route snippet #27 * Documentation #27 --- README.md | 5 +++++ snippets/nuxt-script.code-snippets | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.md b/README.md index e4a57f5..82c729c 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,11 @@ These snippets were made to speed up Vue 3 development. With it you can write bo | `nhead-template` | `useHead` composable with title template | | `npagemeta` | `definePageMeta` composable | | `npagemeta-description` | `definePageMeta` composable with description | +| ⚠️ `nplugin` | Base code for Nuxt plugin | +| ⚠️ `nmiddleware` | Base code for Nuxt middleware | +| ⚠️ `nserverroute` | Base code for Nuxt server route | + +> Snippets with ⚠️ symbol are unreleased. ## Contributing diff --git a/snippets/nuxt-script.code-snippets b/snippets/nuxt-script.code-snippets index 38388ff..31a344f 100644 --- a/snippets/nuxt-script.code-snippets +++ b/snippets/nuxt-script.code-snippets @@ -80,4 +80,31 @@ ], "description": "Nuxt definePageMeta composable with description" }, + "Nuxt define plugin": { + "prefix": "nplugin", + "body": [ + "export default defineNuxtPlugin(nuxtApp => {", + "\t${0}", + "})", + ], + "description": "Base code for Nuxt plugin" + }, + "Nuxt define middleware": { + "prefix": "nmiddleware", + "body": [ + "export default defineNuxtRouteMiddleware((to, from) => {", + "\t${0}", + "})", + ], + "description": "Base code for Nuxt middleware" + }, + "Nuxt define server route": { + "prefix": "nserverroute", + "body": [ + "export default defineEventHandler((event) => {", + "\t${0}", + "})", + ], + "description": "Base code for Nuxt server route" + }, } From d21ea1df66e793434ef94606ba111a24f4f7247c Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sun, 18 Sep 2022 13:04:48 +0300 Subject: [PATCH 2/5] feat: Add `Pinia` composition store snippets (#29) * Pinia composition API snippet #26 * Documentation #26 --- README.md | 9 ++++++--- snippets/pinia.code-snippets | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 82c729c..249fb7c 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,12 @@ These snippets were made to speed up Vue 3 development. With it you can write bo ### Pinia -| Snippet | Purpose | -| -------- | --------------------------------------- | -| `pstore` | Base code needed for a Pinia store file | +| Snippet | Purpose | +| ---------------------- | ------------------------------------------------------------ | +| `pstore` | Base code needed for a Pinia store file | +| ⚠️ `pstore-composition` | Base code needed for a Pinia store file with Composition API | + +> Snippets with ⚠️ symbol are unreleased. ### Vue Router diff --git a/snippets/pinia.code-snippets b/snippets/pinia.code-snippets index 92d1433..d472fb3 100644 --- a/snippets/pinia.code-snippets +++ b/snippets/pinia.code-snippets @@ -18,5 +18,21 @@ "" ], "description": "Base code needed for a Pinia store file" + }, + "Pinia Store Base - Composition API": { + "prefix": "pstore-composition", + "body": [ + "import { defineStore, acceptHMRUpdate } from \"pinia\"", + "", + "export const use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store = defineStore(\"$TM_FILENAME_BASE\", () => {", + "\t${0}", + "})", + "", + "if (import.meta.hot) {", + "\timport.meta.hot.accept(acceptHMRUpdate(use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store, import.meta.hot))", + "}", + "" + ], + "description": "Base code needed for a Pinia store file with Composition API" } } From 79ee94de73f84efe02a1c176dcc4da3093d0c7cc Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sat, 15 Oct 2022 16:05:38 +0300 Subject: [PATCH 3/5] feat: Add `Histoire` snippets (#31) * Histoire config snippets #20 * Histoire story base #20 * Remove extra line in vue snippets * Histoire variants #20 * Histoire layouts #20 * Histoire controls #20 * Folders restructure * Documentation #20 --- README.md | 21 +++++ package.json | 38 +++++--- .../histoire/histoire-script.code-snippets | 32 +++++++ .../histoire/histoire-template.code-snippets | 93 +++++++++++++++++++ snippets/histoire/histoire.code-snippets | 54 +++++++++++ snippets/{ => nuxt}/nuxt-script.code-snippets | 0 .../{ => nuxt}/nuxt-template.code-snippets | 0 snippets/{ => pinia}/pinia.code-snippets | 0 snippets/{ => vue}/vue-router.code-snippets | 0 snippets/{ => vue}/vue-script.code-snippets | 0 snippets/{ => vue}/vue-template.code-snippets | 0 snippets/{ => vue}/vue.code-snippets | 21 ++--- 12 files changed, 234 insertions(+), 25 deletions(-) create mode 100644 snippets/histoire/histoire-script.code-snippets create mode 100644 snippets/histoire/histoire-template.code-snippets create mode 100644 snippets/histoire/histoire.code-snippets rename snippets/{ => nuxt}/nuxt-script.code-snippets (100%) rename snippets/{ => nuxt}/nuxt-template.code-snippets (100%) rename snippets/{ => pinia}/pinia.code-snippets (100%) rename snippets/{ => vue}/vue-router.code-snippets (100%) rename snippets/{ => vue}/vue-script.code-snippets (100%) rename snippets/{ => vue}/vue-template.code-snippets (100%) rename snippets/{ => vue}/vue.code-snippets (93%) diff --git a/README.md b/README.md index 249fb7c..9398912 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,27 @@ These snippets were made to speed up Vue 3 development. With it you can write bo > Snippets with ⚠️ symbol are unreleased. +### Histoire + +| Snippet | Purpose | +| ------------------------- | ------------------------------------ | +| ⚠️ `hconfig` | Histoire config for Vue 3 | +| ⚠️ `hconfig-nuxt` | Histoire config for Nuxt 3 | +| ⚠️ `hbase` | Base code for story | +| ⚠️ `hbase-variant` | Base code for story with variant | +| ⚠️ `hbase-grid` | Base code for story with grid layout | +| ⚠️ `hvariant` | Story variant | +| ⚠️ `hgrid` | Histoire grid layout | +| ⚠️ `hcontrols-base` | Histoire controls base | +| ⚠️ `hcontrols-button` | Histoire controls - Button | +| ⚠️ `hcontrols-buttongroup` | Histoire controls - Button Group | +| ⚠️ `hcontrols-checkbox` | Histoire controls - Checkbox | +| ⚠️ `hcontrols-number` | Histoire controls - Number | +| ⚠️ `hcontrols-text` | Histoire controls - Text | +| ⚠️ `hcontrols-textarea` | Histoire controls - Textarea | + +> Snippets with ⚠️ symbol are unreleased. + ## Contributing This is an open source project open to anyone. Contributors are welcome on [GitHub](https://github.com/exer7um/vue3-vscode-snippets). diff --git a/package.json b/package.json index 5a75aac..56bb066 100644 --- a/package.json +++ b/package.json @@ -49,47 +49,63 @@ "snippets": [ { "language": "vue", - "path": "./snippets/vue.code-snippets" + "path": "./snippets/vue/vue.code-snippets" }, { "language": "html", - "path": "./snippets/vue-template.code-snippets" + "path": "./snippets/vue/vue-template.code-snippets" }, { "language": "javascript", - "path": "./snippets/vue-script.code-snippets" + "path": "./snippets/vue/vue-script.code-snippets" }, { "language": "typescript", - "path": "./snippets/vue-script.code-snippets" + "path": "./snippets/vue/vue-script.code-snippets" }, { "language": "javascript", - "path": "./snippets/pinia.code-snippets" + "path": "./snippets/pinia/pinia.code-snippets" }, { "language": "typescript", - "path": "./snippets/pinia.code-snippets" + "path": "./snippets/pinia/pinia.code-snippets" }, { "language": "javascript", - "path": "./snippets/vue-router.code-snippets" + "path": "./snippets/vue/vue-router.code-snippets" }, { "language": "typescript", - "path": "./snippets/vue-router.code-snippets" + "path": "./snippets/vue/vue-router.code-snippets" }, { "language": "html", - "path": "./snippets/nuxt-template.code-snippets" + "path": "./snippets/nuxt/nuxt-template.code-snippets" }, { "language": "javascript", - "path": "./snippets/nuxt-script.code-snippets" + "path": "./snippets/nuxt/nuxt-script.code-snippets" }, { "language": "typescript", - "path": "./snippets/nuxt-script.code-snippets" + "path": "./snippets/nuxt/nuxt-script.code-snippets" + }, + { + "language": "vue", + "path": "./snippets/histoire/histoire.code-snippets" + }, + { + "language": "html", + "path": "./snippets/histoire/histoire-template.code-snippets" + }, + { + "language": "javascript", + "path": "./snippets/histoire/histoire-script.code-snippets" + }, + { + "language": "typescript", + "path": "./snippets/histoire/histoire-script.code-snippets" } ] } diff --git a/snippets/histoire/histoire-script.code-snippets b/snippets/histoire/histoire-script.code-snippets new file mode 100644 index 0000000..676d11c --- /dev/null +++ b/snippets/histoire/histoire-script.code-snippets @@ -0,0 +1,32 @@ +{ + "Histoire config": { + "prefix": "hconfig", + "body": [ + "import { defineConfig } from 'histoire'", + "import { HstVue } from '@histoire/plugin-vue'", + "", + "export default defineConfig({", + "\tplugins: [", + "\t\tHstVue(),", + "\t],", + "})" + ], + "description": "Histoire config for Vue 3" + }, + "Histoire config - Nuxt": { + "prefix": "hconfig-nuxt", + "body": [ + "import { defineConfig } from 'histoire'", + "import { HstVue } from '@histoire/plugin-vue'", + "import { HstNuxt } from '@histoire/plugin-nuxt'", + "", + "export default defineConfig({", + "\tplugins: [", + "\t\tHstVue(),", + "\t\tHstNuxt(),", + "\t],", + "})" + ], + "description": "Histoire config for Nuxt 3" + }, +} diff --git a/snippets/histoire/histoire-template.code-snippets b/snippets/histoire/histoire-template.code-snippets new file mode 100644 index 0000000..722496a --- /dev/null +++ b/snippets/histoire/histoire-template.code-snippets @@ -0,0 +1,93 @@ +{ + "Histoire story variant": { + "prefix": "hvariant", + "body": [ + "", + "\t$0", + "", + ], + "description": "Story variant" + }, + "Histoire grid layout": { + "prefix": "hgrid", + "body": [ + ":layout='{ type: 'grid', width: ${1:gridWidth} }'", + ], + "description": "Histoire grid layout" + }, + "Histoire controls": { + "prefix": "hcontrols-base", + "body": [ + "" + ], + "description": "Histoire controls base" + }, + "Histoire controls - Button": { + "prefix": "hcontrols-button", + "body": [ + "", + "\t$0", + "" + ], + "description": "Histoire controls - Button" + }, + "Histoire controls - Button Group": { + "prefix": "hcontrols-buttongroup", + "body": [ + "", + ], + "description": "Histoire controls - Button Group" + }, + "Histoire controls - Checkbox": { + "prefix": "hcontrols-checkbox", + "body": [ + "" + ], + "description": "Histoire controls - Checkbox" + }, + "Histoire controls - Number": { + "prefix": "hcontrols-number", + "body": [ + "" + ], + "description": "Histoire controls - Number" + }, + "Histoire controls - Text": { + "prefix": "hcontrols-text", + "body": [ + "" + ], + "description": "Histoire controls - Text" + }, + "Histoire controls - Textarea": { + "prefix": "hcontrols-textarea", + "body": [ + "" + ], + "description": "Histoire controls - Textarea" + }, +} diff --git a/snippets/histoire/histoire.code-snippets b/snippets/histoire/histoire.code-snippets new file mode 100644 index 0000000..8be2135 --- /dev/null +++ b/snippets/histoire/histoire.code-snippets @@ -0,0 +1,54 @@ +{ + "Histoire story base": { + "prefix": "hbase", + "body": [ + "", + "", + "", + ], + "description": "Base code for story" + }, + "Histoire story base with variant": { + "prefix": "hbase-variant", + "body": [ + "", + "", + "", + ], + "description": "Base code for story with variant" + }, + "Histoire story base with grid layout": { + "prefix": "hbase-grid", + "body": [ + "", + "", + "", + ], + "description": "Base code for story with grid layout" + }, +} diff --git a/snippets/nuxt-script.code-snippets b/snippets/nuxt/nuxt-script.code-snippets similarity index 100% rename from snippets/nuxt-script.code-snippets rename to snippets/nuxt/nuxt-script.code-snippets diff --git a/snippets/nuxt-template.code-snippets b/snippets/nuxt/nuxt-template.code-snippets similarity index 100% rename from snippets/nuxt-template.code-snippets rename to snippets/nuxt/nuxt-template.code-snippets diff --git a/snippets/pinia.code-snippets b/snippets/pinia/pinia.code-snippets similarity index 100% rename from snippets/pinia.code-snippets rename to snippets/pinia/pinia.code-snippets diff --git a/snippets/vue-router.code-snippets b/snippets/vue/vue-router.code-snippets similarity index 100% rename from snippets/vue-router.code-snippets rename to snippets/vue/vue-router.code-snippets diff --git a/snippets/vue-script.code-snippets b/snippets/vue/vue-script.code-snippets similarity index 100% rename from snippets/vue-script.code-snippets rename to snippets/vue/vue-script.code-snippets diff --git a/snippets/vue-template.code-snippets b/snippets/vue/vue-template.code-snippets similarity index 100% rename from snippets/vue-template.code-snippets rename to snippets/vue/vue-template.code-snippets diff --git a/snippets/vue.code-snippets b/snippets/vue/vue.code-snippets similarity index 93% rename from snippets/vue.code-snippets rename to snippets/vue/vue.code-snippets index 7a80abf..dae7bd4 100644 --- a/snippets/vue.code-snippets +++ b/snippets/vue/vue.code-snippets @@ -4,8 +4,7 @@ "body": [ "" - , + "", "", "