it-tools/src/tools/text-statistics/text-statistics.vue
steffenrapp 917ff521ea more tools
2024-09-05 17:01:34 +00:00

20 lines
833 B
Vue

<script setup lang="ts">
import { getStringSizeInBytes } from './text-statistics.service';
import { formatBytes } from '@/utils/convert';
const text = ref('');
const { t } = useI18n();
</script>
<template>
<c-card>
<c-input-text v-model:value="text" multiline placeholder="Your text..." rows="5" />
<div mt-5 flex>
<n-statistic :label="t('tools.text-statistics.characters')" :value="text.length" flex-1 />
<n-statistic :label="t('tools.text-statistics.words')" :value="text === '' ? 0 : text.split(/\s+/).length" flex-1 />
<n-statistic :label="t('tools.text-statistics.lines')" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" flex-1 />
<n-statistic :label="t('tools.text-statistics.bytes')" :value="formatBytes(getStringSizeInBytes(text))" flex-1 />
</div>
</c-card>
</template>