From c443593619cc3f9d3e68e8a2268c9becb62f862c Mon Sep 17 00:00:00 2001 From: ArneBo Date: Wed, 15 Jan 2025 11:00:46 +0100 Subject: [PATCH] feat(ui): Splittable playbutton with consistent popover --- front/src/components/audio/PlayButton.vue | 248 ++++++++---------- front/src/components/ui/Button.vue | 76 +++++- front/src/components/ui/Popover.vue | 4 +- front/src/components/ui/popover.scss | 32 +-- .../src/components/ui/popover/PopoverItem.vue | 68 ++++- 5 files changed, 258 insertions(+), 170 deletions(-) diff --git a/front/src/components/audio/PlayButton.vue b/front/src/components/audio/PlayButton.vue index 4f3636f96..a76d363f5 100644 --- a/front/src/components/audio/PlayButton.vue +++ b/front/src/components/audio/PlayButton.vue @@ -2,14 +2,17 @@ import type { Track, Artist, Album, Playlist, Library, Channel, Actor } from '~/types' import type { PlayOptionsProps } from '~/composables/audio/usePlayOptions' -import { computed } from 'vue' +import { computed, ref } from 'vue' import { useI18n } from 'vue-i18n' import usePlayOptions from '~/composables/audio/usePlayOptions' import useReport from '~/composables/moderation/useReport' -// import { useCurrentElement } from '@vueuse/core' -// import { setupDropdown } from '~/utils/fomantic' import { useStore } from '~/store' import { useRouter, useRoute } from 'vue-router' +import { color } from "~/composables/color.ts"; + +import Button from '~/components/ui/Button.vue' +import Popover from '~/components/ui/Popover.vue' +import PopoverItem from '~/components/ui/popover/PopoverItem.vue' interface Props extends PlayOptionsProps { @@ -43,8 +46,8 @@ const props = withDefaults(defineProps(), { library: null, channel: null, account: null, - dropdownIconClasses: () => ['dropdown'], - playIconClass: () => 'play icon', + dropdownIconClasses: () => ['bi-caret-down-fill'], + playIconClass: () => 'bi bi-play-fill', buttonClasses: () => ['button'], discrete: () => false, dropdownOnly: () => false, @@ -102,141 +105,118 @@ const title = computed(() => { return '' }) -// const el = useCurrentElement() -// const dropdown = ref() -// onMounted(() => { -// dropdown.value = setupDropdown('.ui.dropdown', el.value) -// }) +const isOpen = ref(false) -const openMenu = () => { - // little magic to ensure the menu is always visible in the viewport - // By default, try to display it on the right if there is enough room - - // TODO: Re-implement with `Popover` component instead of fomantic dropdown - - // const menu = dropdown.value.find('.menu') - - // if (menu.hasClass('visible')) return - // const viewportOffset = menu.get(0)?.getBoundingClientRect() ?? { right: 0, left: 0 } - // const viewportWidth = document.documentElement.clientWidth - // const rightOverflow = viewportOffset.right - viewportWidth - // const leftOverflow = -viewportOffset.left - - // menu.css({ - // cssText: rightOverflow > 0 - // ? `left: ${-rightOverflow - 5}px !important;` - // : `right: ${-leftOverflow + 5}px !important;` - // }) -} diff --git a/front/src/components/ui/Button.vue b/front/src/components/ui/Button.vue index dc0089baa..58ed125cf 100644 --- a/front/src/components/ui/Button.vue +++ b/front/src/components/ui/Button.vue @@ -20,6 +20,11 @@ const props = defineProps<{ onClick?: (...args: any[]) => void | Promise + split?: boolean // Add this prop for split button support + splitIcon?: string // Add this prop for the split button icon + splitTitle?: string // Add this prop + onSplitClick?: (...args: any[]) => void | Promise // Add click handler for split part + autofocus? : boolean ariaPressed? : true } & (ColorProps | DefaultProps) @@ -53,12 +58,14 @@ onMounted(() => { + +