From 2ea9f582a5b79fe57aff4d4605800313ac00f476 Mon Sep 17 00:00:00 2001 From: Phan An Date: Sun, 13 Nov 2022 16:18:24 +0100 Subject: [PATCH] feat: use Floating UI for "Add To" menu (#1584) --- .../assets/js/components/auth/LoginForm.vue | 2 +- .../js/components/meta/AboutKoelModal.vue | 2 +- .../playlist/CreateNewPlaylistContextMenu.vue | 2 - .../playlist/CreatePlaylistFolderForm.vue | 3 +- .../playlist/CreatePlaylistForm.vue | 3 +- .../playlist/EditPlaylistFolderForm.vue | 3 +- .../components/playlist/EditPlaylistForm.vue | 3 +- .../CreateSmartPlaylistForm.vue | 2 +- .../smart-playlist/EditSmartPlaylistForm.vue | 2 +- .../smart-playlist/SmartPlaylistRule.vue | 7 +- .../smart-playlist/SmartPlaylistRuleGroup.vue | 2 +- .../smart-playlist/SmartPlaylistRuleInput.vue | 2 +- .../__snapshots__/AllSongsScreen.spec.ts.snap | 26 ++++--- .../assets/js/components/song/AddToMenu.vue | 37 ++-------- .../js/components/song/EditSongForm.vue | 2 +- .../assets/js/components/song/SongList.vue | 9 ++- .../components/song/SongListControls.spec.ts | 10 --- .../js/components/song/SongListControls.vue | 74 +++++++++++-------- .../js/components/song/SongListSorter.vue | 3 +- .../song/__snapshots__/AddToMenu.spec.ts.snap | 2 +- .../js/components/ui/ArtistAlbumCard.vue | 6 +- resources/assets/js/components/ui/Btn.vue | 12 ++- .../assets/js/components/ui/BtnCloseModal.vue | 2 +- .../assets/js/components/ui/CheckBox.vue | 2 +- .../assets/js/components/ui/Equalizer.vue | 2 +- .../js/components/ui/ExtraPanelTabHeader.vue | 2 +- .../assets/js/components/ui/Magnifier.vue | 2 +- .../assets/js/components/ui/MessageToast.vue | 2 +- .../js/components/ui/ScreenControlsToggle.vue | 2 +- .../js/components/ui/ViewModeSwitch.vue | 3 +- .../js/components/ui/VirtualScroller.vue | 5 +- .../assets/js/components/user/AddUserForm.vue | 3 +- .../js/components/user/EditUserForm.vue | 3 +- resources/assets/sass/partials/_mixins.scss | 20 ++--- 34 files changed, 129 insertions(+), 133 deletions(-) diff --git a/resources/assets/js/components/auth/LoginForm.vue b/resources/assets/js/components/auth/LoginForm.vue index 93f99134..9e523fd2 100644 --- a/resources/assets/js/components/auth/LoginForm.vue +++ b/resources/assets/js/components/auth/LoginForm.vue @@ -26,7 +26,7 @@ const email = ref(isDemo() ? DEMO_ACCOUNT.email : '') const password = ref(isDemo() ? DEMO_ACCOUNT.password : '') const failed = ref(false) -const emit = defineEmits(['loggedin']) +const emit = defineEmits<{ (e: 'loggedin'): void }>() const login = async () => { try { diff --git a/resources/assets/js/components/meta/AboutKoelModal.vue b/resources/assets/js/components/meta/AboutKoelModal.vue index 2dccb9ac..6b06f932 100644 --- a/resources/assets/js/components/meta/AboutKoelModal.vue +++ b/resources/assets/js/components/meta/AboutKoelModal.vue @@ -70,7 +70,7 @@ const { latestVersionReleaseUrl } = useNewVersionNotification() -const emit = defineEmits(['close']) +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') onMounted(async () => { diff --git a/resources/assets/js/components/playlist/CreateNewPlaylistContextMenu.vue b/resources/assets/js/components/playlist/CreateNewPlaylistContextMenu.vue index dd0104c9..897ec97f 100644 --- a/resources/assets/js/components/playlist/CreateNewPlaylistContextMenu.vue +++ b/resources/assets/js/components/playlist/CreateNewPlaylistContextMenu.vue @@ -16,8 +16,6 @@ import { onMounted } from 'vue' const { base, ContextMenuBase, open, trigger } = useContextMenu() -const emit = defineEmits(['itemClicked']) - const actionToEventMap: Record = { 'new-playlist': 'MODAL_SHOW_CREATE_PLAYLIST_FORM', 'new-smart-playlist': 'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', diff --git a/resources/assets/js/components/playlist/CreatePlaylistFolderForm.vue b/resources/assets/js/components/playlist/CreatePlaylistFolderForm.vue index 84ae05b6..1267a8ff 100644 --- a/resources/assets/js/components/playlist/CreatePlaylistFolderForm.vue +++ b/resources/assets/js/components/playlist/CreatePlaylistFolderForm.vue @@ -42,8 +42,7 @@ const dialog = requireInjection(DialogBoxKey) const loading = ref(false) const name = ref('') -const emit = defineEmits(['close']) - +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') const submit = async () => { diff --git a/resources/assets/js/components/playlist/CreatePlaylistForm.vue b/resources/assets/js/components/playlist/CreatePlaylistForm.vue index d24b4260..6fcde682 100644 --- a/resources/assets/js/components/playlist/CreatePlaylistForm.vue +++ b/resources/assets/js/components/playlist/CreatePlaylistForm.vue @@ -43,8 +43,7 @@ const dialog = requireInjection(DialogBoxKey) const loading = ref(false) const name = ref('') -const emit = defineEmits(['close']) - +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') const submit = async () => { diff --git a/resources/assets/js/components/playlist/EditPlaylistFolderForm.vue b/resources/assets/js/components/playlist/EditPlaylistFolderForm.vue index 0ee122d2..5d09880c 100644 --- a/resources/assets/js/components/playlist/EditPlaylistFolderForm.vue +++ b/resources/assets/js/components/playlist/EditPlaylistFolderForm.vue @@ -60,8 +60,7 @@ const submit = async () => { } } -const emit = defineEmits(['close']) - +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') const maybeClose = async () => { diff --git a/resources/assets/js/components/playlist/EditPlaylistForm.vue b/resources/assets/js/components/playlist/EditPlaylistForm.vue index 9b8c08e7..e32b9952 100644 --- a/resources/assets/js/components/playlist/EditPlaylistForm.vue +++ b/resources/assets/js/components/playlist/EditPlaylistForm.vue @@ -60,8 +60,7 @@ const submit = async () => { } } -const emit = defineEmits(['close']) - +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') const maybeClose = async () => { diff --git a/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue b/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue index 544fbb7a..30512d5e 100644 --- a/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue +++ b/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue @@ -60,7 +60,7 @@ const dialog = requireInjection(DialogBoxKey) const router = requireInjection(RouterKey) const name = ref('') -const emit = defineEmits(['close']) +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') const maybeClose = async () => { diff --git a/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue b/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue index 95f296a7..54bb0185 100644 --- a/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue +++ b/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue @@ -73,7 +73,7 @@ const { onGroupChanged } = useSmartPlaylistForm(mutablePlaylist.rules) -const emit = defineEmits(['close']) +const emit = defineEmits<{ (e: 'close'): void }>() const close = () => emit('close') const maybeClose = async () => { diff --git a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue index 106165f0..077c19bc 100644 --- a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue +++ b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue @@ -96,7 +96,10 @@ watch(availableOperators, () => { const valueSuffix = computed(() => selectedOperator.value?.unit || selectedModel.value?.unit) -const emit = defineEmits(['input', 'remove']) +const emit = defineEmits<{ + (e: 'input', rule: SmartPlaylistRule): void, + (e: 'remove'): void +}>() const onInput = () => { emit('input', { @@ -104,7 +107,7 @@ const onInput = () => { model: selectedModel.value, operator: selectedOperator.value?.operator, value: availableInputs.value.map(input => input.value) - } as SmartPlaylistRule) + }) } const removeRule = () => emit('remove') diff --git a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleGroup.vue b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleGroup.vue index 1b757d4e..9aa07a15 100644 --- a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleGroup.vue +++ b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleGroup.vue @@ -37,7 +37,7 @@ const Rule = defineAsyncComponent(() => import('@/components/playlist/smart-play const mutatedGroup = reactive(JSON.parse(JSON.stringify(group.value))) -const emit = defineEmits(['input']) +const emit = defineEmits<{ (e: 'input', group: SmartPlaylistRuleGroup): void }>() const notifyParentForUpdate = () => emit('input', mutatedGroup) diff --git a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleInput.vue b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleInput.vue index e96cf641..63d49c7b 100644 --- a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleInput.vue +++ b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRuleInput.vue @@ -9,7 +9,7 @@ import inputTypes from '@/config/smart-playlist/inputTypes' const props = withDefaults(defineProps<{ type?: keyof typeof inputTypes, value?: any }>(), { value: undefined }) const { type } = toRefs(props) -const emit = defineEmits(['update:modelValue']) +const emit = defineEmits<{ (e: 'update:modelValue', value: any): void }>() const value = computed({ get: () => props.value, diff --git a/resources/assets/js/components/screens/__snapshots__/AllSongsScreen.spec.ts.snap b/resources/assets/js/components/screens/__snapshots__/AllSongsScreen.spec.ts.snap index 7d5ebdf2..c332aafd 100644 --- a/resources/assets/js/components/screens/__snapshots__/AllSongsScreen.spec.ts.snap +++ b/resources/assets/js/components/screens/__snapshots__/AllSongsScreen.spec.ts.snap @@ -14,18 +14,20 @@ exports[`renders 1`] = `
- diff --git a/resources/assets/js/components/song/AddToMenu.vue b/resources/assets/js/components/song/AddToMenu.vue index ae0c8425..0ec3781d 100644 --- a/resources/assets/js/components/song/AddToMenu.vue +++ b/resources/assets/js/components/song/AddToMenu.vue @@ -1,13 +1,5 @@