mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 02:10:40 +01:00
docs(accordion): add drag and drop example (#3684)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { AccordionItem } from '@nuxt/ui'
|
||||||
|
import { useSortable } from '@vueuse/integrations/useSortable'
|
||||||
|
|
||||||
|
const items = shallowRef<AccordionItem[]>([
|
||||||
|
{
|
||||||
|
label: 'Icons',
|
||||||
|
icon: 'i-lucide-smile',
|
||||||
|
content: 'You have nothing to do, @nuxt/icon will handle it automatically.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Colors',
|
||||||
|
icon: 'i-lucide-swatch-book',
|
||||||
|
slot: 'colors' as const,
|
||||||
|
content: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Components',
|
||||||
|
icon: 'i-lucide-box',
|
||||||
|
content: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const accordion = useTemplateRef<HTMLElement>('accordion')
|
||||||
|
|
||||||
|
useSortable(accordion, items, {
|
||||||
|
animation: 150
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UAccordion ref="accordion" :items="items" />
|
||||||
|
</template>
|
||||||
@@ -292,6 +292,18 @@ props:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
### With drag and drop
|
||||||
|
|
||||||
|
Use the [`useSortable`](https://vueuse.org/integrations/useSortable/) composable from [`@vueuse/integrations`](https://vueuse.org/integrations/README.html) to enable drag and drop functionality on the accordion. This integration wraps [Sortable.js](https://sortablejs.github.io/Sortable/) to provide a seamless drag and drop experience.
|
||||||
|
|
||||||
|
The `useSortable` composable accepts various options, see the [Usage](https://vueuse.org/integrations/useSortable/#usage) for more examples.
|
||||||
|
|
||||||
|
::component-example
|
||||||
|
---
|
||||||
|
name: 'accordion-drag-and-drop-example'
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
"@octokit/rest": "^21.1.1",
|
"@octokit/rest": "^21.1.1",
|
||||||
"@rollup/plugin-yaml": "^4.1.2",
|
"@rollup/plugin-yaml": "^4.1.2",
|
||||||
"@vueuse/nuxt": "^13.0.0",
|
"@vueuse/nuxt": "^13.0.0",
|
||||||
|
"@vueuse/integrations": "^13.0.0",
|
||||||
|
"sortablejs": "^1.15.6",
|
||||||
"joi": "^17.13.3",
|
"joi": "^17.13.3",
|
||||||
"motion-v": "0.13.1",
|
"motion-v": "0.13.1",
|
||||||
"nuxt": "^3.16.1",
|
"nuxt": "^3.16.1",
|
||||||
|
|||||||
16
pnpm-lock.yaml
generated
16
pnpm-lock.yaml
generated
@@ -60,7 +60,7 @@ importers:
|
|||||||
version: 13.0.0(vue@3.5.13(typescript@5.8.2))
|
version: 13.0.0(vue@3.5.13(typescript@5.8.2))
|
||||||
'@vueuse/integrations':
|
'@vueuse/integrations':
|
||||||
specifier: ^13.0.0
|
specifier: ^13.0.0
|
||||||
version: 13.0.0(change-case@5.4.4)(fuse.js@7.1.0)(vue@3.5.13(typescript@5.8.2))
|
version: 13.0.0(change-case@5.4.4)(fuse.js@7.1.0)(sortablejs@1.15.6)(vue@3.5.13(typescript@5.8.2))
|
||||||
colortranslator:
|
colortranslator:
|
||||||
specifier: ^4.1.0
|
specifier: ^4.1.0
|
||||||
version: 4.1.0
|
version: 4.1.0
|
||||||
@@ -254,6 +254,9 @@ importers:
|
|||||||
'@rollup/plugin-yaml':
|
'@rollup/plugin-yaml':
|
||||||
specifier: ^4.1.2
|
specifier: ^4.1.2
|
||||||
version: 4.1.2(rollup@4.34.9)
|
version: 4.1.2(rollup@4.34.9)
|
||||||
|
'@vueuse/integrations':
|
||||||
|
specifier: ^13.0.0
|
||||||
|
version: 13.0.0(change-case@5.4.4)(fuse.js@7.1.0)(sortablejs@1.15.6)(vue@3.5.13(typescript@5.8.2))
|
||||||
'@vueuse/nuxt':
|
'@vueuse/nuxt':
|
||||||
specifier: ^13.0.0
|
specifier: ^13.0.0
|
||||||
version: 13.0.0(magicast@0.3.5)(nuxt@3.16.1(@parcel/watcher@2.5.1)(@types/node@22.13.12)(better-sqlite3@11.9.1)(db0@0.3.1(better-sqlite3@11.9.1))(eslint@9.23.0(jiti@2.4.2))(ioredis@5.6.0)(lightningcss@1.29.2)(magicast@0.3.5)(meow@13.2.0)(optionator@0.9.4)(rollup@4.34.9)(terser@5.39.0)(typescript@5.8.2)(vite@6.2.3(@types/node@22.13.12)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.0))(vue-tsc@2.2.0(typescript@5.8.2))(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))
|
version: 13.0.0(magicast@0.3.5)(nuxt@3.16.1(@parcel/watcher@2.5.1)(@types/node@22.13.12)(better-sqlite3@11.9.1)(db0@0.3.1(better-sqlite3@11.9.1))(eslint@9.23.0(jiti@2.4.2))(ioredis@5.6.0)(lightningcss@1.29.2)(magicast@0.3.5)(meow@13.2.0)(optionator@0.9.4)(rollup@4.34.9)(terser@5.39.0)(typescript@5.8.2)(vite@6.2.3(@types/node@22.13.12)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.0))(vue-tsc@2.2.0(typescript@5.8.2))(yaml@2.7.0))(vue@3.5.13(typescript@5.8.2))
|
||||||
@@ -281,6 +284,9 @@ importers:
|
|||||||
shiki-transformer-color-highlight:
|
shiki-transformer-color-highlight:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
sortablejs:
|
||||||
|
specifier: ^1.15.6
|
||||||
|
version: 1.15.6
|
||||||
superstruct:
|
superstruct:
|
||||||
specifier: ^2.0.2
|
specifier: ^2.0.2
|
||||||
version: 2.0.2
|
version: 2.0.2
|
||||||
@@ -6078,6 +6084,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-D3YaD0aRxR3mEcqnidIs7ReYJFVzWdd6fXJYUM8ixcQcJRGTka/b3saV0KflYhyVJXKhb947GndU35SxYNResQ==}
|
resolution: {integrity: sha512-D3YaD0aRxR3mEcqnidIs7ReYJFVzWdd6fXJYUM8ixcQcJRGTka/b3saV0KflYhyVJXKhb947GndU35SxYNResQ==}
|
||||||
engines: {node: '>= 10.0.0', npm: '>= 3.0.0'}
|
engines: {node: '>= 10.0.0', npm: '>= 3.0.0'}
|
||||||
|
|
||||||
|
sortablejs@1.15.6:
|
||||||
|
resolution: {integrity: sha512-aNfiuwMEpfBM/CN6LY0ibyhxPfPbyFeBTYJKCvzkJ2GkUpazIt3H+QIPAMHwqQ7tMKaHz1Qj+rJJCqljnf4p3A==}
|
||||||
|
|
||||||
source-map-js@1.2.1:
|
source-map-js@1.2.1:
|
||||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -9687,7 +9696,7 @@ snapshots:
|
|||||||
'@vueuse/shared': 13.0.0(vue@3.5.13(typescript@5.8.2))
|
'@vueuse/shared': 13.0.0(vue@3.5.13(typescript@5.8.2))
|
||||||
vue: 3.5.13(typescript@5.8.2)
|
vue: 3.5.13(typescript@5.8.2)
|
||||||
|
|
||||||
'@vueuse/integrations@13.0.0(change-case@5.4.4)(fuse.js@7.1.0)(vue@3.5.13(typescript@5.8.2))':
|
'@vueuse/integrations@13.0.0(change-case@5.4.4)(fuse.js@7.1.0)(sortablejs@1.15.6)(vue@3.5.13(typescript@5.8.2))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vueuse/core': 13.0.0(vue@3.5.13(typescript@5.8.2))
|
'@vueuse/core': 13.0.0(vue@3.5.13(typescript@5.8.2))
|
||||||
'@vueuse/shared': 13.0.0(vue@3.5.13(typescript@5.8.2))
|
'@vueuse/shared': 13.0.0(vue@3.5.13(typescript@5.8.2))
|
||||||
@@ -9695,6 +9704,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
change-case: 5.4.4
|
change-case: 5.4.4
|
||||||
fuse.js: 7.1.0
|
fuse.js: 7.1.0
|
||||||
|
sortablejs: 1.15.6
|
||||||
|
|
||||||
'@vueuse/metadata@10.11.1': {}
|
'@vueuse/metadata@10.11.1': {}
|
||||||
|
|
||||||
@@ -13918,6 +13928,8 @@ snapshots:
|
|||||||
ip-address: 9.0.5
|
ip-address: 9.0.5
|
||||||
smart-buffer: 4.2.0
|
smart-buffer: 4.2.0
|
||||||
|
|
||||||
|
sortablejs@1.15.6: {}
|
||||||
|
|
||||||
source-map-js@1.2.1: {}
|
source-map-js@1.2.1: {}
|
||||||
|
|
||||||
source-map-support@0.5.21:
|
source-map-support@0.5.21:
|
||||||
|
|||||||
Reference in New Issue
Block a user