Migrating from ghl-ui DraggableElement to HighRise DraggableElement
This guide will help you migrate from the ghl-ui DraggableElement component to the new HighRise DraggableElement component.
Component Implementation Changes
Import Changes
diff
- import { UIDraggableElement } from '@gohighlevel/ghl-ui'
+ import { HLDraggableElement } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UIDraggableElement
- :icon="Mail04Icon"
- :label="'mail'"
- />
+ <HLDraggableElement id="draggable-default">
+ <template #content>
+ <div>Visual structure for draggable content</div>
+ </template>
+ </HLDraggableElement>
Props Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
icon | icon | pass icon as icon slot |
label | default | pass the default slot content |
id | id | Required for accessibility |
Examples
Basic Draggable Element
vue
<template>
<HLDraggableElement
id="basic-draggable"
:draggable="true"
:data="itemData"
@drag-start="handleDragStart"
@drag-end="handleDragEnd"
@drag="handleDrag"
>
<div class="draggable-content">
{{ itemData.name }}
</div>
</HLDraggableElement>
</template>
<script setup>
import { ref } from 'vue'
import { HLDraggableElement } from '@platform-ui/highrise'
const itemData = ref({
id: 1,
name: 'Draggable Item',
})
const handleDragStart = evt => {
console.log('Drag started:', evt)
}
const handleDragEnd = evt => {
console.log('Drag ended:', evt)
}
const handleDrag = evt => {
console.log('Dragging:', evt)
}
</script>
Draggable Element with Handle
vue
<template>
<HLDraggableElement
id="handle-draggable"
:draggable="true"
:data="itemData"
drag-handle=".drag-handle"
@drag-start="handleDragStart"
@drag-end="handleDragEnd"
@drag="handleDrag"
>
<div class="draggable-content">
<div class="drag-handle">⋮⋮</div>
<div class="item-content">
{{ itemData.name }}
</div>
</div>
</HLDraggableElement>
</template>
<script setup>
import { ref } from 'vue'
import { HLDraggableElement } from '@platform-ui/highrise'
const itemData = ref({
id: 1,
name: 'Draggable Item with Handle',
})
const handleDragStart = evt => {
console.log('Drag started:', evt)
}
const handleDragEnd = evt => {
console.log('Drag ended:', evt)
}
const handleDrag = evt => {
console.log('Dragging:', evt)
}
</script>
<style scoped>
.draggable-content {
display: flex;
align-items: center;
gap: 8px;
}
.drag-handle {
cursor: move;
padding: 4px;
color: #666;
}
.item-content {
flex: 1;
}
</style>
Disabled Draggable Element
vue
<template>
<HLDraggableElement
id="disabled-draggable"
:disabled="true"
:data="itemData"
@drag-start="handleDragStart"
@drag-end="handleDragEnd"
@drag="handleDrag"
>
<div class="draggable-content">
{{ itemData.name }}
</div>
</HLDraggableElement>
</template>
<script setup>
import { ref } from 'vue'
import { HLDraggableElement } from '@platform-ui/highrise'
const itemData = ref({
id: 1,
name: 'Disabled Draggable Item',
})
const handleDragStart = evt => {
console.log('Drag started:', evt)
}
const handleDragEnd = evt => {
console.log('Drag ended:', evt)
}
const handleDrag = evt => {
console.log('Dragging:', evt)
}
</script>
Best Practices
- Always provide a unique
id
for accessibility - Use appropriate drag handles for better UX
- Implement proper drag event handlers
- Set appropriate data attributes
- Use meaningful content structure
- Add proper ARIA labels
- Handle disabled states appropriately
- Use descriptive item names
- Implement proper error handling
- Consider using tooltips for additional information
- Handle disabled states properly
- Use consistent spacing and alignment
- Consider drag handle placement
- Handle drag events properly
- Consider keyboard navigation
- Implement proper error messages
Additional Notes
- The component automatically handles focus states
- Drag states are managed through events
- Supports keyboard navigation
- Maintains consistent styling with other components
- Handles disabled states consistently
- Integrates seamlessly with other draggable components
- Maintains accessibility standards
- Supports custom styling through CSS variables
- Provides clear visual feedback for all states
- Works well on both desktop and mobile devices
- Supports both controlled and uncontrolled modes
- Includes built-in drag handle support
- Supports custom event handling
- Handles touch events
- Supports custom data attributes
- Provides clear drag feedback
- Supports keyboard input
- Handles drag and drop operations