forked from rotki/ui-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuView.vue
More file actions
205 lines (200 loc) · 4.75 KB
/
Copy pathMenuView.vue
File metadata and controls
205 lines (200 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<script lang="ts" setup>
import {
type ButtonProps,
type MenuProps,
RuiButton,
RuiMenu,
} from '@rotki/ui-library';
import { objectOmit } from '@vueuse/shared';
import ComponentView from '@/components/ComponentView.vue';
type SimpleMenu = MenuProps & { buttonColor?: ButtonProps['color']; buttonText: string };
const menus = ref<SimpleMenu[]>([
{
disabled: false,
buttonText: 'Bottom',
buttonColor: 'primary',
popper: { placement: 'bottom' },
},
{
disabled: false,
buttonText: 'Top',
buttonColor: 'secondary',
popper: { placement: 'top' },
},
{
disabled: false,
buttonText: 'Left',
buttonColor: 'error',
popper: { placement: 'left' },
},
{
disabled: false,
buttonText: 'Right',
buttonColor: 'info',
popper: { placement: 'right' },
},
{
disabled: true,
buttonText: 'Menu disabled',
buttonColor: 'primary',
popper: { placement: 'bottom' },
},
{
disabled: true,
buttonText: 'Menu disabled',
buttonColor: 'secondary',
popper: { placement: 'top' },
},
{
disabled: true,
buttonText: 'Menu disabled',
buttonColor: 'error',
popper: { placement: 'left' },
},
{
disabled: true,
buttonText: 'Menu disabled',
buttonColor: 'info',
popper: { placement: 'right' },
},
{
disabled: false,
buttonText: 'Bottom (Open on Hover)',
buttonColor: 'primary',
popper: { placement: 'bottom' },
openOnHover: true,
},
{
disabled: false,
buttonText: 'Top (Open on Hover)',
buttonColor: 'secondary',
popper: { placement: 'top' },
openOnHover: true,
},
{
disabled: false,
buttonText: 'Left (Open on Hover)',
buttonColor: 'error',
popper: { placement: 'left' },
openOnHover: true,
},
{
disabled: false,
buttonText: 'Right (Open on Hover)',
buttonColor: 'info',
popper: { placement: 'right' },
openOnHover: true,
},
{
disabled: false,
buttonText: 'Bottom (Close on Content Click)',
buttonColor: 'primary',
popper: { placement: 'bottom' },
closeOnContentClick: true,
},
{
disabled: false,
buttonText: 'Top (Close on Content Click)',
buttonColor: 'secondary',
popper: { placement: 'top' },
closeOnContentClick: true,
},
{
disabled: false,
buttonText: 'Left (Close on Content Click)',
buttonColor: 'error',
popper: { placement: 'left' },
closeOnContentClick: true,
},
{
disabled: false,
buttonText: 'Right (Close on Content Click)',
buttonColor: 'info',
popper: { placement: 'right' },
closeOnContentClick: true,
},
{
disabled: false,
buttonText: 'Bottom (Persistent)',
buttonColor: 'primary',
popper: { placement: 'bottom' },
persistent: true,
},
]);
</script>
<template>
<ComponentView data-id="menus">
<template #title>
Menus
</template>
<div class="grid gap-6 grid-cols-4">
<div
v-for="(menu, i) in menus"
:key="i"
class="py-4"
>
<RuiMenu
v-bind="objectOmit(menu, ['buttonColor'])"
:data-id="`menu-${i}`"
:open-delay="10"
>
<template #activator="{ attrs, disabled }">
<RuiButton
:color="menu.buttonColor"
:disabled="disabled"
v-bind="{ ...attrs, 'data-id': 'activator' }"
>
{{ menu.buttonText }}
</RuiButton>
</template>
<div class="px-3 py-2">
This is menu {{ i }}
</div>
</RuiMenu>
</div>
</div>
<h6 class="text-h6 mt-8 mb-4">
Nested menu
</h6>
<div class="py-4">
<RuiMenu
data-id="menu-nested"
:open-delay="10"
:popper="{ placement: 'bottom' }"
>
<template #activator="{ attrs }">
<RuiButton
color="primary"
v-bind="{ ...attrs, 'data-id': 'activator' }"
>
Open outer menu
</RuiButton>
</template>
<div class="px-3 py-2 flex flex-col items-start gap-2">
<span>This is the outer menu</span>
<RuiMenu
data-id="menu-nested-inner"
:open-delay="10"
:popper="{ placement: 'right' }"
>
<template #activator="{ attrs }">
<RuiButton
color="secondary"
size="sm"
v-bind="{ ...attrs, 'data-id': 'inner-activator' }"
>
Open inner menu
</RuiButton>
</template>
<div
class="px-3 py-2"
data-id="inner-content"
>
This is the inner menu
</div>
</RuiMenu>
</div>
</RuiMenu>
</div>
</ComponentView>
</template>