-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup> | ||
const input = ref('I love NuxtUI!') | ||
const badgeColor = (remaining)=>{ | ||
Check failure on line 4 in docs/components/content/examples/TextareaExampleSlotCounter.vue GitHub Actions / ci (ubuntu-latest, 18)
|
||
switch (true) { | ||
case remaining < 5: return 'red'; | ||
Check failure on line 6 in docs/components/content/examples/TextareaExampleSlotCounter.vue GitHub Actions / ci (ubuntu-latest, 18)
|
||
case remaining < 10: return 'amber'; | ||
Check failure on line 7 in docs/components/content/examples/TextareaExampleSlotCounter.vue GitHub Actions / ci (ubuntu-latest, 18)
|
||
case remaining < 15: return 'orange'; | ||
Check failure on line 8 in docs/components/content/examples/TextareaExampleSlotCounter.vue GitHub Actions / ci (ubuntu-latest, 18)
|
||
default: return 'green'; | ||
Check failure on line 9 in docs/components/content/examples/TextareaExampleSlotCounter.vue GitHub Actions / ci (ubuntu-latest, 18)
|
||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<UTextarea v-model="input" :counter="15"> | ||
<template #counter="{focused, letterCount, maxValue}"> | ||
<UBadge :color="badgeColor(maxValue - letterCount)"> | ||
{{ maxValue - letterCount }} Characters remaining! | ||
|
||
<UIcon class="ml-1" v-if="focused" name="i-heroicons-eye" /> | ||
</UBadge> | ||
</template> | ||
</UTextarea> | ||
</template> |