Skip to content
Snippets Groups Projects
key-value.vue 1011 B
Newer Older
syuilo's avatar
syuilo committed
<template>
syuilo's avatar
syuilo committed
<div class="alqyeyti" :class="{ oneline }">
syuilo's avatar
syuilo committed
	<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" setup>
import { } from 'vue';
syuilo's avatar
syuilo committed
import copyToClipboard from '@/scripts/copy-to-clipboard';
import * as os from '@/os';

const props = withDefaults(defineProps<{
	copy: string | null;
	oneline: boolean;
}>(), {
	copy: null,
	oneline: false,
syuilo's avatar
syuilo committed
});

const copy_ = () => {
	copyToClipboard(props.copy);
	os.success();
};
syuilo's avatar
syuilo committed
</script>

<style lang="scss" scoped>
.alqyeyti {
	> .key {
		font-size: 0.85em;
		padding: 0 0 0.25em 0;
		opacity: 0.75;
	}
syuilo's avatar
syuilo committed

	&.oneline {
		display: flex;

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

		> .value {
			width: 70%;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
syuilo's avatar
syuilo committed
		}
	}
syuilo's avatar
syuilo committed
}
</style>