it-tools/src/tools/roman-numeral-converter/roman-numeral-converter.vue

45 lines
1.4 KiB
Vue
Raw Normal View History

<template>
2022-04-15 23:10:47 +02:00
<div>
<n-card title="Arabic to roman">
2022-04-22 23:31:40 +02:00
<n-space align="center" justify="space-between">
<n-input-number v-model:value="inputNumeral" :min="1" style="width: 200px" :show-button="false" />
2022-04-15 23:10:47 +02:00
<div class="result">
{{ outputRoman }}
</div>
2022-04-22 23:31:40 +02:00
<n-button secondary autofocus @click="copyRoman"> Copy </n-button>
2022-04-15 23:10:47 +02:00
</n-space>
</n-card>
2022-04-22 23:31:40 +02:00
<br />
2022-04-15 23:10:47 +02:00
<n-card title="Roman to arabic">
2022-04-22 23:31:40 +02:00
<n-space align="center" justify="space-between">
<n-input v-model:value="inputRoman" style="width: 200px" />
2022-04-15 23:10:47 +02:00
<div class="result">
{{ outputNumeral }}
</div>
2022-04-22 23:31:40 +02:00
<n-button secondary autofocus @click="copyArabic"> Copy </n-button>
2022-04-15 23:10:47 +02:00
</n-space>
</n-card>
</div>
</template>
<script setup lang="ts">
import { useCopy } from '@/composable/copy';
2022-04-22 23:31:40 +02:00
import { ref, computed } from 'vue';
import { arabicToRoman, romanToArabic } from './roman-numeral-converter.service';
2022-04-22 23:31:40 +02:00
const inputNumeral = ref(42);
const outputRoman = computed(() => arabicToRoman(inputNumeral.value));
2022-04-22 23:31:40 +02:00
const inputRoman = ref('IVX');
const outputNumeral = computed(() => romanToArabic(inputRoman.value));
2022-04-22 23:31:40 +02:00
const { copy: copyRoman } = useCopy({ source: outputRoman, text: 'Roman number copied to the clipboard' });
const { copy: copyArabic } = useCopy({ source: outputNumeral, text: 'Arabic number copied to the clipboard' });
</script>
<style lang="less" scoped>
.result {
2022-04-22 23:31:40 +02:00
font-size: 22px;
}
2022-04-22 23:31:40 +02:00
</style>