diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-05-22 12:24:52 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-05-22 12:24:52 +0900 |
| commit | 74c857e23d1ff2350f90e1a6a6278920d74173bf (patch) | |
| tree | e658f17b893ddf272429c4fe870a3e92228f692f /packages/frontend/src/components | |
| parent | Bump version to 2025.5.1-alpha.4 (diff) | |
| download | misskey-74c857e23d1ff2350f90e1a6a6278920d74173bf.tar.gz misskey-74c857e23d1ff2350f90e1a6a6278920d74173bf.tar.bz2 misskey-74c857e23d1ff2350f90e1a6a6278920d74173bf.zip | |
refactor(frontend): src -> anchorElement
Diffstat (limited to 'packages/frontend/src/components')
6 files changed, 32 insertions, 32 deletions
diff --git a/packages/frontend/src/components/MkEmojiPickerDialog.vue b/packages/frontend/src/components/MkEmojiPickerDialog.vue index 662e2a118d..1627dc8760 100644 --- a/packages/frontend/src/components/MkEmojiPickerDialog.vue +++ b/packages/frontend/src/components/MkEmojiPickerDialog.vue @@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only :hasInteractionWithOtherFocusTrappedEls="true" :transparentBg="true" :manualShowing="manualShowing" - :src="src" + :anchorElement="anchorElement" @click="modal?.close()" @esc="modal?.close()" @opening="opening" @@ -44,7 +44,7 @@ import { prefer } from '@/preferences.js'; const props = withDefaults(defineProps<{ manualShowing?: boolean | null; - src?: HTMLElement; + anchorElement?: HTMLElement; showPinned?: boolean; pinnedEmojis?: string[], asReactionPicker?: boolean; diff --git a/packages/frontend/src/components/MkLaunchPad.vue b/packages/frontend/src/components/MkLaunchPad.vue index 3e5a88a170..584afff55c 100644 --- a/packages/frontend/src/components/MkLaunchPad.vue +++ b/packages/frontend/src/components/MkLaunchPad.vue @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only --> <template> -<MkModal ref="modal" v-slot="{ type, maxHeight }" :preferType="preferedModalType" :anchor="anchor" :transparentBg="true" :src="src" @click="modal?.close()" @closed="emit('closed')" @esc="modal?.close()"> +<MkModal ref="modal" v-slot="{ type, maxHeight }" :preferType="preferedModalType" :anchor="anchor" :transparentBg="true" :anchorElement="anchorElement" @click="modal?.close()" @closed="emit('closed')" @esc="modal?.close()"> <div class="szkkfdyq _popup _shadow" :class="{ asDrawer: type === 'drawer' }" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : '' }"> <div class="main"> <template v-for="item in items" :key="item.text"> @@ -34,7 +34,7 @@ import { deviceKind } from '@/utility/device-kind.js'; import { prefer } from '@/preferences.js'; const props = withDefaults(defineProps<{ - src?: HTMLElement; + anchorElement?: HTMLElement; anchor?: { x: string; y: string; }; }>(), { anchor: () => ({ x: 'right', y: 'center' }), @@ -44,7 +44,7 @@ const emit = defineEmits<{ (ev: 'closed'): void; }>(); -const preferedModalType = (deviceKind === 'desktop' && props.src != null) ? 'popup' : +const preferedModalType = (deviceKind === 'desktop' && props.anchorElement != null) ? 'popup' : deviceKind === 'smartphone' ? 'drawer' : 'dialog'; diff --git a/packages/frontend/src/components/MkModal.vue b/packages/frontend/src/components/MkModal.vue index 3bcf835ec9..06686ddfc0 100644 --- a/packages/frontend/src/components/MkModal.vue +++ b/packages/frontend/src/components/MkModal.vue @@ -67,7 +67,7 @@ type ModalTypes = 'popup' | 'dialog' | 'drawer'; const props = withDefaults(defineProps<{ manualShowing?: boolean | null; anchor?: { x: string; y: string; }; - src?: HTMLElement | null; + anchorElement?: HTMLElement | null; preferType?: ModalTypes | 'auto'; zPriority?: 'low' | 'middle' | 'high'; noOverlap?: boolean; @@ -76,7 +76,7 @@ const props = withDefaults(defineProps<{ returnFocusTo?: HTMLElement | null; }>(), { manualShowing: null, - src: null, + anchorElement: null, anchor: () => ({ x: 'center', y: 'bottom' }), preferType: 'auto', zPriority: 'low', @@ -110,7 +110,7 @@ const type = computed<ModalTypes>(() => { if ((prefer.s.menuStyle === 'drawer') || (prefer.s.menuStyle === 'auto' && isTouchUsing && deviceKind === 'smartphone')) { return 'drawer'; } else { - return props.src != null ? 'popup' : 'dialog'; + return props.anchorElement != null ? 'popup' : 'dialog'; } } else { return props.preferType!; @@ -149,7 +149,7 @@ function close(opts: { useSendAnimation?: boolean } = {}) { } // eslint-disable-next-line vue/no-mutating-props - if (props.src) props.src.style.pointerEvents = 'auto'; + if (props.anchorElement) props.anchorElement.style.pointerEvents = 'auto'; showing.value = false; emit('close'); } @@ -174,13 +174,13 @@ const MARGIN = 16; const SCROLLBAR_THICKNESS = 16; const align = () => { - if (props.src == null) return; + if (props.anchorElement == null) return; if (type.value === 'drawer') return; if (type.value === 'dialog') return; if (content.value == null) return; - const srcRect = props.src.getBoundingClientRect(); + const anchorRect = props.anchorElement.getBoundingClientRect(); const width = content.value!.offsetWidth; const height = content.value!.offsetHeight; @@ -188,15 +188,15 @@ const align = () => { let left; let top; - const x = srcRect.left + (fixed.value ? 0 : window.scrollX); - const y = srcRect.top + (fixed.value ? 0 : window.scrollY); + const x = anchorRect.left + (fixed.value ? 0 : window.scrollX); + const y = anchorRect.top + (fixed.value ? 0 : window.scrollY); if (props.anchor.x === 'center') { - left = x + (props.src.offsetWidth / 2) - (width / 2); + left = x + (props.anchorElement.offsetWidth / 2) - (width / 2); } else if (props.anchor.x === 'left') { // TODO } else if (props.anchor.x === 'right') { - left = x + props.src.offsetWidth; + left = x + props.anchorElement.offsetWidth; } if (props.anchor.y === 'center') { @@ -204,7 +204,7 @@ const align = () => { } else if (props.anchor.y === 'top') { // TODO } else if (props.anchor.y === 'bottom') { - top = y + props.src.offsetHeight; + top = y + props.anchorElement.offsetHeight; } if (fixed.value) { @@ -214,7 +214,7 @@ const align = () => { } const underSpace = ((window.innerHeight - SCROLLBAR_THICKNESS) - MARGIN) - top; - const upperSpace = (srcRect.top - MARGIN); + const upperSpace = (anchorRect.top - MARGIN); // 画面から縦にはみ出る場合 if (top + height > ((window.innerHeight - SCROLLBAR_THICKNESS) - MARGIN)) { @@ -238,7 +238,7 @@ const align = () => { } const underSpace = ((window.innerHeight - SCROLLBAR_THICKNESS) - MARGIN) - (top - window.scrollY); - const upperSpace = (srcRect.top - MARGIN); + const upperSpace = (anchorRect.top - MARGIN); // 画面から縦にはみ出る場合 if (top + height - window.scrollY > ((window.innerHeight - SCROLLBAR_THICKNESS) - MARGIN)) { @@ -268,15 +268,15 @@ const align = () => { let transformOriginX = 'center'; let transformOriginY = 'center'; - if (top >= srcRect.top + props.src.offsetHeight + (fixed.value ? 0 : window.scrollY)) { + if (top >= anchorRect.top + props.anchorElement.offsetHeight + (fixed.value ? 0 : window.scrollY)) { transformOriginY = 'top'; - } else if ((top + height) <= srcRect.top + (fixed.value ? 0 : window.scrollY)) { + } else if ((top + height) <= anchorRect.top + (fixed.value ? 0 : window.scrollY)) { transformOriginY = 'bottom'; } - if (left >= srcRect.left + props.src.offsetWidth + (fixed.value ? 0 : window.scrollX)) { + if (left >= anchorRect.left + props.anchorElement.offsetWidth + (fixed.value ? 0 : window.scrollX)) { transformOriginX = 'left'; - } else if ((left + width) <= srcRect.left + (fixed.value ? 0 : window.scrollX)) { + } else if ((left + width) <= anchorRect.left + (fixed.value ? 0 : window.scrollX)) { transformOriginX = 'right'; } @@ -317,12 +317,12 @@ const alignObserver = new ResizeObserver((entries, observer) => { }); onMounted(() => { - watch(() => props.src, async () => { - if (props.src) { + watch(() => props.anchorElement, async () => { + if (props.anchorElement) { // eslint-disable-next-line vue/no-mutating-props - props.src.style.pointerEvents = 'none'; + props.anchorElement.style.pointerEvents = 'none'; } - fixed.value = (type.value === 'drawer') || (getFixedContainer(props.src) != null); + fixed.value = (type.value === 'drawer') || (getFixedContainer(props.anchorElement) != null); await nextTick(); @@ -339,7 +339,7 @@ onMounted(() => { } } else { releaseFocusTrap?.(); - focusParent(props.returnFocusTo ?? props.src, true, false); + focusParent(props.returnFocusTo ?? props.anchorElement, true, false); } }, { immediate: true }); diff --git a/packages/frontend/src/components/MkPopupMenu.vue b/packages/frontend/src/components/MkPopupMenu.vue index 232cc005e1..4942ffe232 100644 --- a/packages/frontend/src/components/MkPopupMenu.vue +++ b/packages/frontend/src/components/MkPopupMenu.vue @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only --> <template> -<MkModal ref="modal" v-slot="{ type, maxHeight }" :manualShowing="manualShowing" :zPriority="'high'" :src="src" :transparentBg="true" :returnFocusTo="returnFocusTo" @click="click" @close="onModalClose" @closed="onModalClosed"> +<MkModal ref="modal" v-slot="{ type, maxHeight }" :manualShowing="manualShowing" :zPriority="'high'" :anchorElement="anchorElement" :transparentBg="true" :returnFocusTo="returnFocusTo" @click="click" @close="onModalClose" @closed="onModalClosed"> <MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :returnFocusTo="returnFocusTo" :class="{ [$style.drawer]: type === 'drawer' }" @close="onMenuClose" @hide="hide"/> </MkModal> </template> @@ -19,7 +19,7 @@ defineProps<{ items: MenuItem[]; align?: 'center' | string; width?: number; - src?: HTMLElement | null; + anchorElement?: HTMLElement | null; returnFocusTo?: HTMLElement | null; }>(); diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index d07ee2a978..982ed88003 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -470,7 +470,7 @@ function setVisibility() { currentVisibility: visibility.value, isSilenced: $i.isSilenced, localOnly: localOnly.value, - src: visibilityButton.value, + anchorElement: visibilityButton.value, ...(props.reply ? { isReplyVisibilitySpecified: props.reply.visibility === 'specified' } : {}), }, { changeVisibility: v => { diff --git a/packages/frontend/src/components/MkVisibilityPicker.vue b/packages/frontend/src/components/MkVisibilityPicker.vue index cb402b1a57..3801195da6 100644 --- a/packages/frontend/src/components/MkVisibilityPicker.vue +++ b/packages/frontend/src/components/MkVisibilityPicker.vue @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only --> <template> -<MkModal ref="modal" v-slot="{ type }" :zPriority="'high'" :src="src" @click="modal?.close()" @closed="emit('closed')" @esc="modal?.close()"> +<MkModal ref="modal" v-slot="{ type }" :zPriority="'high'" :anchorElement="anchorElement" @click="modal?.close()" @closed="emit('closed')" @esc="modal?.close()"> <div class="_popup" :class="{ [$style.root]: true, [$style.asDrawer]: type === 'drawer' }"> <div :class="[$style.label, $style.item]"> {{ i18n.ts.visibility }} @@ -53,7 +53,7 @@ const props = withDefaults(defineProps<{ currentVisibility: typeof Misskey.noteVisibilities[number]; isSilenced: boolean; localOnly: boolean; - src?: HTMLElement; + anchorElement?: HTMLElement; isReplyVisibilitySpecified?: boolean; }>(), { }); |