summaryrefslogtreecommitdiff
path: root/src/client/components/renote-picker.vue
blob: d8258d5f5df9210a3c454f1ab9f2598ea1c8bcda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
<x-popup :source="source" ref="popup" @closed="() => { $emit('closed'); destroyDom(); }" v-hotkey.global="keymap">
	<div class="rdfaahpc">
		<button class="_button" @click="renote()"><fa :icon="faRetweet"/></button>
		<button class="_button" @click="quote()"><fa :icon="faQuoteRight"/></button>
	</div>
</x-popup>
</template>

<script lang="ts">
import Vue from 'vue';
import { faQuoteRight, faRetweet } from '@fortawesome/free-solid-svg-icons';
import i18n from '../i18n';
import XPopup from './popup.vue';

export default Vue.extend({
	i18n,

	components: {
		XPopup,
	},

	props: {
		note: {
			type: Object,
			required: true
		},

		source: {
			required: true
		},
	},

	data() {
		return {
			faQuoteRight, faRetweet
		};
	},

	computed: {
		keymap(): any {
			return {
				'esc': this.close,
			};
		}
	},

	methods: {
		renote() {
			(this as any).$root.api('notes/create', {
				renoteId: this.note.id
			}).then(() => {
				this.$emit('closed');
				this.destroyDom();
			});
		},

		quote() {
			this.$emit('closed');
			this.destroyDom();
			this.$root.post({
				renote: this.note,
			});
		}
	}
});
</script>

<style lang="scss" scoped>
.rdfaahpc {
	padding: 4px;

	> button {
		padding: 0;
		width: 40px;
		height: 40px;
		font-size: 16px;
		border-radius: 2px;

		> * {
			height: 1em;
		}

		&:hover {
			background: rgba(0, 0, 0, 0.05);
		}

		&:active {
			background: var(--accent);
			box-shadow: inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15);
		}
	}
}
</style>