@modelmenu/navigation 1.0.0
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/README.MD +66 -0
- package/dist/index.es.js +4430 -0
- package/dist/index.umd.js +568 -0
- package/menu/MenuPlate.vue +523 -0
- package/menu/components/menu-item.vue +226 -0
- package/menu/components/sub-menu-items.vue +123 -0
- package/menu/components/top-menu-items/top-menu-item.vue +142 -0
- package/menu/components/top-menu-items/top-sub-menu-items.vue +113 -0
- package/menu/index.d.ts +2 -0
- package/menu/index.ts +2 -0
- package/menu/models/menu-models.ts +49 -0
- package/menu/resources/theme.ts +42 -0
- package/menu/routing/routing.ts +43 -0
- package/package.json +50 -0
- package/tsconfig.json +55 -0
- package/vite.config.ts +25 -0
- package/vue.config.js +30 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="menu-item" :ref="ref" @click="openSubMenu(item)" :class="{ 'item-opened': item.opened, 'item-closed': !item.opened, 'item-active': item.active }">
|
|
3
|
+
<FontAwesomeIcon class="menu-item-icon" v-if="item.icon" :size="'lg'" :icon="item.icon"></FontAwesomeIcon>
|
|
4
|
+
<p class="menu-item-text" :class="{'menu-text-opened': menuBar.opened, 'menu-text-closed': !menuBar.opened }"> {{ item.name }}</p>
|
|
5
|
+
<div class="sub-menu-button" v-if="item.items?.length">
|
|
6
|
+
<FontAwesomeIcon :class="{'menu-text-opened': menuBar.opened, 'menu-text-closed': !menuBar.opened }" :icon="item.openIcon"></FontAwesomeIcon>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { ref } from 'vue';
|
|
13
|
+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
14
|
+
import { faChevronDown, faChevronRight } from '@fortawesome/free-solid-svg-icons';
|
|
15
|
+
import { router, to } from '../routing/routing';
|
|
16
|
+
import { LeftMenuItems } from '../models/menu-models';
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'MenuItem',
|
|
20
|
+
components: {
|
|
21
|
+
FontAwesomeIcon
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
item: {
|
|
25
|
+
type: Object,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
leftItems: {
|
|
29
|
+
type: Array,
|
|
30
|
+
default: () => [] as LeftMenuItems[]
|
|
31
|
+
},
|
|
32
|
+
menuBar: {
|
|
33
|
+
type: Object,
|
|
34
|
+
required: true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
faChevronDown: faChevronDown,
|
|
40
|
+
menuBar: this.menuBar,
|
|
41
|
+
tooltip: true,
|
|
42
|
+
item: this.item,
|
|
43
|
+
leftItems: this.leftItems as LeftMenuItems[],
|
|
44
|
+
ref: 'item',
|
|
45
|
+
rotuer: router,
|
|
46
|
+
to: to,
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
watch:{
|
|
50
|
+
menuBar(newVal: any) {
|
|
51
|
+
this.menuBar = newVal;
|
|
52
|
+
},
|
|
53
|
+
item(newVal: any) {
|
|
54
|
+
this.item = newVal;
|
|
55
|
+
},
|
|
56
|
+
leftItems(newVal: any) {
|
|
57
|
+
this.leftItems = newVal;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
emits: [
|
|
61
|
+
'changeMenuItem'
|
|
62
|
+
],
|
|
63
|
+
methods: {
|
|
64
|
+
openSubMenu(item: any) {
|
|
65
|
+
if(!item.items?.length){
|
|
66
|
+
to(item.route);
|
|
67
|
+
|
|
68
|
+
let activeItem = this.findItem(this.leftItems, item, true);
|
|
69
|
+
this.$emit('changeMenuItem', this.leftItems);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
item.opened = !item.opened;
|
|
73
|
+
item.openIcon = item.opened ? faChevronDown : faChevronRight;
|
|
74
|
+
|
|
75
|
+
if(!this.menuBar.opened){
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
findItem(items: any[], item: any, setActive: boolean): any | undefined {
|
|
80
|
+
for(const entry of items){
|
|
81
|
+
if(entry.id === item.id){
|
|
82
|
+
entry.active = setActive;
|
|
83
|
+
return entry;
|
|
84
|
+
}
|
|
85
|
+
if(entry.items?.length){
|
|
86
|
+
const found = this.findItem(entry.items, item, setActive);
|
|
87
|
+
if(found){
|
|
88
|
+
entry.active = setActive;
|
|
89
|
+
return found;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
},
|
|
95
|
+
setUnActiveItems(items: any[]) {
|
|
96
|
+
for(let item of items){
|
|
97
|
+
item.active = false;
|
|
98
|
+
if(item.items?.length){
|
|
99
|
+
this.setUnActiveItems(item.items);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
setActiveItem(items: any[], currentItem: any = null) {
|
|
104
|
+
for(let leftItem of items){
|
|
105
|
+
leftItem.active = leftItem.id === currentItem?.id;
|
|
106
|
+
if(leftItem.items?.length){
|
|
107
|
+
this.setActiveItem(leftItem.items, currentItem);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
showTooltipItems(event: any) {
|
|
112
|
+
if (!this.menuBar.opened) {
|
|
113
|
+
if(this.item.items?.length){
|
|
114
|
+
this.tooltip = true;
|
|
115
|
+
document.querySelector('.active-tooltip')?.classList.add('show');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
hideTooltipItems(event: any) {
|
|
120
|
+
if (!this.menuBar.opened) {
|
|
121
|
+
this.tooltip = false;
|
|
122
|
+
document.querySelector('.active-tooltip')?.classList.remove('show');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
<style scoped>
|
|
133
|
+
|
|
134
|
+
.menu-plate {
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-direction: column;
|
|
137
|
+
width: 100%;
|
|
138
|
+
height: 100%;
|
|
139
|
+
background-color: #2c2c2c;
|
|
140
|
+
color: white;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.horizontal-menu {
|
|
144
|
+
display: flex;
|
|
145
|
+
gap: 20px;
|
|
146
|
+
padding: 10px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.clicked {
|
|
150
|
+
background-color: lightgray;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.menu-item-text{
|
|
154
|
+
margin-left: 8px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.show{
|
|
158
|
+
display: flex;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.vertical-menu {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-direction: column;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 20px;
|
|
166
|
+
padding: 10px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.vertical-menu-opened {
|
|
170
|
+
width: 200px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.svg-inline--fa {
|
|
174
|
+
color: rgba(60, 60, 60, 0.8) !important;
|
|
175
|
+
}
|
|
176
|
+
.menu-item {
|
|
177
|
+
margin-top: 20px;
|
|
178
|
+
width: 180px;
|
|
179
|
+
margin-left: 20px;
|
|
180
|
+
height: 30px;
|
|
181
|
+
margin: 0 16px !important;
|
|
182
|
+
padding: 20px 0px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
display: flex;
|
|
185
|
+
justify-content: flex-start;
|
|
186
|
+
align-items: center;
|
|
187
|
+
}
|
|
188
|
+
.menu-text-opened {
|
|
189
|
+
animation: openMenuText 0.2s ease-in forwards;
|
|
190
|
+
}
|
|
191
|
+
.menu-text-closed {
|
|
192
|
+
animation: closeMenuText 0.2s ease-out forwards;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.item-active {
|
|
196
|
+
background-color: #ececec;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.sub-menu-button{
|
|
200
|
+
margin-left: 8px;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@keyframes openMenuText {
|
|
205
|
+
from {
|
|
206
|
+
opacity: 0;
|
|
207
|
+
transform: translateX(-30px);
|
|
208
|
+
}
|
|
209
|
+
to {
|
|
210
|
+
opacity: 1;
|
|
211
|
+
transform: translateX(0);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@keyframes closeMenuText {
|
|
216
|
+
from {
|
|
217
|
+
opacity: 1;
|
|
218
|
+
transform: translateX(0);
|
|
219
|
+
}
|
|
220
|
+
to {
|
|
221
|
+
opacity: 0;
|
|
222
|
+
transform: translateX(-30px);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
</style>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="sub-menu-items" v-if="item.opened">
|
|
3
|
+
<div v-for="(subItem, subIndex) in item.items" :key="subIndex" class="item" :class="{'menu-item-opened': menuBar.opened }" @mouseenter="showTooltipItems($event)" @mouseleave="hideTooltipItems($event)">
|
|
4
|
+
<MenuItem :item="subItem" :leftItems="leftMenuItems" :menuBar="menuBar" ></MenuItem>
|
|
5
|
+
<SubMenuItems v-if="subItem.items?.length" v-show="menuBar.opened" :item="subItem" :menuBar="menuBar"></SubMenuItems>
|
|
6
|
+
<div class="active-tooltip" v-if="tooltip && subItem.items?.length">
|
|
7
|
+
<div v-for="value in subItem.items" :key="value.name" class="tooltip-item" @click="tooltipItemClick($event, subItem, value)" v-if="!menuBar.opened" @mouseenter="showTooltipItems($event)" @mouseleave="hideTooltipItems($event)">
|
|
8
|
+
{{ value.name }}
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import MenuItem from './menu-item.vue';
|
|
17
|
+
import { to } from '../routing/routing';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'SubMenuItems',
|
|
21
|
+
components: {
|
|
22
|
+
MenuItem: MenuItem,
|
|
23
|
+
},
|
|
24
|
+
props: {
|
|
25
|
+
item: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
menuBar: {
|
|
30
|
+
type: Object,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
leftMenuItems: {
|
|
34
|
+
type: Array,
|
|
35
|
+
default: () => []
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
item: this.item,
|
|
41
|
+
tooltip: false,
|
|
42
|
+
menuBar: this.menuBar,
|
|
43
|
+
leftMenuItems: this.leftMenuItems as any[]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
emits: [
|
|
47
|
+
'openmenu'
|
|
48
|
+
],
|
|
49
|
+
watch:{
|
|
50
|
+
menuBar(newVal: any) {
|
|
51
|
+
this.menuBar = newVal;
|
|
52
|
+
},
|
|
53
|
+
item(newVal: any) {
|
|
54
|
+
this.item = newVal;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
methods: {
|
|
58
|
+
showTooltipItems(event: any) {
|
|
59
|
+
if (!this.menuBar.opened) {
|
|
60
|
+
if(this.item.items?.length){
|
|
61
|
+
this.tooltip = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
hideTooltipItems(event: any) {
|
|
66
|
+
if (!this.menuBar.opened) {
|
|
67
|
+
this.tooltip = false;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
tooltipItemClick(event: any, subItem: any, value: any) {
|
|
71
|
+
if(!value.items?.length){
|
|
72
|
+
to(value.route);
|
|
73
|
+
return;
|
|
74
|
+
|
|
75
|
+
}else{
|
|
76
|
+
this.menuBar.opened = true;
|
|
77
|
+
subItem.opened = true;
|
|
78
|
+
this.$emit('openmenu', subItem, value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<style scoped>
|
|
87
|
+
.active-tooltip {
|
|
88
|
+
position: relative;
|
|
89
|
+
left: 74px;
|
|
90
|
+
width: 240px;
|
|
91
|
+
height: 80px;
|
|
92
|
+
border: 1px solid #424242;
|
|
93
|
+
background-color: white !important;
|
|
94
|
+
z-index: 999999999;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.item{
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-wrap: wrap;
|
|
100
|
+
width: 180px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.item-active {
|
|
104
|
+
background-color: #ececec;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sub-menu-button{
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
}
|
|
110
|
+
.svg-inline--fa {
|
|
111
|
+
color: rgba(60, 60, 60, 0.8) !important;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.sub-menu-items .menu-item{
|
|
115
|
+
margin-left: 60px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.sub-menu-item p{
|
|
119
|
+
margin-left: 60px;
|
|
120
|
+
font-size: 16px;
|
|
121
|
+
padding: 4px;
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="horizontal-top-menu">
|
|
3
|
+
<div v-for="item in topMenuItems" :key="item.id" class="horizontal-top-menu-item" :class="{'menu-hover': item.opened, 'active': item.opened}" @mouseenter="hoverOpenTopMenuItem($event, item)">
|
|
4
|
+
|
|
5
|
+
<div class="top-menu-item-heading" @click="openMenuItem($event, item)" @mouseleave="closeTopMenu($event, item)">
|
|
6
|
+
{{ item.name }}
|
|
7
|
+
<div v-if="item.items?.length"><FontAwesomeIcon :size="'sm'" :icon="item.openIcon"></FontAwesomeIcon></div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<TopSubMenuItems @mouseleave="closeTopMenuItem($event, item)" v-if="item.items?.length" :item="item" :topMenuItems="topMenuItems" :menuBar="menuBar" @click.stop></TopSubMenuItems>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import { faChevronDown, faChevronRight, faChevronUp } from '@fortawesome/free-solid-svg-icons';
|
|
18
|
+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
19
|
+
import TopSubMenuItems from './../top-menu-items/top-sub-menu-items.vue';
|
|
20
|
+
import { toTop } from '../../routing/routing';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
name: 'TopMenuItems',
|
|
24
|
+
components: {
|
|
25
|
+
FontAwesomeIcon: FontAwesomeIcon,
|
|
26
|
+
TopSubMenuItems: TopSubMenuItems
|
|
27
|
+
},
|
|
28
|
+
props: {
|
|
29
|
+
topMenuItems: {
|
|
30
|
+
type: Array,
|
|
31
|
+
default: () => [] as any[]
|
|
32
|
+
},
|
|
33
|
+
menuBar: {
|
|
34
|
+
type: Object,
|
|
35
|
+
required: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
created() {
|
|
39
|
+
console.log("Test", this.topMenuItems);
|
|
40
|
+
},
|
|
41
|
+
data() {
|
|
42
|
+
return {
|
|
43
|
+
topMenuItems: this.topMenuItems as any[],
|
|
44
|
+
menuBar: this.menuBar,
|
|
45
|
+
toTop: toTop
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
openTopMenuItem(event: MouseEvent, item: any) {
|
|
50
|
+
console.log(item)
|
|
51
|
+
if(!item.items?.length){
|
|
52
|
+
toTop(item.route);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
},
|
|
57
|
+
hoverOpenTopMenuItem(event: MouseEvent, item: any) {
|
|
58
|
+
document.querySelector(`.horizontal-top-menu-item-${item.id}`)?.classList.add('menu-hover');
|
|
59
|
+
item.opened = true;
|
|
60
|
+
item.openIcon = faChevronDown;
|
|
61
|
+
this.closeSubItems(item);
|
|
62
|
+
},
|
|
63
|
+
closeTopMenuItem(event: MouseEvent, item: any) {
|
|
64
|
+
document.querySelector(`.horizontal-top-menu-item-${item.id}`)?.classList.remove('menu-hover');
|
|
65
|
+
item.opened = false;
|
|
66
|
+
item.openIcon = faChevronRight;
|
|
67
|
+
this.closeSubItems(item);
|
|
68
|
+
},
|
|
69
|
+
closeTopMenu(event: MouseEvent, item: any) {
|
|
70
|
+
if(!item.items?.length){
|
|
71
|
+
item.opened = false;
|
|
72
|
+
item.openIcon = faChevronRight;
|
|
73
|
+
}
|
|
74
|
+
this.closeSubItems(item);
|
|
75
|
+
},
|
|
76
|
+
openMenuItem(event: MouseEvent, item: any) {
|
|
77
|
+
if(!item.items?.length){
|
|
78
|
+
toTop(item.route);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
closeSubItems(item: any) {
|
|
83
|
+
if(!item.opened){
|
|
84
|
+
for(let subItem of item.items || []){
|
|
85
|
+
subItem.opened = false;
|
|
86
|
+
if(subItem.items?.length){
|
|
87
|
+
this.closeSubItems(subItem);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<style scoped>
|
|
97
|
+
|
|
98
|
+
.item{
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-wrap: wrap;
|
|
101
|
+
width: 180px;
|
|
102
|
+
}
|
|
103
|
+
.horizontal-items{
|
|
104
|
+
display: flex;
|
|
105
|
+
gap: 20px;
|
|
106
|
+
padding: 10px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.top-menu-item-heading{
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
border-bottom: 1px solid transparent;
|
|
114
|
+
box-sizing: border-box;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.horizontal-top-menu-item.active {
|
|
118
|
+
border-bottom: 2px solid black;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.menu-hover {
|
|
122
|
+
background-color: #eeeeee;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.horizontal-top-menu {
|
|
126
|
+
width: 100%;
|
|
127
|
+
display: flex;
|
|
128
|
+
justify-content: flex-end;
|
|
129
|
+
align-items: center;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.horizontal-top-menu-item{
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
height: 48px;
|
|
137
|
+
width: 70px;
|
|
138
|
+
border-bottom: 2px solid transparent;
|
|
139
|
+
padding-left: 16px;
|
|
140
|
+
padding-right: 10px;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="top-sub-menu-items" v-if="item.opened">
|
|
3
|
+
<div v-for="(subSubItem, index) in item.items" :key="subSubItem.id" class="item">
|
|
4
|
+
<div class="top-menu-item" @click.stop="openTopMenuItem($event, subSubItem)" @mouseenter="openHoverTopMenuItem($event, subSubItem)">
|
|
5
|
+
{{ subSubItem.name }} <div v-if="subSubItem.items?.length" style="margin-left: 8px;"><FontAwesomeIcon :size="'sm'" :icon="subSubItem.openIcon"></FontAwesomeIcon></div>
|
|
6
|
+
</div>
|
|
7
|
+
<TopSubMenuItems @mouseleave="closeTopMenuItem($event, subSubItem)" :style="{top: `${(Number(index)) * 70}px`, right: `${2 * 10 + 40}px`}" v-if="subSubItem.items?.length" :key="subSubItem.id" :item="subSubItem" :topMenuItems="topMenuItems" :menuBar="menuBar"></TopSubMenuItems>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { faChevronDown, faChevronRight, faChevronUp } from '@fortawesome/free-solid-svg-icons';
|
|
14
|
+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
15
|
+
import { toTop } from '../../routing/routing';
|
|
16
|
+
import { TopMenuItems } from '../../models/menu-models';
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'TopSubMenuItems',
|
|
20
|
+
components: {
|
|
21
|
+
FontAwesomeIcon: FontAwesomeIcon
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
item: {
|
|
25
|
+
type: Object,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
menuBar: {
|
|
29
|
+
type: Object,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
topMenuItems: {
|
|
33
|
+
type: Array as () => TopMenuItems[],
|
|
34
|
+
default: () => []
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
tooltip: false,
|
|
40
|
+
faChevronDown: faChevronDown,
|
|
41
|
+
item: this.item,
|
|
42
|
+
menuBar: this.menuBar,
|
|
43
|
+
faChevronRight: faChevronRight,
|
|
44
|
+
toTop: toTop
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
watch: {
|
|
48
|
+
item(newVal: any) {
|
|
49
|
+
this.item = newVal;
|
|
50
|
+
},
|
|
51
|
+
menuBar(newVal: any) {
|
|
52
|
+
this.menuBar = newVal;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
openHoverTopMenuItem(event: MouseEvent, item: any) {
|
|
57
|
+
item.opened = true;
|
|
58
|
+
item.openIcon = faChevronDown;
|
|
59
|
+
},
|
|
60
|
+
closeTopMenuItem(event: MouseEvent, item: any) {
|
|
61
|
+
item.opened = false;
|
|
62
|
+
item.openIcon = faChevronRight;
|
|
63
|
+
},
|
|
64
|
+
openTopMenuItem(event: MouseEvent, item: any) {
|
|
65
|
+
if(!item.items?.length){
|
|
66
|
+
toTop(item.route);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
closeSubItems(item: any) {
|
|
71
|
+
if(!item.opened){
|
|
72
|
+
for(let subItem of item.items || []){
|
|
73
|
+
subItem.opened = false;
|
|
74
|
+
if(subItem.items?.length){
|
|
75
|
+
this.closeSubItems(subItem);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.top-sub-menu-items {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 48px;
|
|
89
|
+
right: 0px;
|
|
90
|
+
border: 1px solid #424242;
|
|
91
|
+
padding: 10px;
|
|
92
|
+
margin-top: 1px;
|
|
93
|
+
width: 200px;
|
|
94
|
+
z-index: 999999999;
|
|
95
|
+
background-color: white;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.svg-inline--fa {
|
|
99
|
+
color: rgba(60, 60, 60, 0.8) !important;
|
|
100
|
+
}
|
|
101
|
+
.top-menu-item{
|
|
102
|
+
display: flex;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.item{
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: row;
|
|
109
|
+
width: 200px;
|
|
110
|
+
padding: 3px 7px;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
</style>
|
package/menu/index.d.ts
ADDED
package/menu/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { faChevronDown, faChevronLeft, faChevronRight } from "@fortawesome/free-solid-svg-icons";
|
|
2
|
+
|
|
3
|
+
export class LeftMenuModel{
|
|
4
|
+
name: string = '';
|
|
5
|
+
icon: any;
|
|
6
|
+
route: string = '';
|
|
7
|
+
items: MenuItemModel[] = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class MenuItemModel{
|
|
11
|
+
name: string = '';
|
|
12
|
+
route: string = "";
|
|
13
|
+
items: MenuItemModel[] = [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class MenuBarModel{
|
|
17
|
+
icon: any = faChevronLeft; //angle-arrow, bars, ellipsis
|
|
18
|
+
name: string = '';
|
|
19
|
+
loading: boolean = false;
|
|
20
|
+
opened: boolean = false;
|
|
21
|
+
changeIcon: 'flip' | 'rotate' | 'hover' | 'none' = 'none';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class LeftMenuItems{
|
|
25
|
+
id: number = 0;
|
|
26
|
+
name: string = '';
|
|
27
|
+
icon: any;
|
|
28
|
+
route: string = '';
|
|
29
|
+
opened: boolean = false;
|
|
30
|
+
openIcon: any = faChevronRight;
|
|
31
|
+
items: TopMenuItems[] = [] as TopMenuItems[];
|
|
32
|
+
active: boolean = false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class TopMenuItems{
|
|
36
|
+
id: number = 0;
|
|
37
|
+
name: string = '';
|
|
38
|
+
route: string = '';
|
|
39
|
+
opened: boolean = false;
|
|
40
|
+
active: boolean = false;
|
|
41
|
+
openIcon: any = faChevronRight;
|
|
42
|
+
items: TopMenuItems[] = [] as TopMenuItems[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ThemeModel{
|
|
46
|
+
name: string = '';
|
|
47
|
+
value: string = '';
|
|
48
|
+
type: 'primary' | 'secondary' | 'dark' | 'light' | 'basic' = 'primary';
|
|
49
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const themes = [
|
|
2
|
+
{
|
|
3
|
+
name: 'Light',
|
|
4
|
+
value: 'light',
|
|
5
|
+
type: 'light',
|
|
6
|
+
background: '#ffffff',
|
|
7
|
+
text: '#000000',
|
|
8
|
+
iconColor: '#000000'
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'Dark',
|
|
12
|
+
value: 'dark',
|
|
13
|
+
type: 'dark',
|
|
14
|
+
background: 'rgba(60, 60, 60, 1)',
|
|
15
|
+
text: '#ffffff',
|
|
16
|
+
iconColor: 'orange'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Primary',
|
|
20
|
+
value: 'primary',
|
|
21
|
+
type: 'primary',
|
|
22
|
+
background: '#007bff',
|
|
23
|
+
text: '#ffffff',
|
|
24
|
+
iconColor: '#ffffff'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Secondary',
|
|
28
|
+
value: 'secondary',
|
|
29
|
+
type: 'secondary',
|
|
30
|
+
background: '#6c757d',
|
|
31
|
+
text: '#ffffff',
|
|
32
|
+
iconColor: '#ffffff'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'basic',
|
|
36
|
+
value: 'basic',
|
|
37
|
+
type: 'light',
|
|
38
|
+
background: '#9dffac',
|
|
39
|
+
text: '#000000',
|
|
40
|
+
iconColor: '#000000'
|
|
41
|
+
}
|
|
42
|
+
]
|