Skip to content

Commit 9e8b9e8

Browse files
authored
Merge pull request #37 from formsible/long/form-style
refactor: improve error display and character count layout in text co…
2 parents effb84c + a30f7cb commit 9e8b9e8

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

src/components/long_text/index.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ const maxLength = computed(() => {
4545
:maxlength="maxLength"
4646
fluid
4747
/>
48-
<div class="flex justify-end mt-1">
49-
<span class="text-sm text-gray-500">
50-
{{ charCount }}/{{ maxLength }}
51-
</span>
52-
</div>
5348
</div>
54-
<small
55-
v-if="error"
56-
:id="`${input.key}-help`"
57-
class="text-sm mt-0.5 text-red-600"
58-
>
59-
{{ error }}
60-
</small>
49+
<div class="flex items-start justify-between space-x-1">
50+
<small
51+
v-if="error"
52+
:id="`${input.key}-help`"
53+
class="text-sm text-red-600"
54+
>
55+
{{ error }}
56+
</small>
57+
<span class="text-sm text-gray-500 ml-auto float-right">
58+
{{ charCount }}/{{ maxLength }}
59+
</span>
60+
</div>
6161
</div>
6262
</template>

src/components/short_text/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ const model = defineModel<string>({ default: '' })
1414
const isRequired = computed(() =>
1515
props.input.validations?.map((v) => v.rule).includes('required'),
1616
)
17+
1718
const maxLength = computed(() => {
1819
const v = props.input?.validations?.find(
19-
(v: Validation) => v.rule == 'maxLength',
20+
(v: Validation) => v.rule === 'maxLength',
2021
)
21-
return v?.params ? parseInt(v.params[0]) : 100
22+
return v?.params ? parseInt(v.params[0]) : undefined
2223
})
2324
</script>
2425

src/manifest.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@
100100
"validations": [
101101
{
102102
"rule": "maxLength",
103-
"params": [20]
103+
"params": [255]
104+
},
105+
{
106+
"rule": "required"
104107
}
105108
]
106109
}

0 commit comments

Comments
 (0)