From 60bfa7f49cfc4a69c213e80f908e71ae19ed3bd8 Mon Sep 17 00:00:00 2001 From: "David W. Gray" Date: Fri, 3 Jan 2025 17:18:10 -0800 Subject: [PATCH] docs(BFormGroup): Refactor examples into separate files (#2491) --- .../demo/FormGroupFloatingLabels.vue | 34 ++ .../demo/FormGroupHorizontalLayout.vue | 16 + .../src/docs/components/demo/FormGroupId.vue | 7 + .../components/demo/FormGroupLabelSize.vue | 33 ++ .../docs/components/demo/FormGroupNested.vue | 34 ++ .../components/demo/FormGroupOverview.vue | 28 ++ .../docs/components/demo/FormGroupState.vue | 13 + apps/docs/src/docs/components/form-group.md | 343 +----------------- 8 files changed, 183 insertions(+), 325 deletions(-) create mode 100644 apps/docs/src/docs/components/demo/FormGroupFloatingLabels.vue create mode 100644 apps/docs/src/docs/components/demo/FormGroupHorizontalLayout.vue create mode 100644 apps/docs/src/docs/components/demo/FormGroupId.vue create mode 100644 apps/docs/src/docs/components/demo/FormGroupLabelSize.vue create mode 100644 apps/docs/src/docs/components/demo/FormGroupNested.vue create mode 100644 apps/docs/src/docs/components/demo/FormGroupOverview.vue create mode 100644 apps/docs/src/docs/components/demo/FormGroupState.vue diff --git a/apps/docs/src/docs/components/demo/FormGroupFloatingLabels.vue b/apps/docs/src/docs/components/demo/FormGroupFloatingLabels.vue new file mode 100644 index 000000000..c01d6d461 --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupFloatingLabels.vue @@ -0,0 +1,34 @@ + + + diff --git a/apps/docs/src/docs/components/demo/FormGroupHorizontalLayout.vue b/apps/docs/src/docs/components/demo/FormGroupHorizontalLayout.vue new file mode 100644 index 000000000..4e6b8fab1 --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupHorizontalLayout.vue @@ -0,0 +1,16 @@ + diff --git a/apps/docs/src/docs/components/demo/FormGroupId.vue b/apps/docs/src/docs/components/demo/FormGroupId.vue new file mode 100644 index 000000000..0541b96e8 --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupId.vue @@ -0,0 +1,7 @@ + diff --git a/apps/docs/src/docs/components/demo/FormGroupLabelSize.vue b/apps/docs/src/docs/components/demo/FormGroupLabelSize.vue new file mode 100644 index 000000000..884505033 --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupLabelSize.vue @@ -0,0 +1,33 @@ + diff --git a/apps/docs/src/docs/components/demo/FormGroupNested.vue b/apps/docs/src/docs/components/demo/FormGroupNested.vue new file mode 100644 index 000000000..9ef3ef406 --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupNested.vue @@ -0,0 +1,34 @@ + diff --git a/apps/docs/src/docs/components/demo/FormGroupOverview.vue b/apps/docs/src/docs/components/demo/FormGroupOverview.vue new file mode 100644 index 000000000..4668fa592 --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupOverview.vue @@ -0,0 +1,28 @@ + + + diff --git a/apps/docs/src/docs/components/demo/FormGroupState.vue b/apps/docs/src/docs/components/demo/FormGroupState.vue new file mode 100644 index 000000000..96817b47e --- /dev/null +++ b/apps/docs/src/docs/components/demo/FormGroupState.vue @@ -0,0 +1,13 @@ + diff --git a/apps/docs/src/docs/components/form-group.md b/apps/docs/src/docs/components/form-group.md index 405872f2f..83b37b3dd 100644 --- a/apps/docs/src/docs/components/form-group.md +++ b/apps/docs/src/docs/components/form-group.md @@ -6,49 +6,7 @@ The `BFormGroup` component is the easiest way to add some structure to forms. It - - - - - - +<<< DEMO ./demo/FormGroupOverview.vue ## Label @@ -76,25 +34,7 @@ of strings. The `BFormGroup` component automatically inherits the id of its child input components, such as BFormInput and BFormTextarea. This functionality ensures that the label element's for attribute is correctly set to match the id of the input component, providing proper association between the label and the input field. - - - - - - - +<<< DEMO ./demo/FormGroupId.vue#template{vue-html} ### Horizontal layout @@ -113,7 +53,7 @@ occupy in the row via the `content-cols` and `content-cols-{breakpoint}` props. When using both, the `label-cols` and `content-cols` props, make sure that the total amount of columns does not exceed `12`. -See the [Layout and Grid System](/docs/components/layout#how-it-works) docs for further information. +See the [Grid System](/docs/components/grid-system#how-it-works) docs for further information. | Prop | Description | | ----------------- | --------------------------------- | @@ -128,38 +68,7 @@ See the [Layout and Grid System](/docs/components/layout#how-it-works) docs for | `content-cols-lg` | Applies to breakpoint `lg` and up | | `content-cols-xl` | Applies to breakpoint `xl` and up | - - - - - - +<<< DEMO ./demo/FormGroupHorizontalLayout.vue#template{vue-html} You can also set the label cols to `'auto'`. @@ -169,34 +78,7 @@ You can control the label text size match the size of your form input(s) via the `label-size` prop. Values can be `'sm'` or `'lg'` for small or large label, respectively. Sizes work for both horizontal and non-horizontal form groups. - - - - - - - - - - - - +<<< DEMO ./demo/FormGroupLabelSize.vue#template{vue-html} ### Label text alignment @@ -218,114 +100,7 @@ Alignment has no effect if the `label-visually-hidden` prop is set. Feel free to nest `BFormGroup` components to produce advanced form layouts and semantic grouping of related form controls: - - - - - - - - - - - - - - - - - - - - - - +<<< DEMO ./demo/FormGroupNested.vue#template{vue-html} ## Disabled form group @@ -368,33 +143,7 @@ assistive technologies when setting a contextual `invalid` state. For some elements the child input element will automatically receive the state of the form group. `:state="false"` on the `BFormGroup` will automatically give the appropriate class to the input element. Explicit sets of the `state` prop to the child element will override this. - - - - - - - - - - - - - +<<< DEMO ./demo/FormGroupState.vue#template{vue-html} ### Invalid feedback @@ -420,12 +169,14 @@ the feedback so that it shows as a static tooltip when visible, by setting the p ### Feedback limitations -**Note:** When using `BInputGroup`, `BFormFile`, `BFormRadioGroup`, `BFormRadio`, +::: Info NOTE +When using `BInputGroup`, `BFormFile`, `BFormRadioGroup`, `BFormRadio`, `BFormCheckboxGroup` or `BFormCheckbox` inside a `BFormGroup`, setting an invalid (or valid) `state` on the `input` alone will **not** trigger the invalid (or valid) feedback to show (due to limitations with the Bootstrap 5 validation CSS). To get around this, **you must also** set the invalid/valid `state` on `BFormGroup`. Native browser validation will **not** trigger the invalid feedback to show when using one of the above-mentioned form controls. +::: ## Floating labels @@ -435,55 +186,7 @@ You can make a floating label by setting the property `floating` to true and spe ### Example - - - - - - +<<< DEMO ./demo/FormGroupFloatingLabels.vue ### Restrictions @@ -522,22 +225,12 @@ scoped `default` slot. -