fix show character limit not working (#386)

* fix  show character limit not working

* Improve code for char limit issue

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka 2024-04-22 15:42:38 +01:00 committed by GitHub
parent 053a4a4976
commit e70d0955d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 39 additions and 12 deletions

View File

@ -22,6 +22,13 @@
:maxlength="maxCharLimit" :maxlength="maxCharLimit"
/> />
<template
v-if="$slots.help"
#help
>
<slot name="help" />
</template>
<template <template
v-if="maxCharLimit && showCharLimit" v-if="maxCharLimit && showCharLimit"
#bottom_after_help #bottom_after_help
@ -31,7 +38,10 @@
</small> </small>
</template> </template>
<template #error> <template
v-if="$slots.error"
#error
>
<slot name="error" /> <slot name="error" />
</template> </template>
</input-wrapper> </input-wrapper>

View File

@ -29,7 +29,10 @@
@keydown.enter.prevent="onEnterPress" @keydown.enter.prevent="onEnterPress"
> >
<template #help> <template
v-if="$slots.help"
#help
>
<slot name="help" /> <slot name="help" />
</template> </template>
@ -42,7 +45,10 @@
</small> </small>
</template> </template>
<template #error> <template
v-if="$slots.error"
#error
>
<slot name="error" /> <slot name="error" />
</template> </template>
</input-wrapper> </input-wrapper>

View File

@ -1,5 +1,8 @@
<template> <template>
<div class="flex mb-1 input-help"> <div
v-if="shouldRender"
class="flex mb-1 input-help"
>
<small <small
:class="helpClasses" :class="helpClasses"
class="grow flex" class="grow flex"
@ -19,8 +22,13 @@
</template> </template>
<script setup> <script setup>
defineProps({ const slots = useSlots()
const props = defineProps({
helpClasses: { type: String, default: "text-gray-400 dark:text-gray-500" }, helpClasses: { type: String, default: "text-gray-400 dark:text-gray-500" },
help: { type: String, required: false }, help: { type: String, required: false },
}) })
const shouldRender = computed(() => {
return props.help || !!slots.help || !!slots['after-help']
})
</script> </script>

View File

@ -18,10 +18,13 @@
name="help" name="help"
> >
<InputHelp <InputHelp
v-if="help"
:help="help" :help="help"
:help-classes="theme.default.help" :help-classes="theme.default.help"
/> >
<template #after-help>
<slot name="bottom_after_help" />
</template>
</InputHelp>
</slot> </slot>
<slot /> <slot />
@ -30,7 +33,6 @@
name="help" name="help"
> >
<InputHelp <InputHelp
v-if="help"
:help="help" :help="help"
:help-classes="theme.default.help" :help-classes="theme.default.help"
> >

View File

@ -16,6 +16,7 @@ export const inputProps = {
placeholder: { type: String, default: null }, placeholder: { type: String, default: null },
uppercaseLabels: { type: Boolean, default: false }, uppercaseLabels: { type: Boolean, default: false },
hideFieldName: { type: Boolean, default: false }, hideFieldName: { type: Boolean, default: false },
showCharLimit: { type: Boolean, default: false },
help: { type: String, default: null }, help: { type: String, default: null },
helpPosition: { type: String, default: "below_input" }, helpPosition: { type: String, default: "below_input" },
color: { type: String, default: "#3B82F6" }, color: { type: String, default: "#3B82F6" },

View File

@ -1,11 +1,11 @@
// https://nuxt.com/docs/api/configuration/nuxt-config // https://nuxt.com/docs/api/configuration/nuxt-config
import runtimeConfig from "./runtimeConfig"; import runtimeConfig from "./runtimeConfig"
import {sentryVitePlugin} from "@sentry/vite-plugin"; import {sentryVitePlugin} from "@sentry/vite-plugin"
import sitemap from "./sitemap"; import sitemap from "./sitemap"
export default defineNuxtConfig({ export default defineNuxtConfig({
loglevel: process.env.NUXT_LOG_LEVEL || 'info', loglevel: process.env.NUXT_LOG_LEVEL || 'info',
devtools: {enabled: true}, devtools: {enabled: false},
css: ['~/scss/app.scss'], css: ['~/scss/app.scss'],
modules: [ modules: [
'@pinia/nuxt', '@pinia/nuxt',