summaryrefslogtreecommitdiff
path: root/packages/client/src/components/key-value.vue
blob: da98abd77c8f4e9c69a51468a0398e3070af1f37 (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
<template>
<div class="alqyeyti" :class="{ oneline }">
	<div class="key">
		<slot name="key"></slot>
	</div>
	<div class="value">
		<slot name="value"></slot>
		<button v-if="copy" v-tooltip="$ts.copy" class="_textButton" style="margin-left: 0.5em;" @click="copy_"><i class="far fa-copy"></i></button>
	</div>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import * as os from '@/os';

export default defineComponent({
	props: {
		copy: {
			type: String,
			required: false,
			default: null,
		},
		oneline: {
			type: Boolean,
			required: false,
			default: false,
		},
	},

	setup(props) {
		const copy_ = () => {
			copyToClipboard(props.copy);
			os.success();
		};

		return {
			copy_
		};
	},
});
</script>

<style lang="scss" scoped>
.alqyeyti {
	> .key, > .value {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	> .key {
		font-size: 0.85em;
		padding: 0 0 0.25em 0;
		opacity: 0.75;
	}

	&.oneline {
		display: flex;

		> .key {
			width: 30%;
			font-size: 1em;
			padding: 0 8px 0 0;
		}

		> .value {
			width: 70%;
		}
	}
}
</style>