From 2fc938575d2e409ba9df9fb2ddb8d51d021a1756 Mon Sep 17 00:00:00 2001 From: Levy <56026608+Levy-from-Odessa@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:30:41 +0300 Subject: [PATCH] feat(FormGroup): add slots (#714) Co-authored-by: Romain Hamel Co-authored-by: Benjamin Canac Co-authored-by: saveliy --- .../examples/FormGroupErrorSlotExample.vue | 16 +++ docs/content/3.forms/9.form-group.md | 109 ++++++++++++++++++ src/runtime/components/forms/FormGroup.vue | 36 ++++-- 3 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 docs/components/content/examples/FormGroupErrorSlotExample.vue diff --git a/docs/components/content/examples/FormGroupErrorSlotExample.vue b/docs/components/content/examples/FormGroupErrorSlotExample.vue new file mode 100644 index 0000000000..d09826bf42 --- /dev/null +++ b/docs/components/content/examples/FormGroupErrorSlotExample.vue @@ -0,0 +1,16 @@ + + + diff --git a/docs/content/3.forms/9.form-group.md b/docs/content/3.forms/9.form-group.md index 8329a45ac3..15b02a821f 100644 --- a/docs/content/3.forms/9.form-group.md +++ b/docs/content/3.forms/9.form-group.md @@ -190,6 +190,115 @@ code: >- This will only work with form elements that support the `size` prop. :: +## Slots + +### `label` + +Use the `#label` slot to set the custom content for label. + +::component-card +--- +slots: + label: + default: +--- + +#label + :u-avatar{src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs" class="mr-2 inline-flex"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `description` + +Use the `#description` slot to set the custom content for description. + +::component-card +--- +slots: + description: Write only valid email address + default: +props: + label: 'Email' +--- + +#description + Write only valid email address :u-icon{name="i-heroicons-information-circle" class="align-middle"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `hint` + +Use the `#hint` slot to set the custom content for hint. + +::component-card +--- +slots: + hint: + default: +props: + label: 'Step 1' +--- + +#hint + :u-icon{name="i-heroicons-arrow-right-20-solid"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `help` + +Use the `#help` slot to set the custom content for help. + +::component-card +--- +slots: + help: Here are some examples + default: +props: + label: 'Email' +--- + +#help + Here are some examples :u-icon{name="i-heroicons-information-circle" class="align-middle"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `error` + +Use the `#error` slot to set the custom content for error. + +::component-example +#default +:form-group-error-slot-example{class="w-60"} + +#code +```vue + + + +``` +:: + ## Props :component-props diff --git a/src/runtime/components/forms/FormGroup.vue b/src/runtime/components/forms/FormGroup.vue index 09e87847f5..727d5c54ff 100644 --- a/src/runtime/components/forms/FormGroup.vue +++ b/src/runtime/components/forms/FormGroup.vue @@ -1,19 +1,37 @@