summaryrefslogtreecommitdiff
path: root/src/client/app/common/views/components/cw-button.vue
blob: 034848a11683a134f5aaa48a0c560e846bf37175 (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
<template>
<button class="nrvgflfuaxwgkxoynpnumyookecqrrvh" @click="toggle">
	<b>{{ value ? this.$t('hide') : this.$t('show') }}</b>
	<span v-if="!value">
		<span v-if="note.text">{{ this.$t('chars', { count: length(note.text) }) | number }}</span>
		<span v-if="note.text && note.files && note.files.length > 0"> / </span>
		<span v-if="note.files && note.files.length > 0">{{ this.$t('files', { count: note.files.length }) }}</span>
	</span>
</button>
</template>

<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import { length } from 'stringz';

export default Vue.extend({
	i18n: i18n('common/views/components/cw-button.vue'),

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

	methods: {
		length,

		toggle() {
			this.$emit('input', !this.value);
		}
	}
});
</script>

<style lang="stylus" scoped>
.nrvgflfuaxwgkxoynpnumyookecqrrvh
	display inline-block
	padding 4px 8px
	font-size 0.7em
	color var(--cwButtonFg)
	background var(--cwButtonBg)
	border-radius 2px
	cursor pointer
	user-select none

	&:hover
		background var(--cwButtonHoverBg)

	> span
		margin-left 4px

		&:before
			content '('
		&:after
			content ')'

</style>