Skip to content

Commit 004e714

Browse files
committed
docs: add unplugin-vue-components integration docs
1 parent 6c66b72 commit 004e714

File tree

9 files changed

+123
-3
lines changed

9 files changed

+123
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { BaseBlock } from './../../runtime';
2+
import { definePageConfigBlock } from '../../types'
3+
import Component from './index.vue'
4+
5+
export default definePageConfigBlock({
6+
setup (tabs: Record<string, BaseBlock[]>) {
7+
return {
8+
type: 'collapse' as const,
9+
tabs
10+
}
11+
},
12+
component: Component,
13+
})
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<VaTabs v-model="value" class="mt-2">
3+
<template #tabs>
4+
<VaTab
5+
v-for="tab in tabNames"
6+
:key="tab"
7+
>
8+
{{ tab }}
9+
</VaTab>
10+
</template>
11+
</VaTabs>
12+
<PageConfigBlocks :blocks="tabs[tabNames[value]]" />
13+
</template>
14+
15+
<script setup lang="ts">
16+
import { ref, computed } from 'vue'
17+
import { BaseBlock } from './../../runtime';
18+
import PageConfigBlocks from '../../runtime/PageConfigBlocks.vue';
19+
20+
const value = ref(0)
21+
22+
const props = defineProps<{
23+
tabs: Record<string, BaseBlock[]>
24+
}>()
25+
26+
const tabNames = computed(() => Object.keys(props.tabs))
27+
</script>

packages/docs/modules/page-config/runtime/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import table from '../blocks/table'
2020
import cards from '../blocks/cards'
2121
import changeLog from '../blocks/change-log';
2222
import tags from '../blocks/tags';
23+
import tabs from '../blocks/tabs';
2324
import { APIDescriptionOptions, type ManualApiOptions } from '../blocks/api/types'
2425

2526
// Need to define type in collapse without recursion
26-
const blocksWithoutCollapse = {
27+
const baseBlocks = {
2728
alert,
2829
example,
2930
title,
@@ -44,12 +45,13 @@ const blocksWithoutCollapse = {
4445
tags,
4546
}
4647

47-
export type BaseBlock = ReturnType<(typeof blocksWithoutCollapse)[keyof typeof blocksWithoutCollapse]>
48+
export type BaseBlock = ReturnType<(typeof baseBlocks)[keyof typeof baseBlocks]>
4849

4950
export const block = {
50-
...blocksWithoutCollapse,
51+
...baseBlocks,
5152
collapse,
5253
async,
54+
tabs,
5355
}
5456

5557
export type GlobalBlock = typeof block
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// vite.config.ts
2+
import { defineConfig } from 'vite';
3+
import Components from 'unplugin-vue-components/vite'
4+
5+
export default defineConfig({
6+
plugins: [
7+
Components({
8+
resolvers: [
9+
(componentName) => {
10+
if (componentName.startsWith('Va'))
11+
return { name: componentName, from: 'vuestic-ui' }
12+
},
13+
],
14+
}),
15+
],
16+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// webpack.config.js
2+
module.exports = {
3+
/* ... */
4+
plugins: [
5+
require('unplugin-vue-components/webpack').default({
6+
resolvers: [
7+
(componentName) => {
8+
if (componentName.startsWith('Va'))
9+
return { name: componentName, from: 'vuestic-ui' }
10+
},
11+
],
12+
}),
13+
],
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createApp } from "vue";
2+
import { createVuesticEssential } from "vuestic-ui";
3+
import "vuestic-ui/css";
4+
import App from "./App.vue";
5+
6+
createApp(App)
7+
.use(
8+
createVuesticEssential({
9+
config: {
10+
/* ... */
11+
},
12+
})
13+
)
14+
.mount("#app");
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export default definePageConfig({
2+
blocks: [
3+
block.title('Unplugin Vue Components'),
4+
block.paragraph('[Unplugin Vue Components](https://github.com/unplugin/unplugin-vue-components) is a Vite/Webpack plugin that automatically imports Vue components from your dependencies.'),
5+
block.paragraph('You can use to import components from Vuestic UI without registering them globally or importing them in every file.'),
6+
7+
block.tabs({
8+
'vite': [
9+
block.code('installation.vite')
10+
],
11+
'webpack': [
12+
block.code('installation.webpack')
13+
],
14+
}),
15+
16+
block.paragraph('After installing the plugin, you can use components from Vuestic UI without importing them. But you need to prevent them from global registration. Use `createVuesticEssential` to register Vuestic without global components. Read more about tree-shaking [here](/getting-started/tree-shaking)'),
17+
18+
block.code('vuestic-setup'),
19+
20+
block.paragraph('When working with [Nuxt](/getting-started/nuxt) this feature is built-in.'),
21+
]
22+
})

packages/docs/page-config/getting-started/tree-shaking/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export default definePageConfig({
1010
block.title("Tree shaking"),
1111
block.paragraph("If you plan to use only several components in your application and thus reduce the size of your bundle, you can use the Vuestic ESM build. Webpack (vue-cli) and Vite do that automatically."),
1212

13+
block.alert('It is recommended to use special tools like [Unplugin Vue Components](/extensions/unplugin-vue-components) for SPA Vite/Webpack or [Nuxt](/getting-started/nuxt) that tree-shake components automatically.', 'info'),
14+
1315
block.paragraph("First, you don't need to use `createVuestic` since it registers all the `vuestic` components globally. We have `createVuesticEssential` instead, which register only essential plugins. You can specify components to declare globally. Or you can import them later."),
1416
block.code("tree-shaking"),
1517
block.paragraph("You can also specify Vuestic subplugins as `plugins` option. "),

packages/docs/page-config/navigationRoutes.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export const navigationRoutes: NavigationRoute[] = [
6161
{
6262
name: "tree-shaking",
6363
displayName: "Tree Shaking",
64+
meta: {
65+
badge: navigationBadge.updated('1.9.9'),
66+
}
6467
},
6568
{
6669
name: "nuxt",
@@ -607,6 +610,13 @@ export const navigationRoutes: NavigationRoute[] = [
607610
badge: navigationBadge.new('1.6.0'),
608611
}
609612
},
613+
{
614+
name: 'unplugin-vue-components',
615+
displayName: 'Auto import plugin',
616+
meta: {
617+
badge: navigationBadge.new('1.9.9'),
618+
}
619+
}
610620
],
611621
},
612622
];

0 commit comments

Comments
 (0)