Skip to content

Commit

Permalink
docs(BFormGroup): Refactor examples into separate files (bootstrap-vu…
Browse files Browse the repository at this point in the history
  • Loading branch information
dwgray authored Jan 4, 2025
1 parent fa06eda commit 60bfa7f
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 325 deletions.
34 changes: 34 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupFloatingLabels.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<BFormGroup
id="fieldset-4"
description="Let us know your name."
label="Name"
label-for="input-floating-4"
valid-feedback="Thank you!"
:invalid-feedback="floatingInvalidFeedback"
:state="floatingState"
floating
>
<BFormInput
id="input-floating-4"
v-model="floatingName"
:state="floatingState"
trim
placeholder="Enter your name please"
/>
</BFormGroup>
<div>
Name: <strong>{{ floatingName }}</strong>
</div>
</template>

<script setup lang="ts">
import {computed, ref} from 'vue'
const floatingName = ref('')
const floatingState = computed(() => floatingName.value.length >= 4)
const floatingInvalidFeedback = computed(() =>
floatingName.value.length > 0 ? 'Enter at least 4 characters.' : 'Please enter something.'
)
</script>
16 changes: 16 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupHorizontalLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<!-- #region template -->
<BFormGroup
id="fieldset-horizontal"
label-cols-sm="4"
label-cols-lg="3"
content-cols-sm
content-cols-lg="7"
description="Let us know your name."
label="Enter your name"
label-for="input-horizontal"
>
<BFormInput id="input-horizontal" />
</BFormGroup>
<!-- #endregion template -->
</template>
7 changes: 7 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupId.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<!-- #region template -->
<BFormGroup label="Enter your name">
<BFormInput id="input-id" />
</BFormGroup>
<!-- #endregion template -->
</template>
33 changes: 33 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupLabelSize.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<!-- #region template -->
<BFormGroup
label-cols="4"
label-cols-lg="2"
label-size="sm"
label="Small"
label-for="input-sm"
class="my-1"
>
<BFormInput id="input-sm" size="sm" />
</BFormGroup>
<BFormGroup
label-cols="4"
label-cols-lg="2"
label="Default"
label-for="input-default"
class="my-1"
>
<BFormInput id="input-default" />
</BFormGroup>
<BFormGroup
label-cols="4"
label-cols-lg="2"
label-size="lg"
label="Large"
label-for="input-lg"
class="my-1"
>
<BFormInput id="input-lg" size="lg" />
</BFormGroup>
<!-- #endregion template -->
</template>
34 changes: 34 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupNested.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<!-- #region template -->
<BCard bg-variant="light">
<BFormGroup
label-cols-lg="3"
label="Shipping Address"
label-size="lg"
label-class="fw-bold pt-0"
class="mb-0"
>
<BFormGroup label="Street:" label-for="nested-street" label-cols-sm="3" label-align-sm="end">
<BFormInput id="nested-street" />
</BFormGroup>
<BFormGroup label="City:" label-for="nested-city" label-cols-sm="3" label-align-sm="end">
<BFormInput id="nested-city" />
</BFormGroup>
<BFormGroup label="State:" label-for="nested-state" label-cols-sm="3" label-align-sm="end">
<BFormInput id="nested-state" />
</BFormGroup>
<BFormGroup
label="Country:"
label-for="nested-country"
label-cols-sm="3"
label-align-sm="end"
>
<BFormInput id="nested-country" />
</BFormGroup>
<BFormGroup label="Ship via:" label-cols-sm="3" label-align-sm="end" class="mb-0">
<BFormRadioGroup class="pt-2" :options="['Air', 'Courier', 'Mail']" />
</BFormGroup>
</BFormGroup>
</BCard>
<!-- #endregion template -->
</template>
28 changes: 28 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupOverview.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<BFormGroup
id="fieldset-1"
description="Let us know your name."
label="Enter your name"
label-for="input-1"
valid-feedback="Thank you!"
:invalid-feedback="invalidFeedback"
:state="state"
label-class="mb-1"
>
<BFormInput id="input-1" v-model="name" :state="state" trim />
</BFormGroup>
<div>
Name: <strong>{{ name }}</strong>
</div>
</template>

<script setup lang="ts">
import {computed, ref} from 'vue'
const name = ref('')
const state = computed(() => name.value.length >= 4)
const invalidFeedback = computed(() =>
name.value.length > 0 ? 'Enter at least 4 characters.' : 'Please enter something.'
)
</script>
13 changes: 13 additions & 0 deletions apps/docs/src/docs/components/demo/FormGroupState.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<!-- #region template -->
<BCard>
<BFormGroup :state="false" class="mb-2">
<BFormInput />
</BFormGroup>
<BFormGroup :state="false">
<!-- Use the state prop to override this behavior -->
<BFormInput :state="null" />
</BFormGroup>
</BCard>
<!-- #endregion template -->
</template>
Loading

0 comments on commit 60bfa7f

Please sign in to comment.