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

21 lines
743 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" />
2023-05-27 17:36:15 +02:00
<div mt-5 flex>
<n-statistic label="Character count" :value="text.length" flex-1 />
<n-statistic label="Word count" :value="text === '' ? 0 : text.split(/\s+/).length" flex-1 />
<n-statistic label="Line count" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" flex-1 />
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" flex-1 />
</div>
</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>