Skip to content

Commit 338f14b

Browse files
author
yongbo.zeng_U+
committed
feat: add react component|hook, vue use|pinia
1 parent 5017102 commit 338f14b

File tree

9 files changed

+142
-121
lines changed

9 files changed

+142
-121
lines changed

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,30 @@ vue-vscode-snippets 中提供了大量好用、易用的代码片段,我在日
1313

1414
## TODO
1515

16-
- 🐬 [ ] react 页面模板;
17-
- 🦊 [ ] react hooks 模板;
16+
- 🐬 [] react 页面模板;
17+
- 🦊 [] react hooks 模板;
1818
- 🐶 [ ] axios 网络请求模板;
1919

2020
## Vue
2121

2222
| snippets | Purpose |
2323
| ------------------------------ | -------------------------------------------------- |
24-
| `up-v3-c-setup-ts-less-scoped` | Vue Single File Component With Props Setup Less Ts |
25-
| `up-v3-c-setup-ts-scss-scoped` | Vue Single File Component With Props Setup Scss Ts |
24+
| `up-v3comp-less` | Vue Single File Component With Props Setup Less Ts |
25+
| `up-v3comp-scss` | Vue Single File Component With Props Setup Scss Ts |
26+
27+
28+
## React
29+
| snippets | Purpose |
30+
| ------------------------------ | -------------------------------------------------- |
31+
| `up-rfc` | React Functional Component |
32+
| `up-rcc` | React Class Component |
33+
| `up-ruse` | React Hook |
34+
35+
## TypeScript
36+
| snippets | Purpose |
37+
| ------------------------------ | -------------------------------------------------- |
38+
| `up-v3use` | Vue3 Composition API |
39+
| `up-ruse` | React Hook |
2640

2741
## 提示
2842

package.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "up-snippets",
33
"displayName": "Up Snippets",
4-
"description": "Snippets that will supercharge your fontend workflow",
4+
"description": "Snippets that will supercharge your frontend workflow",
55
"icon": "images/vue-logo.png",
66
"version": "0.0.1",
77
"publisher": "Robert Zeng",
88
"engines": {
9-
"vscode": "^1.14.0"
9+
"vscode": ">=1.70.0",
10+
"node": ">=16.0.0"
1011
},
1112
"repository": {
1213
"type": "git",
@@ -35,10 +36,6 @@
3536
"language": "vue",
3637
"path": "./snippets/vue.json"
3738
},
38-
{
39-
"language": "vue",
40-
"path": "./snippets/up.json"
41-
},
4239
{
4340
"language": "jade",
4441
"path": "./snippets/vue-pug.json"
@@ -86,6 +83,18 @@
8683
{
8784
"language": "typescript",
8885
"path": "./snippets/nuxt-config.json"
86+
},
87+
{
88+
"language": "vue",
89+
"path": "./snippets/up-vue.json"
90+
},
91+
{
92+
"language": "typescriptreact",
93+
"path": "./snippets/up-react.json"
94+
},
95+
{
96+
"language": "typescript",
97+
"path": "./snippets/up-ts.json"
8998
}
9099
]
91100
}

playground/index.ts

Whitespace-only changes.

playground/index.tsx

Whitespace-only changes.

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

snippets/up-react.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"React Functional Component": {
3+
"prefix": "up-rfc",
4+
"body": [
5+
"import React, { useState } from'react'",
6+
"",
7+
"const myComponent = () => {",
8+
"\tconst [count, setCount] = useState(0)",
9+
"\treturn (<>",
10+
"\t\t<div>",
11+
"\t\t\t<p>Count: {count}</p>",
12+
"\t\t</div>",
13+
"\t</>)",
14+
"}",
15+
"export default myComponent"
16+
],
17+
"description": "React Functional Component"
18+
}
19+
}

snippets/up-ts.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"Vue3 Composition API": {
3+
"prefix": "up-v3use",
4+
"body": [
5+
"import { ref } from 'vue'",
6+
"",
7+
"export default function () {",
8+
"\tconst count = ref<string>('')",
9+
"",
10+
"\treturn {",
11+
"\t\tcount",
12+
"\t}",
13+
"}"
14+
],
15+
"description": "Vue3 Composition API"
16+
},
17+
"Vue3 createPinia API": {
18+
"prefix": "up-v3pinia-create",
19+
"body": [
20+
"import { createPinia } from 'pinia'",
21+
"const pinia = createPinia()",
22+
"app.use(pinia)"
23+
],
24+
"description": "Vue3 createPinia API"
25+
},
26+
"Vue3 define Pinia Store":{
27+
"prefix": "up-v3pinia-store",
28+
"body": [
29+
"export const useStore = defineStore('store', () => {",
30+
"\tconst myStore = ref('')",
31+
"\treturn {",
32+
"\t\tmyStore",
33+
"\t}",
34+
"})"
35+
],
36+
"description": "Vue3 define Pinia Store"
37+
},
38+
"React Hooks": {
39+
"prefix": "up-ruse",
40+
"body": [
41+
"import { useState } from 'react'",
42+
"",
43+
"export default function () {",
44+
"\tconst [count, setCount] = useState(0)",
45+
"",
46+
"\treturn [",
47+
"\t\tcount",
48+
"\t]",
49+
"}"
50+
],
51+
"description": "React Hooks"
52+
}
53+
}
Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Vue Single File Component With Props Setup Less Ts": {
3-
"prefix": "up-v3-c-setup-ts-less-scoped",
3+
"prefix": "up-v3comp-less",
44
"body": [
55
"<template>",
66
"\t<div class=\"container\">",
@@ -9,21 +9,20 @@
99
"</template>",
1010
"",
1111
"<script setup lang=\"ts\">",
12-
"\timport { ref } from 'vue'",
13-
"\t\t${0}",
14-
"\t",
12+
"import { ref } from 'vue'",
13+
"${0}",
1514
"</script>",
1615
"",
1716
"<style lang=\"less\" scoped>",
18-
"\t.container {",
19-
"\t\t${0}",
20-
"\t}",
17+
".container {",
18+
"\t${0}",
19+
"}",
2120
"</style>"
2221
],
2322
"description": "Vue3 Component with setup, ts, less, scoped"
2423
},
25-
"Vue Single File Component With Props Setup Scss Ts": {
26-
"prefix": "up-v3-c-setup-ts-scss-scoped",
24+
"Vue Single File Component With Props Setup Scss Ts": {
25+
"prefix": "up-v3comp-scss",
2726
"body": [
2827
"<template>",
2928
"\t<div class=\"container\">",
@@ -32,17 +31,31 @@
3231
"</template>",
3332
"",
3433
"<script setup lang=\"ts\">",
35-
"\timport { ref } from 'vue'",
36-
"\t\t${0}",
37-
"\t",
34+
"import { ref } from 'vue'",
35+
"${0}",
3836
"</script>",
3937
"",
4038
"<style lang=\"scss\" scoped>",
41-
"\t.container {",
42-
"\t\t${0}",
43-
"\t}",
39+
".container {",
40+
"\t${0}",
41+
"}",
4442
"</style>"
4543
],
4644
"description": "Vue3 Component with setup, ts, less, scoped"
45+
},
46+
"Vue3 Composition API": {
47+
"prefix": "up-v3use",
48+
"body": [
49+
"import { ref } from 'vue'",
50+
"",
51+
"export default function () {",
52+
"\tconst count = ref<string>('')",
53+
"",
54+
"\treturn {",
55+
"\t\tcount",
56+
"\t}",
57+
"}"
58+
],
59+
"description": "Vue3 Composition API"
4760
}
4861
}

snippets/vue-pug.json

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)