|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <div class="area" > |
| 4 | + <div class="absolute flex w-full h-full justify-center items-center"> |
| 5 | + <div class="w-[600px] max-w-[80vw] font-bold text-4xl z-10"> |
| 6 | + <h1 class="text-slate-50">TinyLD Playground</h1> |
| 7 | + <p class="text-sm font-normal mt-2 text-slate-300"> |
| 8 | + Tiny Language Detector, simply detect the language of a unicode UTF-8 text |
| 9 | + </p> |
| 10 | + <textarea |
| 11 | + rows="8" |
| 12 | + v-model="input" |
| 13 | + placeholder="Enter your text here" |
| 14 | + class="block w-full px-3 py-2 bg-white border border-slate-300 rounded-md text-sm shadow-sm placeholder-slate-400 |
| 15 | + focus:outline-none focus:border-sky-500 focus:ring-1 focus:ring-sky-500 font-normal mt-5"/> |
| 16 | + |
| 17 | + <div v-if="results && results.length > 0" class="font-normal bg-white border shadow-sm rounded-md mt-2 px-3 py-2 text-sm"> |
| 18 | + <ul class="list-item"> |
| 19 | + <li v-for="(result, index) in results" :key="result.lang" class="flex items-center pt-1"> |
| 20 | + <span style="width: 80px" class="px-2 font-semibold uppercase"> |
| 21 | + {{ result.lang }} |
| 22 | + </span> |
| 23 | + <div class="w-full bg-gray-100 rounded-full h-2.5 dark:bg-gray-700"> |
| 24 | + <div v-if="index === 0" class="bg-blue-400 h-2.5 rounded-full" :style="`width: ${Math.round(result.accuracy * 10000)/100 }%`"></div> |
| 25 | + <div v-else class="bg-yellow-200 h-2.5 rounded-full" :style="`width: ${Math.round(result.accuracy * 10000)/100 }%`"></div> |
| 26 | + </div> |
| 27 | + <span style="width: 80px" class="px-2"> |
| 28 | + {{ Math.round(result.accuracy * 10000)/100 }}% |
| 29 | + </span> |
| 30 | + </li> |
| 31 | + </ul> |
| 32 | + </div> |
| 33 | + |
| 34 | + <div class="flex gap-3 pt-4"> |
| 35 | + <a href="https://github.com/komodojp/tinyld" alt="Github" target="_blank" class="text-slate-200 hover:text-slate-50"> |
| 36 | + <v-icon label="github" :icon="{ prefix: 'fab', iconName: 'github' }" /> |
| 37 | + </a> |
| 38 | + <a href="https://github.com/komodojp/tinyld/blob/develop/docs/benchmark.md" alt="Benchmark" target="_blank" class="text-slate-200 hover:text-slate-50"> |
| 39 | + <v-icon label="benchmark" icon="chart-line" /> |
| 40 | + </a> |
| 41 | + <a href="https://github.com/komodojp/tinyld/blob/develop/docs/faq.md" alt="FAQ" target="_blank" class="text-slate-200 hover:text-slate-50"> |
| 42 | + <v-icon label="FAQ" :icon="{ prefix: 'far', iconName: 'circle-question' }" /> |
| 43 | + </a> |
| 44 | + <a href="#" alt="Share" class="text-slate-200 hover:text-slate-50" @click="copy()"> |
| 45 | + <v-icon label="Share" icon="share-from-square" /> |
| 46 | + <span v-if="copied" class="text-slate-50 pl-2 text-lg">Copied to clipboard !</span> |
| 47 | + </a> |
| 48 | + </div> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | + |
| 52 | + <ul class="circles"> |
| 53 | + <li></li> |
| 54 | + <li></li> |
| 55 | + <li></li> |
| 56 | + <li></li> |
| 57 | + <li></li> |
| 58 | + <li></li> |
| 59 | + <li></li> |
| 60 | + <li></li> |
| 61 | + <li></li> |
| 62 | + <li></li> |
| 63 | + </ul> |
| 64 | + </div > |
| 65 | + </div> |
| 66 | +</template> |
| 67 | + |
| 68 | +<script setup> |
| 69 | +import { ref, computed } from 'vue' |
| 70 | +import { detectAll } from 'tinyld' |
| 71 | +import { useClipboard } from '@vueuse/core' |
| 72 | +
|
| 73 | +const input = ref('') |
| 74 | +const results = computed(() => { |
| 75 | + return detectAll(input.value) |
| 76 | +}) |
| 77 | +const link = computed(() => { |
| 78 | + return `https://tinyld.vercel.app/?text=${encodeURIComponent(input.value)}` |
| 79 | +}) |
| 80 | +
|
| 81 | +const clipboard = useClipboard({ source: link }) |
| 82 | +
|
| 83 | +const copied = ref(false) |
| 84 | +const copy = () => { |
| 85 | + clipboard.copy() |
| 86 | + copied.value = true |
| 87 | + setTimeout(() => { |
| 88 | + copied.value = false |
| 89 | + }, 2000) |
| 90 | +} |
| 91 | +</script> |
| 92 | + |
| 93 | +<style scoped> |
| 94 | +.area{ |
| 95 | + background: #4e54c8; |
| 96 | + background: -webkit-linear-gradient(to left, #8f94fb, #4e54c8); |
| 97 | + width: 100%; |
| 98 | + height:100vh; |
| 99 | +} |
| 100 | +
|
| 101 | +.circles{ |
| 102 | + position: absolute; |
| 103 | + top: 0; |
| 104 | + left: 0; |
| 105 | + width: 100%; |
| 106 | + height: 100%; |
| 107 | + overflow: hidden; |
| 108 | +} |
| 109 | +
|
| 110 | +.circles li{ |
| 111 | + position: absolute; |
| 112 | + display: block; |
| 113 | + list-style: none; |
| 114 | + width: 20px; |
| 115 | + height: 20px; |
| 116 | + background: rgba(255, 255, 255, 0.2); |
| 117 | + animation: animate 25s linear infinite; |
| 118 | + bottom: -150px; |
| 119 | +
|
| 120 | +} |
| 121 | +
|
| 122 | +.circles li:nth-child(1){ |
| 123 | + left: 25%; |
| 124 | + width: 80px; |
| 125 | + height: 80px; |
| 126 | + animation-delay: 0s; |
| 127 | +} |
| 128 | +
|
| 129 | +
|
| 130 | +.circles li:nth-child(2){ |
| 131 | + left: 10%; |
| 132 | + width: 20px; |
| 133 | + height: 20px; |
| 134 | + animation-delay: 2s; |
| 135 | + animation-duration: 12s; |
| 136 | +} |
| 137 | +
|
| 138 | +.circles li:nth-child(3){ |
| 139 | + left: 70%; |
| 140 | + width: 20px; |
| 141 | + height: 20px; |
| 142 | + animation-delay: 4s; |
| 143 | +} |
| 144 | +
|
| 145 | +.circles li:nth-child(4){ |
| 146 | + left: 40%; |
| 147 | + width: 60px; |
| 148 | + height: 60px; |
| 149 | + animation-delay: 0s; |
| 150 | + animation-duration: 18s; |
| 151 | +} |
| 152 | +
|
| 153 | +.circles li:nth-child(5){ |
| 154 | + left: 65%; |
| 155 | + width: 20px; |
| 156 | + height: 20px; |
| 157 | + animation-delay: 0s; |
| 158 | +} |
| 159 | +
|
| 160 | +.circles li:nth-child(6){ |
| 161 | + left: 75%; |
| 162 | + width: 110px; |
| 163 | + height: 110px; |
| 164 | + animation-delay: 3s; |
| 165 | +} |
| 166 | +
|
| 167 | +.circles li:nth-child(7){ |
| 168 | + left: 35%; |
| 169 | + width: 150px; |
| 170 | + height: 150px; |
| 171 | + animation-delay: 7s; |
| 172 | +} |
| 173 | +
|
| 174 | +.circles li:nth-child(8){ |
| 175 | + left: 50%; |
| 176 | + width: 25px; |
| 177 | + height: 25px; |
| 178 | + animation-delay: 15s; |
| 179 | + animation-duration: 45s; |
| 180 | +} |
| 181 | +
|
| 182 | +.circles li:nth-child(9){ |
| 183 | + left: 20%; |
| 184 | + width: 15px; |
| 185 | + height: 15px; |
| 186 | + animation-delay: 2s; |
| 187 | + animation-duration: 35s; |
| 188 | +} |
| 189 | +
|
| 190 | +.circles li:nth-child(10){ |
| 191 | + left: 85%; |
| 192 | + width: 150px; |
| 193 | + height: 150px; |
| 194 | + animation-delay: 0s; |
| 195 | + animation-duration: 11s; |
| 196 | +} |
| 197 | +
|
| 198 | +@keyframes animate { |
| 199 | + 0%{ |
| 200 | + transform: translateY(0) rotate(0deg); |
| 201 | + opacity: 1; |
| 202 | + border-radius: 0; |
| 203 | + } |
| 204 | + 100%{ |
| 205 | + transform: translateY(-1000px) rotate(720deg); |
| 206 | + opacity: 0; |
| 207 | + border-radius: 50%; |
| 208 | + } |
| 209 | +} |
| 210 | +</style> |
0 commit comments