chore(client): tweak ui
This commit is contained in:
parent
6ba888f476
commit
7c7ce072c7
|
@ -12,39 +12,22 @@
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { computed, defineComponent, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
|
import * as misskey from 'misskey-js';
|
||||||
import XDetails from '@/components/reactions-viewer.details.vue';
|
import XDetails from '@/components/reactions-viewer.details.vue';
|
||||||
import XReactionIcon from '@/components/reaction-icon.vue';
|
import XReactionIcon from '@/components/reaction-icon.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { useTooltip } from '@/scripts/use-tooltip';
|
import { useTooltip } from '@/scripts/use-tooltip';
|
||||||
import { $i } from '@/account';
|
import { $i } from '@/account';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
components: {
|
reaction: string;
|
||||||
XReactionIcon
|
count: number;
|
||||||
},
|
isInitial: boolean;
|
||||||
|
note: misskey.entities.Note;
|
||||||
|
}>();
|
||||||
|
|
||||||
props: {
|
|
||||||
reaction: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
count: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
isInitial: {
|
|
||||||
type: Boolean,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
note: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup(props) {
|
|
||||||
const buttonRef = ref<HTMLElement>();
|
const buttonRef = ref<HTMLElement>();
|
||||||
|
|
||||||
const canToggle = computed(() => !props.reaction.match(/@\w/) && $i);
|
const canToggle = computed(() => !props.reaction.match(/@\w/) && $i);
|
||||||
|
@ -55,19 +38,19 @@ export default defineComponent({
|
||||||
const oldReaction = props.note.myReaction;
|
const oldReaction = props.note.myReaction;
|
||||||
if (oldReaction) {
|
if (oldReaction) {
|
||||||
os.api('notes/reactions/delete', {
|
os.api('notes/reactions/delete', {
|
||||||
noteId: props.note.id
|
noteId: props.note.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (oldReaction !== props.reaction) {
|
if (oldReaction !== props.reaction) {
|
||||||
os.api('notes/reactions/create', {
|
os.api('notes/reactions/create', {
|
||||||
noteId: props.note.id,
|
noteId: props.note.id,
|
||||||
reaction: props.reaction
|
reaction: props.reaction,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
os.api('notes/reactions/create', {
|
os.api('notes/reactions/create', {
|
||||||
noteId: props.note.id,
|
noteId: props.note.id,
|
||||||
reaction: props.reaction
|
reaction: props.reaction,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -90,7 +73,7 @@ export default defineComponent({
|
||||||
const reactions = await os.api('notes/reactions', {
|
const reactions = await os.api('notes/reactions', {
|
||||||
noteId: props.note.id,
|
noteId: props.note.id,
|
||||||
type: props.reaction,
|
type: props.reaction,
|
||||||
limit: 11
|
limit: 11,
|
||||||
});
|
});
|
||||||
|
|
||||||
const users = reactions.map(x => x.user);
|
const users = reactions.map(x => x.user);
|
||||||
|
@ -103,15 +86,7 @@ export default defineComponent({
|
||||||
count: props.count,
|
count: props.count,
|
||||||
targetElement: buttonRef.value,
|
targetElement: buttonRef.value,
|
||||||
}, {}, 'closed');
|
}, {}, 'closed');
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
return {
|
|
||||||
buttonRef,
|
|
||||||
canToggle,
|
|
||||||
toggleReaction,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Ref, ref, watch, onUnmounted } from 'vue';
|
||||||
export function useTooltip(
|
export function useTooltip(
|
||||||
elRef: Ref<HTMLElement | { $el: HTMLElement } | null | undefined>,
|
elRef: Ref<HTMLElement | { $el: HTMLElement } | null | undefined>,
|
||||||
onShow: (showing: Ref<boolean>) => void,
|
onShow: (showing: Ref<boolean>) => void,
|
||||||
|
delay = 300,
|
||||||
): void {
|
): void {
|
||||||
let isHovering = false;
|
let isHovering = false;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ export function useTooltip(
|
||||||
if (isHovering) return;
|
if (isHovering) return;
|
||||||
if (shouldIgnoreMouseover) return;
|
if (shouldIgnoreMouseover) return;
|
||||||
isHovering = true;
|
isHovering = true;
|
||||||
timeoutId = window.setTimeout(open, 300);
|
timeoutId = window.setTimeout(open, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMouseleave = () => {
|
const onMouseleave = () => {
|
||||||
|
@ -54,7 +55,7 @@ export function useTooltip(
|
||||||
shouldIgnoreMouseover = true;
|
shouldIgnoreMouseover = true;
|
||||||
if (isHovering) return;
|
if (isHovering) return;
|
||||||
isHovering = true;
|
isHovering = true;
|
||||||
timeoutId = window.setTimeout(open, 300);
|
timeoutId = window.setTimeout(open, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTouchend = () => {
|
const onTouchend = () => {
|
||||||
|
|
Loading…
Reference in New Issue