From bdaf2dbbd474c95c9761ba99c5af78f6c2f1adc7 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Mon, 22 May 2023 16:00:31 +0200 Subject: [PATCH] chore(CommandPalette): handle loading state (#221) --- docs/content/1.getting-started/3.theming.md | 1 + docs/content/2.elements/1.avatar.md | 2 +- docs/content/2.elements/3.button.md | 4 +- docs/content/3.forms/1.input.md | 4 +- docs/content/3.forms/3.select.md | 2 +- docs/content/3.forms/4.select-menu.md | 4 +- .../content/4.navigation/2.command-palette.md | 26 ++++++++++++- src/runtime/app.config.ts | 1 + .../components/navigation/CommandPalette.vue | 37 ++++++++++++++++++- 9 files changed, 71 insertions(+), 10 deletions(-) diff --git a/docs/content/1.getting-started/3.theming.md b/docs/content/1.getting-started/3.theming.md index 631140fe..8fd9c6c4 100644 --- a/docs/content/1.getting-started/3.theming.md +++ b/docs/content/1.getting-started/3.theming.md @@ -184,6 +184,7 @@ export default defineAppConfig({ commandPalette: { default: { icon: 'i-octicon-search-24', + loadingIcon: 'i-octicon-sync-24', selectedIcon: 'i-octicon-check-24', empty: { icon: 'i-octicon-search-24' diff --git a/docs/content/2.elements/1.avatar.md b/docs/content/2.elements/1.avatar.md index 820cd720..d237979d 100644 --- a/docs/content/2.elements/1.avatar.md +++ b/docs/content/2.elements/1.avatar.md @@ -29,7 +29,7 @@ baseProps: ### Chip -Use the `chipColor`, `chipVariant` and `chipPosition` props to display a chip on the Avatar. +Use the `chip-color`, `chip-variant` and `chip-position` props to display a chip on the Avatar. ::component-card --- diff --git a/docs/content/2.elements/3.button.md b/docs/content/2.elements/3.button.md index 6ab7011e..8d86cb33 100644 --- a/docs/content/2.elements/3.button.md +++ b/docs/content/2.elements/3.button.md @@ -113,7 +113,7 @@ Button Use any icon from [Iconify](https://icones.js.org) by setting the `icon` prop by using this pattern: `i-{collection_name}-{icon_name}`. -Use the `leading` and `trailing` props to set the icon position or the `leadingIcon` and `trailingIcon` props to set a different icon for each position. +Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position. ::component-card --- @@ -163,7 +163,7 @@ Button Use the `loading` prop to show a loading icon and disable the Button. -Use the `loadingIcon` prop to set a different icon or change it globally in `ui.button.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`. +Use the `loading-icon` prop to set a different icon or change it globally in `ui.button.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`. ::component-card --- diff --git a/docs/content/3.forms/1.input.md b/docs/content/3.forms/1.input.md index d3eb02ff..7d6121a3 100644 --- a/docs/content/3.forms/1.input.md +++ b/docs/content/3.forms/1.input.md @@ -56,7 +56,7 @@ props: Use any icon from [Iconify](https://icones.js.org) by setting the `icon` prop by using this pattern: `i-{collection_name}-{icon_name}`. -Use the `leading` and `trailing` props to set the icon position or the `leadingIcon` and `trailingIcon` props to set a different icon for each position. +Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position. ::component-card --- @@ -94,7 +94,7 @@ excludedProps: Use the `loading` prop to show a loading icon and disable the Input. -Use the `loadingIcon` prop to set a different icon or change it globally in `ui.input.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`. +Use the `loading-icon` prop to set a different icon or change it globally in `ui.input.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`. ::component-card --- diff --git a/docs/content/3.forms/3.select.md b/docs/content/3.forms/3.select.md index a166e563..e2c1faef 100644 --- a/docs/content/3.forms/3.select.md +++ b/docs/content/3.forms/3.select.md @@ -78,7 +78,7 @@ props: Use any icon from [Iconify](https://icones.js.org) by setting the `icon` prop by using this pattern: `i-{collection_name}-{icon_name}`. -Use the `trailingIcon` prop to set a different icon or change it globally in `ui.select.default.trailingIcon`. Defaults to `i-heroicons-chevron-down-20-solid`. +Use the `trailing-icon` prop to set a different icon or change it globally in `ui.select.default.trailingIcon`. Defaults to `i-heroicons-chevron-down-20-solid`. ::component-card --- diff --git a/docs/content/3.forms/4.select-menu.md b/docs/content/3.forms/4.select-menu.md index 898099b9..c1583ffd 100644 --- a/docs/content/3.forms/4.select-menu.md +++ b/docs/content/3.forms/4.select-menu.md @@ -136,9 +136,9 @@ const selected = ref(people[0]) Use any icon from [Iconify](https://icones.js.org) by setting the `icon` prop by using this pattern: `i-{collection_name}-{icon_name}`. -Use the `trailingIcon` prop to set a different icon or change it globally in `ui.select.default.trailingIcon`. Defaults to `i-heroicons-chevron-down-20-solid`. +Use the `trailing-icon` prop to set a different icon or change it globally in `ui.select.default.trailingIcon`. Defaults to `i-heroicons-chevron-down-20-solid`. -Use the `selectedIcon` prop to set a different icon or change it globally in `ui.selectMenu.default.selectedIcon`. Defaults to `i-heroicons-check-20-solid`. +Use the `selected-icon` prop to set a different icon or change it globally in `ui.selectMenu.default.selectedIcon`. Defaults to `i-heroicons-check-20-solid`. ::component-card --- diff --git a/docs/content/4.navigation/2.command-palette.md b/docs/content/4.navigation/2.command-palette.md index 264c6cd5..e10e180f 100644 --- a/docs/content/4.navigation/2.command-palette.md +++ b/docs/content/4.navigation/2.command-palette.md @@ -160,7 +160,7 @@ function onSelect (option) { Use any icon from [Iconify](https://icones.js.org) by setting the `icon` prop by using this pattern: `i-{collection_name}-{icon_name}`. -Use the `selectedIcon` prop to set a different icon or change it globally in `ui.commandPalette.default.selectedIcon`. Defaults to `i-heroicons-check-20-solid`. +Use the `selected-icon` prop to set a different icon or change it globally in `ui.commandPalette.default.selectedIcon`. Defaults to `i-heroicons-check-20-solid`. ::component-card --- @@ -174,6 +174,24 @@ excludedProps: --- :: +### Loading + +Use the `loading` prop to show a loading icon. + +Use the `loading-icon` prop to set a different icon or change it globally in `ui.commandPalette.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`. + +::component-card +--- +padding: false +baseProps: + empty: null +props: + loading: true +excludedProps: + - icon +--- +:: + ### Placeholder Use the `placeholder` prop to change the input placeholder @@ -218,6 +236,8 @@ Use the `empty` prop to display a message when there are no results. You can pass an `object` through the `empty` prop or globally through `ui.commandPalette.default.empty`. Here is the default: +You can also set it to `null` to hide the empty label. + ::component-card --- padding: false @@ -299,6 +319,10 @@ const groups = computed(() => { ``` :: +::alert{icon="i-heroicons-light-bulb"} +The `loading` state will automatically be enabled when a `search` function is loading. You can disable this behaviour by setting the `loading-icon` prop to `null` or globally in `ui.commandPalette.default.loadingIcon`. +:: + ## Themes Our theming system provides a lot of flexibility to customize the component. Here is some examples of what you can do. diff --git a/src/runtime/app.config.ts b/src/runtime/app.config.ts index 73ce3752..7e143da2 100644 --- a/src/runtime/app.config.ts +++ b/src/runtime/app.config.ts @@ -546,6 +546,7 @@ const commandPalette = { }, default: { icon: 'i-heroicons-magnifying-glass-20-solid', + loadingIcon: 'i-heroicons-arrow-path-20-solid', empty: { icon: 'i-heroicons-magnifying-glass-20-solid', label: 'We couldn\'t find any items.', diff --git a/src/runtime/components/navigation/CommandPalette.vue b/src/runtime/components/navigation/CommandPalette.vue index 50e10bae..e95a17b3 100644 --- a/src/runtime/components/navigation/CommandPalette.vue +++ b/src/runtime/components/navigation/CommandPalette.vue @@ -8,7 +8,7 @@ >
-