|
| 1 | +<script setup lang="ts"> |
| 2 | +import { useCopy } from '@/composable/copy'; |
| 3 | +import { useQueryParamOrStorage } from '@/composable/queryParams'; |
| 4 | +import { lunicode } from '@/utils/lunicode'; |
| 5 | +
|
| 6 | +const textInput = ref(''); |
| 7 | +const intensity = useQueryParamOrStorage({ name: 'intensity', storageName: 'zalgo:i', defaultValue: 8 }); |
| 8 | +watch(intensity, () => { |
| 9 | + if (textInput.value) { |
| 10 | + doZalgo(); |
| 11 | + } |
| 12 | +}); |
| 13 | +const zalgoOutput = ref(''); |
| 14 | +function doZalgo() { |
| 15 | + lunicode.tools.creepify.options.maxHeight = intensity.value; |
| 16 | + zalgoOutput.value = lunicode.tools.creepify.encode(textInput.value); |
| 17 | +} |
| 18 | +const { copy: copyZalgoOutput } = useCopy({ source: zalgoOutput, text: 'Zalgo text copied!' }); |
| 19 | +
|
| 20 | +const zalgoInput = ref(''); |
| 21 | +const textOutput = ref(''); |
| 22 | +function unZalgo() { |
| 23 | + textOutput.value = lunicode.tools.creepify.decode(zalgoInput.value); |
| 24 | +} |
| 25 | +</script> |
| 26 | + |
| 27 | +<template> |
| 28 | + <c-card title="Zalgo Text Generation"> |
| 29 | + <c-input-text |
| 30 | + v-model:value="textInput" |
| 31 | + multiline |
| 32 | + placeholder="Put your string here..." |
| 33 | + rows="5" |
| 34 | + label="Text to decorate with Zalgo" |
| 35 | + raw-text |
| 36 | + mb-2 |
| 37 | + /> |
| 38 | + |
| 39 | + <n-form-item label="Intensity:" label-placement="left" mb-3> |
| 40 | + <NSlider v-model:value="intensity" :min="1" :max="300" :step="1" /> |
| 41 | + </n-form-item> |
| 42 | + |
| 43 | + <n-space justify="center" mb-2> |
| 44 | + <n-button |
| 45 | + type="primary" |
| 46 | + @click="doZalgo" |
| 47 | + > |
| 48 | + Generate |
| 49 | + </n-button> |
| 50 | + </n-space> |
| 51 | + |
| 52 | + <div v-if="zalgoOutput"> |
| 53 | + <n-card title="Zalgo text" mb-2> |
| 54 | + <div :style="{ lineHeight: intensity / 3, textAlign: 'center' }"> |
| 55 | + {{ zalgoOutput }} |
| 56 | + </div> |
| 57 | + </n-card> |
| 58 | + |
| 59 | + <div flex justify-center> |
| 60 | + <c-button @click="copyZalgoOutput()"> |
| 61 | + Copy |
| 62 | + </c-button> |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + </c-card> |
| 66 | + |
| 67 | + <c-card title="Zalgo cleaner"> |
| 68 | + <c-input-text |
| 69 | + v-model:value="zalgoInput" |
| 70 | + multiline |
| 71 | + placeholder="Put zalgo text to clean here..." |
| 72 | + rows="5" |
| 73 | + label="Zalgo text to clean" |
| 74 | + mb-5 |
| 75 | + /> |
| 76 | + |
| 77 | + <n-space justify="center" mb-2> |
| 78 | + <n-button |
| 79 | + type="primary" |
| 80 | + @click="unZalgo" |
| 81 | + > |
| 82 | + Clean |
| 83 | + </n-button> |
| 84 | + </n-space> |
| 85 | + |
| 86 | + <TextareaCopyable |
| 87 | + v-if="textOutput" |
| 88 | + v-model:value="textOutput" |
| 89 | + label="Cleaned text" |
| 90 | + placeholder="Clean zalgo text will appear here..." |
| 91 | + mb-5 |
| 92 | + /> |
| 93 | + </c-card> |
| 94 | +</template> |
0 commit comments