Newer
Older
const bandcampPrivacy = ref('pod')
const ccPrivacy = ref('public')
const bandcamp = ref(false)
const cc = ref(false)
const share = ref(false)
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
const items = [
{
type: 'button',
text: 'Play next',
icon: 'bi-arrow-up-right',
click: () => {}
},
{
type: 'button',
text: 'Append to queue',
icon: 'bi-arrow-down-right',
click: () => {}
},
{
type: 'button',
text: 'Add to playlist',
icon: 'bi-music-note-list',
click: () => {},
items: [
{
type: 'button',
text: 'Sample playlist',
icon: 'bi-music-note-list',
click: () => {}
},
{ type: 'separator', },
{
type: 'button',
text: 'New playlist',
icon: 'bi-plus-lg',
click: () => {}
},
]
},
{ type: 'separator', },
{
type: 'button',
text: 'Add to favorites',
icon: 'bi-heart',
click: () => {}
},
{
type: 'button',
text: 'Organize and share',
icon: 'bi-collection',
click: () => {},
items: [
{
model: bandcamp,
extraItems: [
{
type: 'library-privacy-level',
model: bandcampPrivacy
}
]
model: cc,
extraItems: [
{
type: 'library-privacy-level',
model: ccPrivacy
}
]
},
{ type: 'separator', },
{
type: 'button',
text: 'New library',
icon: 'bi-plus-lg',
click: () => {}
},
{ type: 'separator', },
{
model: share,
extraItems: [
{
type: 'circle-button',
icon: 'bi-link',
click: () => {}
},
{
type: 'circle-button',
icon: 'bi-code',
click: () => {}
},
]
},
]
},
{
type: 'button',
text: 'Download',
icon: 'bi-cloud-download',
click: () => {}
},
{ type: 'separator', },
{
type: 'button',
text: 'Report',
icon: 'bi-exclamation',
click: () => {}
},
]
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
const oneButtonMenu = [
{
type: 'button',
text: 'Report',
icon: 'bi-exclamation',
click: () => {}
}
]
const oneSelectMenu = [
{
type: 'select',
text: 'Bandcamp',
model: bandcamp
}
]
const oneSeparatorMenu = [
{ type: 'separator', }
]
const nestedMenu = [
{
type: 'button',
text: 'Organize and share',
icon: 'bi-collection',
click: () => {},
items: [
{
type: 'select',
text: 'Bandcamp',
model: bandcamp,
}
]
}
]
const extraItemsMenu = [
{
type: 'select',
text: 'Bandcamp',
model: bandcamp,
extraItems: [
{
type: 'library-privacy-level',
model: bandcampPrivacy
}
]
},
{
type: 'select',
text: 'Creative Commons',
model: cc,
extraItems: [
{
type: 'circle-button',
icon: 'bi-exclamation',
click: () => {}
}
]
}
]
const separator = ref(false)
const singleButton = ref(false)
const singleSelect = ref(false)
const extraItemsOpen = ref(false)
Popovers are visually hiden menus of items activated by a simple button. Use popovers to create complex menus in a visually appealing way.
| Prop | Data type | Required? | Description |
| ----- | --------- | ----------- | ----------- |
| `items` | Array\<Item\> | Yes | A list of menu items. |
| `v-model:open` | Boolean | Yes | Controls whether the popover is open or not. |
| `click-outside` | Boolean | No | Controls whether clicking outside the popover closes it. |
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
## Items
Popovers contain a list of menu items. Items can contain different information based on their type.
### Button
A button is a clickable item users can interact with. It can take the form of a link or an action.
| Property | Data type | Required? | Description |
| --------- | --------- | ---------- | ----------- |
|`type` | String | Yes | The item type (`button`). |
| `text` | String | Yes | The text that appears in the menu. |
| `icon` | String | Yes | The icon that appears in the menu. |
| `click` | Event | Yes | The action that triggers when a user clicks the button. |
```vue{2-9}
<script-setup lang="ts">
const items = [
{
type: 'button',
text: 'Report',
icon: 'bi-exclamation',
click: () => {}
}
]
const open = ref(false)
</script>
<template>
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />
</template
```
<fw-options-button @click="singleButton = !singleButton" />
<fw-popover :items="oneButtonMenu" v-model:open="singleButton" />
### Select
A select is a checkbox item that users can select or deselect to modify data.
| Property | Data type | Required? | Description |
| --------- | --------- | ---------- | ----------- |
|`type` | String | Yes | The item type (`select`). |
| `text` | String | Yes | The text that appears in the menu. |
| `model` | Property | Yes | The property the select button maps to. |
```vue{2-8}
<script-setup lang="ts">
const items = [
{
type: 'select',
text: 'Bandcamp',
model: bandcamp
}
]
const open = ref(false)
</script>
<template>
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />
</template>
```
<fw-options-button @click="singleSelect = !singleSelect" />
<fw-popover :items="oneSelectMenu" v-model:open="singleSelect" />
### Separator
| Property | Data type | Required? | Description |
| --------- | --------- | ---------- | ----------- |
|`type` | String | Yes | The item type (`separator`). |
Separators are visual separators that break the menu up into different sections.
```vue{2-6}
<script-setup lang="ts">
const items=[
{
type: 'separator'
}
]
</script>
<template>
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />
</template>
```
<fw-options-button @click="separator = !separator" />
<fw-popover :items="oneSeparatorMenu" v-model:open="separator" />
## Nested items
To create a more complex menu, you can nest items within other menu items. Add a new `items` array inside an item to nest the array as an expanded list.
```vue{8-14}
<script-setup lang="ts">
const items = [
{
type: 'button',
text: 'Organize and share',
icon: 'bi-collection',
click: () => {},
items: [
{
type: 'select',
text: 'Bandcamp',
model: bandcamp,
}
]
}
]
const open = ref(false)
</script>
<template>
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />
</template
```
<fw-options-button @click="singleButton = !singleButton" />
<fw-popover :items="nestedMenu" v-model:open="singleButton" />
## Extra items
::: info
Extra items can only be added to `button` and `select` items.
:::
You can extend items without creating submenus by attaching a small extra menu on the right hand side of the item.
| Property | Data type | Required? | Description |
| --------- | --------- | ---------- | ----------- |
|`type` | String | Yes | The item type. |
::: details Supported types
- `circle-button` – a small clickable circle button
- `library-privacy-level` – a selectable list of Funkwhale privacy levels
:::
```vue{7-12,18-24}
<script-setup lang="ts">
const items = [
{
type: 'select',
text: 'Bandcamp',
model: bandcamp,
extraItems: [
{
type: 'library-privacy-level',
model: bandcampPrivacy
}
]
},
{
type: 'select',
text: 'Creative Commons',
model: cc,
extraItems: [
{
type: 'circle-button',
icon: 'bi-exclamation',
click: () => {}
}
]
}
]
const open = ref(false)
</script>
<template>
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />
</template>
```
<fw-options-button @click="extraItemsOpen = !extraItemsOpen" />
<fw-popover :items="extraItemsMenu" v-model:open="extraItemsOpen" />
## Menu
Here is an example of a completed menu containing all supported features.
```vue-html
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />
```
<fw-options-button @click="open = !open" />
<fw-popover :items="items" v-model:open="open" />