trashposs/packages/client/src/components/MkStarButton.vue

43 lines
993 B
Vue
Raw Normal View History

2022-10-26 05:20:41 +02:00
<template>
2022-11-25 12:46:10 +01:00
<button class="skdfgljsdkf _button" v-tooltip.noDelay.bottom="text" @click="star($event)">
2022-11-07 03:49:47 +01:00
<i class="ph-star-bold ph-lg"></i>
2022-10-26 05:20:41 +02:00
</button>
</template>
<script lang="ts" setup>
import type { Note } from 'misskey-js/built/entities';
2022-10-26 05:33:09 +02:00
import Ripple from '@/components/MkRipple.vue';
2022-10-26 05:20:41 +02:00
import { pleaseLogin } from '@/scripts/please-login';
import * as os from '@/os';
2022-11-25 12:46:10 +01:00
const text = 'Like';
2022-10-26 05:20:41 +02:00
const props = defineProps<{
note: Note;
}>();
2022-10-26 05:33:09 +02:00
function star(ev?: MouseEvent): void {
2022-10-26 05:20:41 +02:00
pleaseLogin();
os.api('notes/reactions/create', {
noteId: props.note.id,
reaction: '⭐',
});
2022-10-26 05:33:09 +02:00
const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
if (el) {
const rect = el.getBoundingClientRect();
const x = rect.left + (el.offsetWidth / 2);
const y = rect.top + (el.offsetHeight / 2);
os.popup(Ripple, { x, y }, {}, 'end');
}
2022-10-26 05:20:41 +02:00
}
</script>
<style lang="scss" scoped>
.skdfgljsdkf {
display: inline-block;
height: 32px;
margin: 2px;
padding: 0 6px;
}
</style>