Skip to content

Commit

Permalink
Merge pull request #37 from formsible/long/form-style
Browse files Browse the repository at this point in the history
refactor: improve error display and character count layout in text co…
  • Loading branch information
tewnut authored Jan 21, 2025
2 parents effb84c + a30f7cb commit 9e8b9e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/components/long_text/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ const maxLength = computed(() => {
:maxlength="maxLength"
fluid
/>
<div class="flex justify-end mt-1">
<span class="text-sm text-gray-500">
{{ charCount }}/{{ maxLength }}
</span>
</div>
</div>
<small
v-if="error"
:id="`${input.key}-help`"
class="text-sm mt-0.5 text-red-600"
>
{{ error }}
</small>
<div class="flex items-start justify-between space-x-1">
<small
v-if="error"
:id="`${input.key}-help`"
class="text-sm text-red-600"
>
{{ error }}
</small>
<span class="text-sm text-gray-500 ml-auto float-right">
{{ charCount }}/{{ maxLength }}
</span>
</div>
</div>
</template>
5 changes: 3 additions & 2 deletions src/components/short_text/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ const model = defineModel<string>({ default: '' })
const isRequired = computed(() =>
props.input.validations?.map((v) => v.rule).includes('required'),
)
const maxLength = computed(() => {
const v = props.input?.validations?.find(
(v: Validation) => v.rule == 'maxLength',
(v: Validation) => v.rule === 'maxLength',
)
return v?.params ? parseInt(v.params[0]) : 100
return v?.params ? parseInt(v.params[0]) : undefined
})
</script>

Expand Down
5 changes: 4 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@
"validations": [
{
"rule": "maxLength",
"params": [20]
"params": [255]
},
{
"rule": "required"
}
]
}
Expand Down

0 comments on commit 9e8b9e8

Please sign in to comment.