vanilla-vue-ui 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/basic/app-bar/WAppBar.stories.ts +41 -0
- package/basic/app-bar/WAppBar.vue +48 -0
- package/basic/banner/BannerStore.ts +54 -0
- package/basic/banner/WBanner.stories.ts +28 -0
- package/basic/banner/WBanner.vue +41 -0
- package/basic/breadcrumb/WBreadcrumb.stories.ts +25 -0
- package/basic/breadcrumb/WBreadcrumb.vue +97 -0
- package/basic/button/ButtonSize.ts +2 -0
- package/basic/button/WButton.spec.ts +17 -0
- package/basic/button/WButton.stories.ts +68 -0
- package/basic/button/WButton.vue +81 -0
- package/basic/icon/WIcon.vue +5 -0
- package/basic/range/WRange.vue +113 -17
- package/basic/text-field/TextFieldSize.ts +2 -0
- package/basic/text-field/WTextField.stories.ts +88 -0
- package/basic/text-field/WTextField.vue +188 -0
- package/basic/tooltip/WTooltip.stories.ts +87 -0
- package/basic/tooltip/WTooltip.vue +63 -0
- package/package.json +44 -30
- package/template/footer-simple/WFooterSimple.stories.ts +23 -0
- package/template/footer-simple/WFooterSimple.vue +20 -0
- package/template/navigation-drawer/NavigationDrawer.stories.ts +59 -0
- package/template/navigation-drawer/NavigationDrawer.vue +121 -0
- package/template/navigation-drawer/NavigationDrawerContent.ts +11 -0
- package/template/primary-button/WPrimaryButton.spec.ts +17 -0
- package/template/primary-button/WPrimaryButton.stories.ts +30 -0
- package/template/primary-button/WPrimaryButton.vue +9 -0
- package/template/secondary-button/WSecondaryButton.spec.ts +17 -0
- package/template/secondary-button/WSecondaryButton.stories.ts +30 -0
- package/template/secondary-button/WSecondaryButton.vue +9 -0
- package/template/tree-menu/TreeMenuContent.ts +11 -0
- package/template/tree-menu/WTreeMenu.stories.ts +55 -0
- package/template/tree-menu/WTreeMenu.vue +152 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<TransitionRoot as="template" :show="sidebarOpen">
|
|
4
|
+
<Dialog as="div" class="relative z-50 lg:hidden" @close="sidebarOpen = false">
|
|
5
|
+
<TransitionChild as="template" enter="transition-opacity ease-linear duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="transition-opacity ease-linear duration-300" leave-from="opacity-100" leave-to="opacity-0">
|
|
6
|
+
<div class="fixed inset-0 bg-gray-900/80" />
|
|
7
|
+
</TransitionChild>
|
|
8
|
+
|
|
9
|
+
<div class="fixed inset-0 flex">
|
|
10
|
+
<TransitionChild as="template" enter="transition ease-in-out duration-300 transform" enter-from="-translate-x-full" enter-to="translate-x-0" leave="transition ease-in-out duration-300 transform" leave-from="translate-x-0" leave-to="-translate-x-full">
|
|
11
|
+
<DialogPanel class="relative mr-16 flex w-full max-w-xs flex-1">
|
|
12
|
+
<TransitionChild as="template" enter="ease-in-out duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="ease-in-out duration-300" leave-from="opacity-100" leave-to="opacity-0">
|
|
13
|
+
<div class="absolute left-full top-0 flex w-16 justify-center pt-5">
|
|
14
|
+
<button type="button" class="-m-2.5 p-2.5" @click="sidebarOpen = false">
|
|
15
|
+
<span class="sr-only">Close sidebar</span>
|
|
16
|
+
<XMarkIcon class="h-6 w-6 text-white" aria-hidden="true" />
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
</TransitionChild>
|
|
20
|
+
<div class="flex grow flex-col gap-y-5 overflow-y-auto bg-surface dark:bg-surface-dark px-6 pb-2">
|
|
21
|
+
<div class="flex h-4 shrink-0 items-center"/>
|
|
22
|
+
<nav class="flex flex-1 flex-col">
|
|
23
|
+
<ul role="list" class="flex flex-1 flex-col gap-y-7">
|
|
24
|
+
<li>
|
|
25
|
+
<ul role="list" class="-mx-2 space-y-1">
|
|
26
|
+
<TreeMenu :navigation-items="navigationTop"/>
|
|
27
|
+
</ul>
|
|
28
|
+
</li>
|
|
29
|
+
|
|
30
|
+
<li class="-mx-6 mt-auto px-6 py-2">
|
|
31
|
+
<ul role="list" class="-mx-2 space-y-1">
|
|
32
|
+
<TreeMenu :navigation-items="navigationBottom"/>
|
|
33
|
+
</ul>
|
|
34
|
+
</li>
|
|
35
|
+
|
|
36
|
+
</ul>
|
|
37
|
+
</nav>
|
|
38
|
+
</div>
|
|
39
|
+
</DialogPanel>
|
|
40
|
+
</TransitionChild>
|
|
41
|
+
</div>
|
|
42
|
+
</Dialog>
|
|
43
|
+
</TransitionRoot>
|
|
44
|
+
|
|
45
|
+
<!-- Static sidebar for desktop -->
|
|
46
|
+
<div class="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-72 lg:flex-col">
|
|
47
|
+
<!-- Sidebar component, swap this element with another sidebar if you like -->
|
|
48
|
+
<div class="flex grow flex-col gap-y-5 overflow-y-auto border-r border-outline dark:border-outline-dark bg-surface dark:bg-surface-dark px-6">
|
|
49
|
+
<div class="flex h-4 shrink-0 items-center">
|
|
50
|
+
<!-- <img class="h-8 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company" /> -->
|
|
51
|
+
</div>
|
|
52
|
+
<nav class="flex flex-1 flex-col">
|
|
53
|
+
<ul role="list" class="flex flex-1 flex-col gap-y-7">
|
|
54
|
+
<li>
|
|
55
|
+
<ul role="list" class="-mx-2 space-y-1">
|
|
56
|
+
<TreeMenu :navigation-items="navigationTop"/>
|
|
57
|
+
</ul>
|
|
58
|
+
</li>
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<li class="-mx-6 mt-auto p-6 px-2">
|
|
62
|
+
<ul role="list" class="mx-2 space-y-1">
|
|
63
|
+
<TreeMenu :navigation-items="navigationBottom"/>
|
|
64
|
+
</ul>
|
|
65
|
+
</li>
|
|
66
|
+
</ul>
|
|
67
|
+
</nav>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<AppBar class="" :title="title" @open="sidebarOpen = true"/>
|
|
72
|
+
|
|
73
|
+
<main class="lg:pl-72">
|
|
74
|
+
<div class="">
|
|
75
|
+
<!-- Your content -->
|
|
76
|
+
<slot />
|
|
77
|
+
</div>
|
|
78
|
+
</main>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<script setup lang="ts">
|
|
83
|
+
import type { NavigationDrawerContent } from './NavigationDrawerContent'
|
|
84
|
+
import { ref, watch, type PropType } from 'vue'
|
|
85
|
+
import { useRoute } from 'vue-router'
|
|
86
|
+
import { Dialog, DialogPanel, TransitionChild, TransitionRoot } from '@headlessui/vue'
|
|
87
|
+
import { XMarkIcon } from '@heroicons/vue/24/outline'
|
|
88
|
+
import TreeMenu from '../tree-menu/WTreeMenu.vue'
|
|
89
|
+
import AppBar from '../../basic/app-bar/WAppBar.vue'
|
|
90
|
+
|
|
91
|
+
const props = defineProps({
|
|
92
|
+
title: {
|
|
93
|
+
type: String as PropType<string>,
|
|
94
|
+
default: "Dashboard"
|
|
95
|
+
},
|
|
96
|
+
navigationTop: {
|
|
97
|
+
type: Array as PropType<NavigationDrawerContent[]>,
|
|
98
|
+
required: true
|
|
99
|
+
},
|
|
100
|
+
navigationBottom: {
|
|
101
|
+
type: Array as PropType<NavigationDrawerContent[]>,
|
|
102
|
+
required: true
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const navigationTop = ref(props.navigationTop)
|
|
107
|
+
const navigationBottom = ref(props.navigationBottom)
|
|
108
|
+
|
|
109
|
+
const sidebarOpen = ref(false)
|
|
110
|
+
|
|
111
|
+
const route = useRoute()
|
|
112
|
+
|
|
113
|
+
watch(route, (newRoute) => {
|
|
114
|
+
// current、isOpen を設定
|
|
115
|
+
navigationTop.value.forEach(item => {
|
|
116
|
+
item.current = item.href === newRoute.path;
|
|
117
|
+
// current だったら sub を表示させる
|
|
118
|
+
item.isOpen = true
|
|
119
|
+
});
|
|
120
|
+
}, { immediate: true });
|
|
121
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import PrimaryButton from './WPrimaryButton.vue'; // コンポーネントのパスを適切に設定してください
|
|
4
|
+
|
|
5
|
+
describe('PrimaryButton', () => {
|
|
6
|
+
it('renders correctly', () => {
|
|
7
|
+
const wrapper = mount(PrimaryButton, {
|
|
8
|
+
slots: {
|
|
9
|
+
default: 'Click Me'
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(wrapper.html()).toContain('Click Me');
|
|
14
|
+
expect(wrapper.classes()).toContain('bg-gradient-to-r');
|
|
15
|
+
expect(wrapper.classes()).toContain('from-primary');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Replace vue3 with vue if you are using Storybook for Vue 2
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
3
|
+
|
|
4
|
+
import Button from './WPrimaryButton.vue';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Button> = {
|
|
7
|
+
component: Button,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof Button>;
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
|
|
15
|
+
* See https://storybook.js.org/docs/api/csf
|
|
16
|
+
* to learn how to use render functions.
|
|
17
|
+
*/
|
|
18
|
+
export const Primary: Story = {
|
|
19
|
+
render: () => ({
|
|
20
|
+
components: { Button },
|
|
21
|
+
template: '<Button>OK</Button>',
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Block: Story = {
|
|
26
|
+
render: () => ({
|
|
27
|
+
components: { Button },
|
|
28
|
+
template: '<Button block>OK</Button>',
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Button class="bg-gradient-to-r from-primary dark:from-primary-dark via-primaryVia dark:via-primaryVia-dark to-primaryTo dark:to-primaryTo-dark text-white font-bold">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</Button>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import Button from '../../basic/button/WButton.vue'
|
|
9
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import WSecondaryButton from './WSecondaryButton.vue'; // コンポーネントのパスを適切に設定してください
|
|
4
|
+
|
|
5
|
+
describe('SecondaryButton', () => {
|
|
6
|
+
it('renders correctly', () => {
|
|
7
|
+
const wrapper = mount(WSecondaryButton, {
|
|
8
|
+
slots: {
|
|
9
|
+
default: 'Click Me'
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(wrapper.html()).toContain('Click Me');
|
|
14
|
+
expect(wrapper.classes()).toContain('bg-gradient-to-r');
|
|
15
|
+
expect(wrapper.classes()).toContain('from-primary');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Replace vue3 with vue if you are using Storybook for Vue 2
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
3
|
+
|
|
4
|
+
import Button from './WSecondaryButton.vue';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Button> = {
|
|
7
|
+
component: Button,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof Button>;
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
|
|
15
|
+
* See https://storybook.js.org/docs/api/csf
|
|
16
|
+
* to learn how to use render functions.
|
|
17
|
+
*/
|
|
18
|
+
export const Primary: Story = {
|
|
19
|
+
render: () => ({
|
|
20
|
+
components: { Button },
|
|
21
|
+
template: '<Button>OK</Button>',
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Block: Story = {
|
|
26
|
+
render: () => ({
|
|
27
|
+
components: { Button },
|
|
28
|
+
template: '<Button block>OK</Button>',
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Replace vue3 with vue if you are using Storybook for Vue 2
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
3
|
+
import WTreeMenu from './WTreeMenu.vue';
|
|
4
|
+
import {
|
|
5
|
+
HomeIcon,
|
|
6
|
+
BellAlertIcon,
|
|
7
|
+
ChatBubbleBottomCenterTextIcon,
|
|
8
|
+
Cog6ToothIcon,
|
|
9
|
+
CurrencyYenIcon,
|
|
10
|
+
CubeIcon,
|
|
11
|
+
BookOpenIcon,
|
|
12
|
+
MinusIcon
|
|
13
|
+
} from '@heroicons/vue/24/outline'
|
|
14
|
+
|
|
15
|
+
type WTreeMenuProps = InstanceType<typeof WTreeMenu>['$props']
|
|
16
|
+
|
|
17
|
+
const meta: Meta<typeof WTreeMenu> = {
|
|
18
|
+
component: WTreeMenu,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof WTreeMenu>;
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
|
|
26
|
+
* See https://storybook.js.org/docs/api/csf
|
|
27
|
+
* to learn how to use render functions.
|
|
28
|
+
*/
|
|
29
|
+
export const Primary: Story = {
|
|
30
|
+
render: (args: WTreeMenuProps) => ({
|
|
31
|
+
setup() {
|
|
32
|
+
return {
|
|
33
|
+
...args
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
components: { WTreeMenu },
|
|
37
|
+
template: '<WTreeMenu :navigationItems="navigationItems"></WTreeMenu>',
|
|
38
|
+
}),
|
|
39
|
+
args: {
|
|
40
|
+
navigationItems: [
|
|
41
|
+
{ name: 'メニュー', href: '/menu', onClick: undefined, icon: HomeIcon, current: false },
|
|
42
|
+
{ name: 'リクエスト', href: '/request', icon: CubeIcon, current: false },
|
|
43
|
+
{ name: '履歴', href: '/history', icon: BookOpenIcon, current: false },
|
|
44
|
+
{ name: '支払い', href: '/payment', icon: CurrencyYenIcon, current: false, isOpen: true,
|
|
45
|
+
subItems: [
|
|
46
|
+
{ name: '現金', href: '/payment', icon: MinusIcon, current: false },
|
|
47
|
+
{ name: 'クレジット', href: '/payment', icon: MinusIcon, current: false }
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{ name: 'メッセージ', href: '/message', icon: BellAlertIcon, current: false },
|
|
51
|
+
{ name: '問い合わせ', href: '/contact', icon: ChatBubbleBottomCenterTextIcon, current: false },
|
|
52
|
+
{ name: '設定', href: '/setting', icon: Cog6ToothIcon, current: false },
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ul role="list" class="flex flex-1 flex-col gap-y-7">
|
|
3
|
+
<li>
|
|
4
|
+
<ul role="list" class="-mx-2 space-y-1">
|
|
5
|
+
<li v-for="item in navigationItems" :key="item.name">
|
|
6
|
+
|
|
7
|
+
<SecondaryButton v-if="item.onClick" block @click="clickNavigation(item.onClick)">
|
|
8
|
+
<component :is="item.icon" :class="[item.current ? 'text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark group-hover:text-primary dark:group-hover:text-primary-dark', 'h-6 w-6 shrink-0 inline mx-2']" aria-hidden="true" />
|
|
9
|
+
{{ item.name }}
|
|
10
|
+
</SecondaryButton>
|
|
11
|
+
|
|
12
|
+
<!-- メインアイテム -->
|
|
13
|
+
<div v-else class="flex hover:bg-surfaceHover dark:hover:bg-surfaceHover-dark text-onSurface dark:text-onSurface-dark hover:text-primary dark:hover:text-primary-dark rounded-xl">
|
|
14
|
+
|
|
15
|
+
<!-- メインアイテム(リンク) -->
|
|
16
|
+
<a
|
|
17
|
+
v-if="item.subItems === undefined"
|
|
18
|
+
:href="item.href"
|
|
19
|
+
:class="[
|
|
20
|
+
item.current ? 'bg-surfaceHover dark:bg-surfaceHover-dark text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark hover:text-primary dark:hover:text-primary-dark hover:bg-surfaceHover dark:hover:bg-surfaceHover-dark',
|
|
21
|
+
'group flex-auto flex gap-x-3 rounded-xl p-2 text-sm leading-6 font-semibold'
|
|
22
|
+
]"
|
|
23
|
+
>
|
|
24
|
+
<component
|
|
25
|
+
:is="item.icon"
|
|
26
|
+
:class="[
|
|
27
|
+
item.current ? 'text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark group-hover:text-primary dark:group-hover:text-primary-dark',
|
|
28
|
+
'h-6 w-6 shrink-0'
|
|
29
|
+
]"
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
/>
|
|
32
|
+
{{ item.name }}
|
|
33
|
+
</a>
|
|
34
|
+
|
|
35
|
+
<!-- メインアイテム(矢印) -->
|
|
36
|
+
<span
|
|
37
|
+
v-else
|
|
38
|
+
:class="[
|
|
39
|
+
item.current ? 'bg-surfaceHover dark:bg-surfaceHover-dark text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark hover:text-primary dark:hover:text-primary-dark hover:bg-surfaceHover dark:hover:bg-surfaceHover-dark',
|
|
40
|
+
'group flex-auto flex gap-x-3 rounded-xl p-2 text-sm leading-6 font-semibold'
|
|
41
|
+
]"
|
|
42
|
+
@click="toggleSubItems(item)">
|
|
43
|
+
|
|
44
|
+
<!-- <div class="text-onSurface dark:text-onSurface-dark"> -->
|
|
45
|
+
<component
|
|
46
|
+
:is="ChevronRightIcon"
|
|
47
|
+
v-if="item.isOpen === false"
|
|
48
|
+
:class="[
|
|
49
|
+
'text-onSurface dark:text-onSurface-dark',
|
|
50
|
+
'h-6 w-6 shrink-0 inline'
|
|
51
|
+
]"
|
|
52
|
+
/>
|
|
53
|
+
<component
|
|
54
|
+
:is="ChevronDownIcon"
|
|
55
|
+
v-if="item.isOpen === true"
|
|
56
|
+
:class="[
|
|
57
|
+
'text-onSurface dark:text-onSurface-dark',
|
|
58
|
+
'h-6 w-6 shrink-0 inline'
|
|
59
|
+
]"
|
|
60
|
+
/>
|
|
61
|
+
<!-- </div> -->
|
|
62
|
+
|
|
63
|
+
<!-- ここまで -->
|
|
64
|
+
<component
|
|
65
|
+
:is="item.icon"
|
|
66
|
+
:class="[
|
|
67
|
+
item.current ? 'text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark group-hover:text-primary dark:group-hover:text-primary-dark',
|
|
68
|
+
'h-6 w-6 shrink-0'
|
|
69
|
+
]"
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
/>
|
|
72
|
+
{{ item.name }}
|
|
73
|
+
</span>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<!-- サブアイテム -->
|
|
77
|
+
<template v-if="item.subItems && item.isOpen === true">
|
|
78
|
+
<ul role="list" class="ml-4 space-y-1">
|
|
79
|
+
<li v-for="subItem in item.subItems" :key="subItem.name">
|
|
80
|
+
<SecondaryButton v-if="subItem.onClick" block @click="clickNavigation(subItem.onClick)">
|
|
81
|
+
<component :is="subItem.icon" :class="[subItem.current ? 'text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark group-hover:text-primary dark:group-hover:text-primary-dark', 'h-6 w-6 shrink-0 inline mx-2']" aria-hidden="true" />
|
|
82
|
+
{{ subItem.name }}
|
|
83
|
+
</SecondaryButton>
|
|
84
|
+
|
|
85
|
+
<a
|
|
86
|
+
v-else
|
|
87
|
+
:href="subItem.href"
|
|
88
|
+
:class="[
|
|
89
|
+
subItem.current ? 'bg-surfaceHover dark:bg-surfaceHover-dark text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark hover:text-primary dark:hover:text-primary-dark hover:bg-surfaceHover dark:hover:bg-surfaceHover-dark',
|
|
90
|
+
'group flex gap-x-3 rounded-xl p-2 text-sm leading-6 font-semibold'
|
|
91
|
+
]"
|
|
92
|
+
>
|
|
93
|
+
<component
|
|
94
|
+
:is="subItem.icon"
|
|
95
|
+
:class="[
|
|
96
|
+
subItem.current ? 'text-primary dark:text-primary-dark' : 'text-onSurface dark:text-onSurface-dark group-hover:text-primary dark:group-hover:text-primary-dark',
|
|
97
|
+
'h-6 w-6 shrink-0'
|
|
98
|
+
]"
|
|
99
|
+
aria-hidden="true"
|
|
100
|
+
/>
|
|
101
|
+
{{ subItem.name }}
|
|
102
|
+
</a>
|
|
103
|
+
</li>
|
|
104
|
+
</ul>
|
|
105
|
+
</template>
|
|
106
|
+
</li>
|
|
107
|
+
</ul>
|
|
108
|
+
</li>
|
|
109
|
+
</ul>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<script setup lang="ts">
|
|
113
|
+
import type { TreeMenuContent } from './TreeMenuContent'
|
|
114
|
+
import { ref, type PropType } from 'vue'
|
|
115
|
+
import {
|
|
116
|
+
ChevronRightIcon,
|
|
117
|
+
ChevronDownIcon
|
|
118
|
+
} from '@heroicons/vue/24/outline'
|
|
119
|
+
import SecondaryButton from '../secondary-button/WSecondaryButton.vue'
|
|
120
|
+
|
|
121
|
+
const props = defineProps({
|
|
122
|
+
navigationItems: {
|
|
123
|
+
type: Array as PropType<TreeMenuContent[]>,
|
|
124
|
+
required: true
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const navigationItems = ref(props.navigationItems)
|
|
129
|
+
|
|
130
|
+
function clickNavigation(func: (() => void) | null | undefined) {
|
|
131
|
+
if (func) {
|
|
132
|
+
func();
|
|
133
|
+
} else {
|
|
134
|
+
console.error("func is null or undefined");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function toggleSubItems(item: TreeMenuContent) {
|
|
139
|
+
navigationItems.value = navigationItems.value.map((currentItem: TreeMenuContent) => {
|
|
140
|
+
if (currentItem.name === item.name) {
|
|
141
|
+
|
|
142
|
+
if (currentItem.isOpen === true) {
|
|
143
|
+
currentItem.isOpen = false
|
|
144
|
+
} else {
|
|
145
|
+
currentItem.isOpen = true
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
return currentItem
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
</script>
|