Skip to content

Commit 973da6a

Browse files
committed
feat: add unplugin-vue-components volar plugin
1 parent 494afb6 commit 973da6a

File tree

7 files changed

+88
-62
lines changed

7 files changed

+88
-62
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ See [Vitesse](https://github.com/antfu/vitesse) for full feature set.
8484
If you prefer to do it manually with the cleaner git history
8585

8686
```bash
87-
npx degit @vue-macros/vitesse-jsxmy-vitesse-app
87+
npx degit @vue-macros/vitesse-jsx my-vitesse-app
8888
cd my-vitesse-app
8989
pnpm i # If you don't have pnpm installed, run: npm install -g pnpm
9090
```

README.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
如果您更喜欢使用更干净的 git 历史记录手动执行此操作
8686

8787
```bash
88-
npx degit @vue-macros/vitesse-jsxmy-vitesse-app
88+
npx degit @vue-macros/vitesse-jsx my-vitesse-app
8989
cd my-vitesse-app
9090
pnpm i # 如果你没装过 pnpm, 可以先运行: npm install -g pnpm
9191
```

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@unocss/eslint-plugin": "^0.64.1",
2626
"@unocss/reset": "^0.64.1",
2727
"@vitejs/plugin-vue-jsx": "^4.1.0",
28-
"@vue-macros/jsx": "https://pkg.pr.new/vue-macros/vue-macros/@vue-macros/jsx@904d806",
28+
"@vue-macros/jsx": "https://pkg.pr.new/vue-macros/vue-macros/@vue-macros/jsx@9e7d673",
2929
"@vue/test-utils": "^2.4.6",
3030
"eslint": "^9.15.0",
3131
"eslint-plugin-format": "^0.1.2",
@@ -38,7 +38,7 @@
3838
"typescript": "^5.7.2",
3939
"unocss": "^0.64.1",
4040
"unplugin-auto-import": "^0.18.5",
41-
"unplugin-vue-components-jsx": "0.27.3-1",
41+
"unplugin-vue-components": "npm:unplugin-vue-components-jsx@0.27.4-2",
4242
"unplugin-vue-router": "https://pkg.pr.new/unplugin-vue-router@6e5dc20",
4343
"vite": "^5.4.11",
4444
"vite-plugin-inspect": "^0.8.8",

pnpm-lock.yaml

+50-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/TheCounter.tsx

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
1+
/**
2+
* ## The Counter
3+
*/
14
export default defineComponent(({
25
initial = undefined as undefined | number,
36
}) => {
47
const { count, inc, dec } = useCounter(initial)
58

9+
const color = computed(() => (index: number) => (
10+
index
11+
? count.value >= index
12+
: count.value <= index)
13+
? 'green'
14+
: 'red',
15+
)
16+
17+
const styles = defineStyle(`
18+
.inc, .dec {
19+
@apply px3 b-(2 solid rounded [${color.value(1)}]);
20+
}
21+
.dec {
22+
@apply b-[${color.value(0)}];
23+
}
24+
`)
25+
26+
const slots = defineSlots({
27+
default: ({ value }: { value: number }) => <div class={styles.inc}>{value}</div>,
28+
})
29+
630
return () => (
7-
<div>
8-
{ count.value }
9-
<button class="inc" onClick={() => inc()}>
31+
<div gap3 mb3 flex="~ justify-center">
32+
33+
<slots.default value={count.value} />
34+
35+
<button class={styles.inc} onClick={() => inc()}>
1036
+
1137
</button>
12-
<button class="dec" onClick={() => dec()}>
38+
<button class={styles.dec} onClick={() => dec()}>
1339
-
1440
</button>
1541
</div>

src/pages/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export default defineComponent(() => {
2525

2626
<div py-4 />
2727

28+
<TheCounter />
29+
2830
<TheInput
2931
v-model={name.value}
3032
placeholder="What's your name?"

vite.config.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
55
import VueJsxMacros from '@vue-macros/jsx/vite'
66
import UnoCSS from 'unocss/vite'
77
import AutoImport from 'unplugin-auto-import/vite'
8-
import Components from 'unplugin-vue-components-jsx/vite'
8+
import Components from 'unplugin-vue-components/vite'
99
import { VueRouterAutoImports } from 'unplugin-vue-router'
1010
import VueRouter from 'unplugin-vue-router/vite'
1111
import { defineConfig } from 'vite'
@@ -20,9 +20,7 @@ export default defineConfig({
2020
},
2121
plugins: [
2222
// https://github.com/vue-macros/vue-macros
23-
VueJsxMacros({
24-
jsxMacros: true,
25-
}),
23+
VueJsxMacros(),
2624

2725
// https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx
2826
vueJsx(),

0 commit comments

Comments
 (0)