it-tools/src/tools/text-statistics/text-statistics.vue

21 lines
741 B
Vue
Raw Normal View History

2022-04-14 01:06:06 +02:00
<template>
<c-card>
2022-04-22 23:31:40 +02:00
<n-input v-model:value="text" type="textarea" placeholder="Your text..." rows="5" />
<n-space justify="space-around" mt-5>
2022-04-22 23:31:40 +02:00
<n-statistic label="Character count" :value="text.length" />
<n-statistic label="Word count" :value="text === '' ? 0 : text.split(/\s+/).length" />
<n-statistic label="Line count" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" />
2022-04-22 23:31:40 +02:00
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" />
2022-04-14 01:06:06 +02:00
</n-space>
</c-card>
2022-04-14 01:06:06 +02:00
</template>
<script setup lang="ts">
2022-04-22 23:31:40 +02:00
import { formatBytes } from '@/utils/convert';
import { ref } from 'vue';
2022-04-22 23:31:40 +02:00
import { getStringSizeInBytes } from './text-statistics.service';
2022-04-14 01:06:06 +02:00
const text = ref('');
2022-04-14 01:06:06 +02:00
</script>