Skip to content

Adds Pinia snippets #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5b376b0
removed vetur as dep
CRBroughton Nov 18, 2021
00cd321
removed volar section
CRBroughton Nov 18, 2021
289173b
removed yarn.lock
CRBroughton Nov 18, 2021
9384d44
Merge branch 'develop' into main
CRBroughton Nov 18, 2021
9c3f534
added pinia.json
CRBroughton Nov 18, 2021
6799af4
added state refs and patching
CRBroughton Nov 19, 2021
ac7a3e6
updated pinia.json prefixes
CRBroughton Nov 19, 2021
4915240
added pinia table to README.md
CRBroughton Nov 19, 2021
47e4f86
updated keywords
CRBroughton Nov 19, 2021
be6d32e
fixed pstateref description
CRBroughton Nov 19, 2021
c28d07b
pinia state refs prefix changed
CRBroughton Nov 19, 2021
cb34dce
Merge pull request #1 from sdras/main
CRBroughton Feb 20, 2022
61048dc
Merge branch 'main' into develop
CRBroughton Feb 20, 2022
048af80
added store import command
CRBroughton Feb 20, 2022
fcc0ac3
Merge branch 'develop' into main
CRBroughton Feb 20, 2022
4ea1880
Revert "removed yarn.lock"
CRBroughton Feb 20, 2022
ef3aca8
added vue-html
CRBroughton Feb 20, 2022
1d385be
moved composition API scripts to the top
CRBroughton Feb 20, 2022
05d58b2
Merge branch 'script-top-2' into develop
CRBroughton Feb 20, 2022
d28fa47
added defineProps script snippet
CRBroughton Feb 20, 2022
6f7bd69
updated README.md with vdefineprops
CRBroughton Feb 20, 2022
448c097
added vdefineemits
CRBroughton Mar 4, 2022
08dcf84
modified functions to match examples
CRBroughton Mar 7, 2022
02d12e4
changed prefixes
CRBroughton Mar 7, 2022
1d8ac0a
added computed getter setter
CRBroughton Mar 8, 2022
3a7cd0f
added computed get / set to README.md
CRBroughton Mar 8, 2022
5520b75
add v3store command for composition store
CRBroughton May 30, 2022
fc00f32
update defineEmits to 3.3, add defineSlots, add generic component
CRBroughton Jun 11, 2023
c798e05
add spacing to generic component
CRBroughton Jun 11, 2023
f149d00
replace yarn with npm
CRBroughton Jun 11, 2023
4f17a23
Merge branch 'develop'
CRBroughton Jun 11, 2023
b3c56db
add defineModel, update defineEmits & defineSlots
CRBroughton Dec 29, 2023
a7ae345
chore: install changesets, update publisher and vscode engine version…
CRBroughton Nov 22, 2024
cacd116
chore: add .vscodeignore
CRBroughton Nov 22, 2024
c1a704a
chore: update name
CRBroughton Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ You can enable tab completion (recommended) by opening `Code > Preferences > Set
| `vstore-import` | Import vuex store into main.js |
| `vstore2` | Updated Base for Vuex store |

### Pinia

| Snippet | Purpose |
| --------------- | ------------------------------ |
| `pstore` | Base for Pinia store.ts |
| `pstateref` | Access Pinia State |
| `ppatch` | Pinia Patch |
| `ppatchf` | Pinia Patch Function |

### Vue Router

| Snippet | Purpose |
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"Vue 3",
"Vue 2",
"Composition API",
"Vuex",
"Pinia",
"Vue Snippets"
],
"categories": [
Expand Down Expand Up @@ -75,6 +77,10 @@
{
"language": "typescript",
"path": "./snippets/nuxt-config.json"
},
{
"language": "typescript",
"path": "./snippets/pinia.json"
}
]
}
Expand Down
57 changes: 57 additions & 0 deletions snippets/pinia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"Pinia Store": {
"prefix": "pstore",
"body": [
"import { defineStore } from 'pinia'",
"",
"export const useCounterStore = defineStore('counter', {",
"\tstate: () => {",
"\t\treturn { count: 0 }",
"\t},",
"\tactions: {",
"\t\tincrement() {",
"\t\t\tthis.count++",
"\t\t},",
"\t},",
"})"
],
"description": "Basic Pinia Store"
},
"Pinia Store State Refs": {
"prefix": "pstateref",
"body": [
"import { useCounterStore } from '@/store/main'",
"",
"const store = useCounterStore()",
"const { count } = storeToRefs(store)",
"// You can access destructured state like so: store.counter++"
],
"description": "Destructure Pinia State"
},
"Pinia Store Patch": {
"prefix": "ppatch",
"body": [
"store.$patch({",
"\tcount: store.count++",
"})"
],
"description": "Pinia Store Patch"
},
"Pinia Store Patch Function": {
"prefix": "ppatchf",
"body": [
"store.$patch((state) => {",
"\tstate.items.push({ name: 'shoes', quantity: 1 })",
"\tstate.hasChanged = true",
"})"
],
"description": "Pinia Store Patch Function"
},
"Pinia Import Store": {
"prefix": "pstore-import",
"body": [
"import { useCounterStore } from '@/store/main'"
],
"description": "Import a Pinia store"
}
}