mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-14 01:46:52 -04:00
feat(ui-lib): demo pages for c-lib components
This commit is contained in:
parent
e88c1d5f2c
commit
92bd83536f
14 changed files with 294 additions and 248 deletions
33
src/ui/demo/demo-wrapper.vue
Normal file
33
src/ui/demo/demo-wrapper.vue
Normal file
|
@ -0,0 +1,33 @@
|
|||
<template>
|
||||
<div mt-2 w-full p-8>
|
||||
<h1>c-lib components</h1>
|
||||
|
||||
<div flex>
|
||||
<div w-30 b-r b-gray b-op-10 b-r-solid pr-4>
|
||||
<c-button
|
||||
v-for="{ name } of demoRoutes"
|
||||
:key="name"
|
||||
variant="text"
|
||||
:to="{ name }"
|
||||
w-full
|
||||
important:justify-start
|
||||
:type="route.name === name ? 'primary' : 'default'"
|
||||
>
|
||||
{{ name }}
|
||||
</c-button>
|
||||
</div>
|
||||
|
||||
<div flex-1 pl-4>
|
||||
<router-view />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { demoRoutes } from './demo.routes';
|
||||
|
||||
const route = useRoute();
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
25
src/ui/demo/demo.routes.ts
Normal file
25
src/ui/demo/demo.routes.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import type { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
const demoPages = import.meta.glob('../*/*.demo.vue');
|
||||
|
||||
export const demoRoutes = Object.keys(demoPages).map((path) => {
|
||||
const [, , fileName] = path.split('/');
|
||||
const name = fileName.split('.').shift();
|
||||
|
||||
console.log(path);
|
||||
|
||||
return {
|
||||
path: name,
|
||||
name,
|
||||
component: () => import(/* @vite-ignore */ path),
|
||||
} as RouteRecordRaw;
|
||||
});
|
||||
|
||||
export const routes = [
|
||||
{
|
||||
path: '/c-lib',
|
||||
name: 'c-lib',
|
||||
children: demoRoutes,
|
||||
component: () => import('./demo-wrapper.vue'),
|
||||
},
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue