mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
fix form cosmetics
This commit is contained in:
parent
56b3190293
commit
77e3ac3ea0
4 changed files with 14 additions and 4 deletions
|
@ -5,12 +5,14 @@ import * as yup from 'yup'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
schema: yup.ObjectShape
|
schema: yup.ObjectShape
|
||||||
|
initialValues: Record<string, any>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits(['submit'])
|
const emit = defineEmits(['submit'])
|
||||||
|
|
||||||
const { handleSubmit } = useForm({
|
const { handleSubmit } = useForm({
|
||||||
validationSchema: toTypedSchema(yup.object(props.schema)),
|
validationSchema: toTypedSchema(yup.object(props.schema)),
|
||||||
|
initialValues: props.initialValues,
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSubmit = handleSubmit((values) => {
|
const onSubmit = handleSubmit((values) => {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const props = defineProps<{
|
||||||
label: string
|
label: string
|
||||||
icon?: string
|
icon?: string
|
||||||
description?: string
|
description?: string
|
||||||
|
row?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { errorMessage } = useField(() => props.name)
|
const { errorMessage } = useField(() => props.name)
|
||||||
|
@ -33,11 +34,11 @@ provide(formGroupExtras, {
|
||||||
<div
|
<div
|
||||||
role="group"
|
role="group"
|
||||||
:aria-invalid="invalid"
|
:aria-invalid="invalid"
|
||||||
:class="{ 'is-invalid': invalid }"
|
:class="{ 'is-invalid': invalid, 'flex-col': !row }"
|
||||||
class="flex"
|
class="flex"
|
||||||
>
|
>
|
||||||
<slot name="label">
|
<slot name="label">
|
||||||
<label :id="name + '__label'" :for="name" class="block">
|
<label :id="name + '__label'" :for="name" class="block ml-1 mb-2">
|
||||||
<Icon
|
<Icon
|
||||||
v-if="icon"
|
v-if="icon"
|
||||||
:name="icon"
|
:name="icon"
|
||||||
|
|
|
@ -5,6 +5,8 @@ const props = withDefaults(
|
||||||
text?: string
|
text?: string
|
||||||
variant?: string
|
variant?: string
|
||||||
icon?: string
|
icon?: string
|
||||||
|
iconSize: string
|
||||||
|
iconOnly: boolean
|
||||||
block?: boolean
|
block?: boolean
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
|
@ -12,6 +14,8 @@ const props = withDefaults(
|
||||||
text: undefined,
|
text: undefined,
|
||||||
variant: 'primary',
|
variant: 'primary',
|
||||||
icon: undefined,
|
icon: undefined,
|
||||||
|
iconSize: '1.5em',
|
||||||
|
iconOnly: false,
|
||||||
block: false,
|
block: false,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -21,6 +25,7 @@ const variantClass = computed(() => {
|
||||||
primary: 'btn-primary',
|
primary: 'btn-primary',
|
||||||
success: 'btn-success',
|
success: 'btn-success',
|
||||||
info: 'btn-info',
|
info: 'btn-info',
|
||||||
|
error: 'btn-error',
|
||||||
}[props.variant]
|
}[props.variant]
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -28,8 +33,8 @@ const variantClass = computed(() => {
|
||||||
<template>
|
<template>
|
||||||
<button class="btn" :class="[variantClass, { 'btn-block': block }]">
|
<button class="btn" :class="[variantClass, { 'btn-block': block }]">
|
||||||
<slot name="default">
|
<slot name="default">
|
||||||
<Icon v-if="icon" :name="icon" size="1.5em" aria-hidden="true" />
|
<Icon v-if="icon" :name="icon" :size="iconSize" aria-hidden="true" />
|
||||||
{{ text }}
|
<span :class="{ 'sr-only': iconOnly }">{{ text }}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -46,6 +46,7 @@ const schema = {
|
||||||
:label="t('username')"
|
:label="t('username')"
|
||||||
icon="mdi:account-circle"
|
icon="mdi:account-circle"
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
|
row
|
||||||
>
|
>
|
||||||
<TextInput name="username" type="text" :placeholder="t('username')" />
|
<TextInput name="username" type="text" :placeholder="t('username')" />
|
||||||
</FormField>
|
</FormField>
|
||||||
|
@ -55,6 +56,7 @@ const schema = {
|
||||||
:label="t('password')"
|
:label="t('password')"
|
||||||
icon="mdi:lock"
|
icon="mdi:lock"
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
|
row
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
name="password"
|
name="password"
|
||||||
|
|
Loading…
Add table
Reference in a new issue