From 2e056fa3cf2ebd2ca083f421cab0c8bd71db5130 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Mon, 28 Aug 2023 15:02:43 +0200 Subject: [PATCH] docs(SelectMenu): add slots examples Resolves #557 --- .../examples/SelectMenuExampleCreatable.vue | 100 +++++++++ .../SelectMenuExampleOptionEmptySlot.vue | 13 ++ .../examples/SelectMenuExampleOptionSlot.vue | 30 +++ docs/content/3.forms/4.select-menu.md | 199 +++++++++++++++++- 4 files changed, 331 insertions(+), 11 deletions(-) create mode 100644 docs/components/content/examples/SelectMenuExampleCreatable.vue create mode 100644 docs/components/content/examples/SelectMenuExampleOptionEmptySlot.vue create mode 100644 docs/components/content/examples/SelectMenuExampleOptionSlot.vue diff --git a/docs/components/content/examples/SelectMenuExampleCreatable.vue b/docs/components/content/examples/SelectMenuExampleCreatable.vue new file mode 100644 index 00000000..6d810799 --- /dev/null +++ b/docs/components/content/examples/SelectMenuExampleCreatable.vue @@ -0,0 +1,100 @@ + + + diff --git a/docs/components/content/examples/SelectMenuExampleOptionEmptySlot.vue b/docs/components/content/examples/SelectMenuExampleOptionEmptySlot.vue new file mode 100644 index 00000000..999580ce --- /dev/null +++ b/docs/components/content/examples/SelectMenuExampleOptionEmptySlot.vue @@ -0,0 +1,13 @@ + + + diff --git a/docs/components/content/examples/SelectMenuExampleOptionSlot.vue b/docs/components/content/examples/SelectMenuExampleOptionSlot.vue new file mode 100644 index 00000000..71deeb36 --- /dev/null +++ b/docs/components/content/examples/SelectMenuExampleOptionSlot.vue @@ -0,0 +1,30 @@ + + + diff --git a/docs/content/3.forms/4.select-menu.md b/docs/content/3.forms/4.select-menu.md index 7cf21234..b44ea6e4 100644 --- a/docs/content/3.forms/4.select-menu.md +++ b/docs/content/3.forms/4.select-menu.md @@ -11,13 +11,13 @@ links: ## Usage -The SelectMenu component renders by default a [Select](/forms/select) component and is based on the `ui.select` preset. You can use most of the Select props to configure the display if you don't want to override the default slot such as [color](/forms/select#style), [variant](/forms/select#style), [size](/forms/select#size), [placeholder](/forms/select#placeholder), [icon](/forms/select#icon), [disabled](/forms/select#disabled), etc. +The `SelectMenu` component renders by default a [Select](/forms/select) component and is based on the `ui.select` preset. You can use most of the `Select` props to configure the display if you don't want to override the default slot such as [color](/forms/select#style), [variant](/forms/select#style), [size](/forms/select#size), [placeholder](/forms/select#placeholder), [icon](/forms/select#icon), [disabled](/forms/select#disabled), etc. -Like the Select component, you can use the `options` prop to pass an array of strings or objects. +Like the `Select` component, you can use the `options` prop to pass an array of strings or objects. ::component-example #default -:select-menu-example-basic{class="w-full lg:w-48"} +:select-menu-example-basic{class="w-full lg:w-40"} #code ```vue @@ -39,7 +39,7 @@ You can use the `multiple` prop to select multiple values. ::component-example #default -:select-menu-example-multiple{class="w-full lg:w-48"} +:select-menu-example-multiple{class="w-full lg:w-40"} #code ```vue @@ -61,7 +61,7 @@ You can pass an array of objects to `options` and either compare on the whole ob ::component-example #default -:select-menu-example-objects{class="w-full lg:w-48"} +:select-menu-example-objects{class="w-full lg:w-40"} #code ```vue + + +``` +:: + ## Slots ### `label` @@ -235,7 +335,7 @@ You can override the `#label` slot and handle the display yourself. ::component-example #default -:select-menu-example-multiple-slot{class="w-full lg:w-48"} +:select-menu-example-multiple-slot{class="w-full lg:w-40"} #code ```vue @@ -262,7 +362,7 @@ You can also override the `#default` slot entirely. ::component-example #default -:select-menu-example-button{class="w-full lg:w-48"} +:select-menu-example-button{class="w-full lg:w-40"} #code ```vue @@ -284,6 +384,83 @@ const selected = ref(people[3]) ``` :: +### `option` + +Use the `#option` slot to customize the option content. You will have access to the `option`, `active` and `selected` properties in the slot scope. + +::component-example +#default +:select-menu-example-option-slot{class="w-full lg:w-40"} + +#code +```vue + + + +``` +:: + +### `option-empty` + +Use the `#option-empty` slot to customize the content displayed when the `searchable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope. + +::component-example +#default +:select-menu-example-option-empty-slot{class="w-full lg:w-40"} + +#code +```vue + + + +``` +:: + +### `option-create` + +Use the `#option-create` slot to customize the content displayed when the `creatable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope. + +::callout{icon="i-heroicons-light-bulb"} +An example is available in the [Create option](#create-option) section. +:: + ## Props :component-props