2024-11-26 11:59:11 +00:00
< script setup lang = "ts" >
import { ref } from 'vue'
2024-12-14 18:22:29 +00:00
import { SUPPORTED_LOCALES, setI18nLanguage } from '~/init/locale'
2024-11-26 11:59:11 +00:00
2024-12-04 15:06:34 +00:00
import Button from "~/components/ui/Button.vue"
import OptionsButton from "~/components/ui/button/Options.vue"
import Pill from "~/components/ui/Pill.vue"
import Popover from "~/components/ui/Popover.vue"
import PopoverCheckbox from "~/components/ui/popover/PopoverCheckbox.vue"
import PopoverItem from "~/components/ui/popover/PopoverItem.vue"
import PopoverRadio from "~/components/ui/popover/PopoverRadio.vue"
import PopoverSubmenu from "~/components/ui/popover/PopoverSubmenu.vue"
2024-11-26 11:59:11 +00:00
// String values
const privacyChoices = ['public', 'private', 'pod']
const bcPrivacy = ref('pod')
const ccPrivacy = ref('public')
// Boolean values
const bc = ref(false)
const cc = ref(false)
const share = ref(false)
// Alert control
const alert = (message: string) => window.alert(message)
// Menu controls
const emptyMenu = ref(false)
2024-12-08 20:28:21 +00:00
// const separator = ref(false)
2024-11-26 11:59:11 +00:00
const singleItemMenu = ref(false)
const checkboxMenu = ref(false)
const radioMenu = ref(false)
const seperatorMenu = ref(false)
const subMenu = ref(false)
const extraItemsMenu = ref(false)
2024-12-20 14:58:35 +00:00
const linksMenu = ref(false)
2024-11-26 11:59:11 +00:00
const fullMenu= ref(false)
2024-12-08 19:34:52 +00:00
const isOpen = ref(false)
2024-11-26 11:59:11 +00:00
< / script >
2024-12-06 16:20:41 +00:00
# Popover (Dropdown Menu)
Popovers (`Popover`) are dropdown menus activated by a button. Use popovers to create dropdown menus ranging from simple lists to complex nested menus.
2024-12-20 14:58:35 +00:00
::: warning A11y issues
2024-11-26 11:59:11 +00:00
2024-12-20 14:58:35 +00:00
This component has severe usability issues and cannot be used as-is.
### Add keyboard operability
> I can't operate the popup with a keyboard. Remove barrier for people not using a mouse.
- ✅ All items can be focused and activated by `Space`
(use `<button>` element instead of `<div>` )
- **Tab order:** Users can go to the next and previous items with `Tab` and `Shift+Tab` . When they have opened a sub-menu, the next focusable element is inside the sub-menu. When they have closed it, the focus jumps back to where it was.
- **Dismissal:** Users can close a menu or sub-menu with `ESC`
- **Arrow keys:** Users can move up and down a menu, open sub-menus with `->` and close them with `<-` . I have added something like this to `Tabs.vue` , for reference.
### Implement expected behavior
> Switching to submenus is error-prone. When moving cursor into freshly opened submenu, it should not close if the cursor crosses another menu item.
< img style = "mix-blend-mode:multiply; width: 50%; float:right;" src = "./popover/image.png" / >
- **Dead triangle:** Add a triangular invisible node that covers the possible paths from the current mouse position to the menu items.
---
> Large menus disappear. I can't scroll to see all options.
- **Submenu-to-Modal:** Lists longer than 12 or so items are not recommended and should be replaced with modals.
2024-11-26 11:59:11 +00:00
2024-12-20 14:58:35 +00:00
---
2024-12-14 18:22:29 +00:00
2024-12-20 14:58:35 +00:00
> Submenus open without a delay, and they don't close unless I click somewhere outside them, which goes against established expectations.
2024-12-14 18:22:29 +00:00
2024-12-20 14:58:35 +00:00
- **Expansion delay:** Sub-menus open after 200ms
- **Auto-close:** Sub-menus close when the outside is hovered. There may be a delay of 200ms. Menus close when they lose focus.
---
2024-12-14 18:22:29 +00:00
Common Ui libraries in the Vue ecosystem such as vuetify or shadcn-vue all implement these features. It may be prudent to use their components.
2024-12-20 14:58:35 +00:00
::: tip Quick mitigation tactics:
2024-12-17 18:08:01 +00:00
- Place complex interfaces into nested [`Modal` ](./modal )s
2024-12-20 14:58:35 +00:00
- Place long lists into [native `<Select>` elements ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select )
- Avoid sub-menus
2024-12-17 18:08:01 +00:00
2024-12-14 18:22:29 +00:00
:::
2024-12-20 14:58:35 +00:00
Common uses:
- "More actions" dropdown menus
- Navigation menus
- Settings menus
- Context menus (right-click menus)
2024-11-26 11:59:11 +00:00
| Prop | Data type | Required? | Description |
| ------ | --------- | --------- | ---------------------------------------------------------- |
| `open` | Boolean | No | Controls whether the popover is open. Defaults to `false` . |
2024-12-14 18:22:29 +00:00
[[toc]]
```vue-html
< Popover >
< template #default ="{ toggleOpen }" >
< OptionsButton @click =" toggleOpen " />
< / template >
< / Popover >
```
< Popover >
< template #default ="{ toggleOpen }" >
< OptionsButton @click =" toggleOpen " />
< / template >
< / Popover >
Destructure the function `toggleOpen` and let
a [default dropdown button: `OptionsButton` ](./button/options.md ) trigger it. This way, the state of the component is encapsulated.
## Bind to `isOpen`
If you want to process or influence the expansion of the menu in the containing component, you can bind it to a `ref` .
2024-11-26 11:59:11 +00:00
2024-12-14 18:22:29 +00:00
Use [Vue event handling ](https://vuejs.org/guide/essentials/event-handling.html ) to map the button to a boolean value.
2024-11-26 11:59:11 +00:00
```vue{7}
< script setup lang = "ts" >
2024-12-14 18:22:29 +00:00
const isOpen = ref(false)
2024-11-26 11:59:11 +00:00
< / script >
< template >
2024-12-14 18:22:29 +00:00
< Popover v-model:open = "isOpen" >
< OptionsButton @click =" isOpen = !isOpen" />
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "emptyMenu" >
< OptionsButton @click =" emptyMenu = !emptyMenu" />
< / Popover >
2024-11-26 11:59:11 +00:00
2024-12-14 18:22:29 +00:00
## Customize the dropdown button
2024-11-26 11:59:11 +00:00
2024-12-14 18:22:29 +00:00
```vue
2024-11-26 11:59:11 +00:00
< script setup lang = "ts" >
2024-12-14 18:22:29 +00:00
const open = ref(false);
const privacyChoices = ["pod", "public", "private"];
const bcPrivacy = ref("pod");
2024-11-26 11:59:11 +00:00
< / script >
< template >
2024-12-08 19:34:52 +00:00
< Popover v-model:open = "isOpen" >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-06 16:20:41 +00:00
< Pill
2024-12-14 18:22:29 +00:00
@click ="
(e) => {
console.log('Pill clicked');
console.log('Before toggleOpen:', isOpen);
toggleOpen();
console.log('After toggleOpen:', isOpen);
}
"
2024-12-06 16:20:41 +00:00
:blue="bcPrivacy === 'pod'"
:red="bcPrivacy === 'public'"
>
2024-11-26 11:59:11 +00:00
{{ bcPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-14 18:22:29 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-08 19:34:52 +00:00
< Popover v-model:open = "isOpen" >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-06 16:20:41 +00:00
< Pill
@click ="(e) => {
console.log('Pill clicked');
2024-12-08 19:34:52 +00:00
console.log('Before toggleOpen:', isOpen);
2024-12-06 16:20:41 +00:00
toggleOpen();
2024-12-08 19:34:52 +00:00
console.log('After toggleOpen:', isOpen);
2024-12-06 16:20:41 +00:00
}"
:blue="bcPrivacy === 'pod'"
:red="bcPrivacy === 'public'"
>
2024-11-26 11:59:11 +00:00
{{ bcPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
## Items
Popovers contain a list of menu items. Items can contain different information based on their type.
::: info
2024-12-04 15:06:34 +00:00
Lists of items must be nested inside a `<template #items>` tag directly under the `<Popover>` tag.
2024-11-26 11:59:11 +00:00
:::
### Popover item
2024-12-04 15:06:34 +00:00
The popover item (`PopoverItem`) is a simple button that uses [Vue event handling ](https://vuejs.org/guide/essentials/event-handling.html ). Each item contains a [slot ](https://vuejs.org/guide/components/slots.html ) which you can use to add a menu label and icon.
2024-11-26 11:59:11 +00:00
```vue{10-13}
< script setup lang = "ts" >
const alert = (message: string) => window.alert(message)
const open = ref(false)
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverItem @click =" alert (' Report this object ?')" >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-exclamation" / >
Report
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "singleItemMenu" >
< OptionsButton @click =" singleItemMenu = !singleItemMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverItem @click =" alert (' Report this object ?')" >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-exclamation" / >
Report
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
### Checkbox
2024-12-04 15:06:34 +00:00
The checkbox (`PopoverCheckbox`) is an item that acts as a selectable box. Use [`v-model` ](https://vuejs.org/api/built-in-directives.html#v-model ) to bind the checkbox to a boolean value. Each checkbox contains a [slot ](https://vuejs.org/guide/components/slots.html ) which you can use to add a menu label.
2024-11-26 11:59:11 +00:00
```vue{11-16}
< script setup lang = "ts" >
const bc = ref(false)
const cc = ref(false)
const open = ref(false)
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
< PopoverCheckbox v-model = "cc" >
2024-11-26 11:59:11 +00:00
Creative commons
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "checkboxMenu" >
< OptionsButton @click =" checkboxMenu = !checkboxMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
< PopoverCheckbox v-model = "cc" >
2024-11-26 11:59:11 +00:00
Creative commons
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
### Radio
2024-12-04 15:06:34 +00:00
The radio (`PopoverRadio`) is an item that acts as a radio selector.
2024-11-26 11:59:11 +00:00
| Prop | Data type | Required? | Description |
| ------------ | --------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `modelValue` | String | Yes | The current value of the radio. Use [`v-model` ](https://vuejs.org/api/built-in-directives.html#v-model ) to bind this to a value. |
| `choices` | Array\<String\> | Yes | A list of choices. |
```vue
< script setup lang = "ts" >
const open = ref(false);
const currentChoice = ref("pod");
const privacy = ["public", "private", "pod"];
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "currentChoice" :choices = "choices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "radioMenu" >
< OptionsButton @click =" radioMenu = !radioMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
### Separator
Use a standard horizontal rule (`< hr > `) to add visual separators to popover lists.
```vue{14}
< script setup lang = "ts" >
const bc = ref(false)
const cc = ref(false)
const open = ref(false)
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "cc" >
2024-11-26 11:59:11 +00:00
Creative commons
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "seperatorMenu" >
< OptionsButton @click =" seperatorMenu = !seperatorMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "cc" >
2024-11-26 11:59:11 +00:00
Creative commons
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
## Submenus
2024-12-04 15:06:34 +00:00
To create more complex menus, you can use submenus (`PopoverSubmenu`). Submenus are menu items which contain other menu items.
2024-11-26 11:59:11 +00:00
```vue{10-18}
< script setup lang = "ts" >
const bc = ref(false)
const open = ref(false)
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-collection" / >
Organize and share
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "subMenu" >
< OptionsButton @click =" subMenu = !subMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-collection" / >
Organize and share
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
## Extra items
You can add extra items to the right hand side of a popover item by nesting them in a `<template #after>` tag. Use this to add additional menus or buttons to menu items.
```vue{18-29,34-37}
< script setup lang = "ts" >
const bc = ref(false)
const privacyChoices = ['public', 'private', 'pod']
const bcPrivacy = ref('pod')
const open = ref(false)
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-collection" / >
Organize and share
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
< template #after >
2024-12-04 15:06:34 +00:00
< Popover >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-04 15:06:34 +00:00
< Pill @click . stop = "toggleOpen" :blue = "bcPrivacy === 'pod'" :red = "bcPrivacy === 'public'" >
2024-11-26 11:59:11 +00:00
{{ bcPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "share" >
2024-11-26 11:59:11 +00:00
Share by link
< template #after >
2024-12-04 15:06:34 +00:00
< Button @click . stop = "alert('Link copied to clipboard')" color = "secondary" round icon = "bi-link" />
< Button @click . stop = "alert('Here is your code')" color = "secondary" round icon = "bi-code" />
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "extraItemsMenu" >
< OptionsButton @click =" extraItemsMenu = !extraItemsMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-collection" / >
Organize and share
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
< template #after >
2024-12-04 15:06:34 +00:00
< Popover >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-04 15:06:34 +00:00
< Pill @click . stop = "toggleOpen" :blue = "bcPrivacy === 'pod'" :red = "bcPrivacy === 'public'" >
2024-11-26 11:59:11 +00:00
{{ bcPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "share" >
2024-11-26 11:59:11 +00:00
Share by link
< template #after >
2024-12-04 15:06:34 +00:00
< Button @click . stop = "alert('Link copied to clipboard')" secondary round icon = "bi-link" />
< Button @click . stop = "alert('Here is your code')" secondary round icon = "bi-code" />
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
2024-12-17 22:15:31 +00:00
## Links
You can use `PopoverItem` s as Links by providing a `to` prop with the route object or and external Url (`http...`). Read more on the [Link component ](./link ) page.
2024-12-20 14:58:35 +00:00
< Popover v-model:open = "linksMenu" >
< OptionsButton @click =" linksMenu = !linksMenu" />
< template #items >
< PopoverItem to = "a" >
< i class = "bi bi-music-note-list" / >
Hello
< / PopoverItem >
< PopoverSubmenu >
< i class = "bi bi-music-note-list" / >
Change language
< template #items >
< PopoverItem
v-for="(language, key) in SUPPORTED_LOCALES"
:key="key"
:to="key"
>
< i class = "bi bi-gear-fill" / >
{{ language }}
< / PopoverItem >
< / template >
< / PopoverSubmenu >
< / template >
< / Popover >
2024-11-26 11:59:11 +00:00
## Menu
Here is an example of a completed menu containing all supported features.
```vue
< script setup lang = "ts" >
const open = ref(false);
const bc = ref(false);
const cc = ref(false);
const share = ref(false);
const bcPrivacy = ref("pod");
const ccPrivacy = ref("public");
const privacyChoices = ["private", "pod", "public"];
< / script >
< template >
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "open" >
< OptionsButton @click =" open = !open" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-14 18:22:29 +00:00
< PopoverSubmenu >
< i class = "bi bi-music-note-list" / >
Change language
< template #items >
< PopoverItem
v-for="(language, key) in SUPPORTED_LOCALES"
:key="key"
@click ="setI18nLanguage(key)"
>
{{ language }}
< / PopoverItem >
< / template >
< / PopoverSubmenu >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-arrow-up-right" / >
Play next
2024-12-04 15:06:34 +00:00
< / PopoverItem >
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-arrow-down-right" / >
Append to queue
2024-12-04 15:06:34 +00:00
< / PopoverItem >
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-music-note-list" / >
Add to playlist
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-music-note-list" / >
Sample playlist
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< hr / >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-plus-lg" / >
New playlist
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< hr / >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-heart" / >
Add to favorites
2024-12-04 15:06:34 +00:00
< / PopoverItem >
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-collection" / >
Organize and share
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
< template #after >
2024-12-04 15:06:34 +00:00
< Popover >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-04 15:06:34 +00:00
< Pill
2024-11-26 11:59:11 +00:00
@click .stop="toggleOpen"
:blue="bcPrivacy === 'pod'"
:red="bcPrivacy === 'public'"
>
{{ bcPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
< PopoverCheckbox v-model = "cc" >
2024-11-26 11:59:11 +00:00
Creative Commons
< template #after >
2024-12-06 16:20:41 +00:00
< Popover v-model:open = "isOpen" >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-04 15:06:34 +00:00
< Pill
2024-12-06 16:20:41 +00:00
@click ="toggleOpen"
2024-11-26 11:59:11 +00:00
:blue="ccPrivacy === 'pod'"
:red="ccPrivacy === 'public'"
>
{{ ccPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "ccPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< hr / >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-plus-lg" / >
New library
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< hr / >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "share" >
2024-11-26 11:59:11 +00:00
Share by link
< template #after >
2024-12-04 15:06:34 +00:00
< Button @click . stop color = "secondary" round icon = "bi-link" />
< Button @click . stop color = "secondary" round icon = "bi-code" />
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-cloud-download" / >
Download
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< hr / >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-exclamation" / >
Report
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
```
2024-12-04 15:06:34 +00:00
< Popover v-model:open = "fullMenu" >
< OptionsButton @click =" fullMenu = !fullMenu" />
2024-11-26 11:59:11 +00:00
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-arrow-up-right" / >
Play next
2024-12-04 15:06:34 +00:00
< / PopoverItem >
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-arrow-down-right" / >
Append to queue
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-12-14 18:22:29 +00:00
< PopoverSubmenu >
< i class = "bi bi-music-note-list" / >
Change language
< template #items >
< PopoverItem v-for = "(language, key) in SUPPORTED_LOCALES"
:key="key"
@click ="setI18nLanguage(key)" >
{{ language }}
< / PopoverItem >
< / template >
< / PopoverSubmenu >
2024-12-04 15:06:34 +00:00
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-music-note-list" / >
Add to playlist
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-music-note-list" / >
Sample playlist
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-plus-lg" / >
New playlist
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-heart" / >
Add to favorites
2024-12-04 15:06:34 +00:00
< / PopoverItem >
< PopoverSubmenu >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-collection" / >
Organize and share
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "bc" >
2024-11-26 11:59:11 +00:00
Bandcamp
< template #after >
2024-12-06 16:20:41 +00:00
< Popover v-model:open = "isOpen" >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-04 15:06:34 +00:00
< Pill @click . stop = "toggleOpen" :blue = "bcPrivacy === 'pod'" :red = "bcPrivacy === 'public'" >
2024-11-26 11:59:11 +00:00
{{ bcPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "bcPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
< PopoverCheckbox v-model = "cc" >
2024-11-26 11:59:11 +00:00
Creative Commons
< template #after >
2024-12-06 16:20:41 +00:00
< Popover v-model:open = "isOpen" >
2024-11-26 11:59:11 +00:00
< template #default ="{ toggleOpen }" >
2024-12-06 16:20:41 +00:00
< Pill @click =" toggleOpen " :blue = "ccPrivacy === 'pod'" :red = "ccPrivacy === 'public'" >
2024-11-26 11:59:11 +00:00
{{ ccPrivacy }}
2024-12-04 15:06:34 +00:00
< / Pill >
2024-11-26 11:59:11 +00:00
< / template >
< template #items >
2024-12-04 15:06:34 +00:00
< PopoverRadio v-model = "ccPrivacy" :choices = "privacyChoices" / >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-plus-lg" / >
New library
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverCheckbox v-model = "share" >
2024-11-26 11:59:11 +00:00
Share by link
< template #after >
2024-12-04 15:06:34 +00:00
< Button @click . stop color = "secondary" round icon = "bi-link" />
< Button @click . stop color = "secondary" round icon = "bi-code" />
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverCheckbox >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / PopoverSubmenu >
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-cloud-download" / >
Download
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< hr >
2024-12-04 15:06:34 +00:00
< PopoverItem >
2024-11-26 11:59:11 +00:00
< i class = "bi bi-exclamation" / >
Report
2024-12-04 15:06:34 +00:00
< / PopoverItem >
2024-11-26 11:59:11 +00:00
< / template >
2024-12-04 15:06:34 +00:00
< / Popover >