2022-04-14 00:00:29 +02:00
|
|
|
<template>
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-card>
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-form-item label="Paragraphs" :show-feedback="false" label-width="200" label-placement="left">
|
|
|
|
<n-slider v-model:value="paragraphs" :step="1" :min="1" :max="20" />
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-form-item>
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-form-item label="Sentences per paragraph" :show-feedback="false" label-width="200" label-placement="left">
|
|
|
|
<n-slider v-model:value="sentences" range :step="1" :min="1" :max="50" />
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-form-item>
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-form-item label="Words per sentence" :show-feedback="false" label-width="200" label-placement="left">
|
|
|
|
<n-slider v-model:value="words" range :step="1" :min="1" :max="50" />
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-form-item>
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-form-item label="Start with lorem ipsum ?" :show-feedback="false" label-width="200" label-placement="left">
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-switch v-model:value="startWithLoremIpsum" />
|
|
|
|
</n-form-item>
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-form-item label="As html ?" :show-feedback="false" label-width="200" label-placement="left">
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-switch v-model:value="asHTML" />
|
|
|
|
</n-form-item>
|
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
<br />
|
2022-04-15 23:10:47 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-input :value="loremIpsumText" type="textarea" placeholder="Your lorem ipsum..." autosize readonly />
|
|
|
|
<br />
|
|
|
|
<br />
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-space justify="center">
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-button secondary autofocus @click="copy"> Copy </n-button>
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-space>
|
|
|
|
</n-card>
|
2022-04-14 00:00:29 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { useCopy } from '@/composable/copy';
|
2022-04-22 23:31:40 +02:00
|
|
|
import { ref, computed } from 'vue';
|
|
|
|
import { generateLoremIpsum } from './lorem-ipsum-generator.service';
|
|
|
|
import { randIntFromInterval } from '@/utils/random';
|
2022-04-14 00:00:29 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const paragraphs = ref(1);
|
|
|
|
const sentences = ref([3, 8]);
|
|
|
|
const words = ref([8, 15]);
|
|
|
|
const startWithLoremIpsum = ref(true);
|
|
|
|
const asHTML = ref(false);
|
2022-04-14 00:00:29 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const loremIpsumText = computed(() =>
|
|
|
|
generateLoremIpsum({
|
2022-04-14 00:00:29 +02:00
|
|
|
paragraphCount: paragraphs.value,
|
|
|
|
asHTML: asHTML.value,
|
|
|
|
sentencePerParagraph: randIntFromInterval(sentences.value[0], sentences.value[1]),
|
|
|
|
wordCount: randIntFromInterval(words.value[0], words.value[1]),
|
2022-04-22 23:31:40 +02:00
|
|
|
startWithLoremIpsum: startWithLoremIpsum.value,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to the clipboard' });
|
2022-04-14 00:00:29 +02:00
|
|
|
</script>
|