Migrating from ghl-ui Upload to HighRise Upload
This guide will help you migrate from the ghl-ui Upload component to the new HighRise Upload component.
Component Implementation Changes
Import Changes
diff
- import { UIUpload } from '@gohighlevel/ghl-ui'
+ import { HLUpload } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UIUpload
- :fileList="files"
- @change="handleChange"
- >
+ <HLUpload
+ id="file-upload"
+ v-model:file-list="files"
+ label="Upload Files"
+ @change="handleChange"
+ />
Props Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
fileList | v-model:file-list | Changed to use file-list prop |
accept | accept | Enhanced file type support |
status | status | New prop for validation status |
validation-message | validation-message | New prop for validation feedback |
max-size | max-size | New prop for file size limit (MB) |
max-count | max-count | New prop for file count limit |
show-file-list | show-file-list | New prop for file list visibility |
drag | drag | New prop for drag and drop |
Examples
Basic Upload
vue
<template>
<HLUpload v-model:file-list="fileList" @change="handleChange"> </HLUpload>
</template>
<script setup>
import { ref } from 'vue'
import { HLUpload } from '@platform-ui/highrise'
const fileList = ref([])
const handleChange = (fileList: HLUploadFile[]) => {
console.log(fileList)
}
</script>
Drag and Drop Upload
vue
<template>
<HLUpload id="drag-upload" v-model:value="files" label="Drag and Drop Files" :max-size="5" :max-count="5" accept="image/*" drag />
</template>
<script setup>
import { ref } from 'vue'
import { HLUpload } from '@platform-ui/highrise'
const files = ref([])
</script>
Upload with Custom Preview
vue
<template>
<HLUpload
id="custom-preview-upload"
v-model:value="files"
label="Upload Images"
:max-size="5"
:max-count="5"
accept="image/*"
:show-file-list="true"
>
<template #preview="{ file }">
<div class="custom-preview">
<img :src="file.url" :alt="file.name" />
<span>{{ file.name }}</span>
</div>
</template>
</HLUpload>
</template>
<script setup>
import { ref } from 'vue'
import { HLUpload } from '@platform-ui/highrise'
const files = ref([])
</script>
<style scoped>
.custom-preview {
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid #e5e7eb;
border-radius: 4px;
}
.custom-preview img {
width: 40px;
height: 40px;
object-fit: cover;
border-radius: 4px;
}
</style>
Upload with File Handler
vue
<template>
<HLUpload v-model:file-list="fileList" @change="handleChange"> </HLUpload>
</template>
<script setup>
import { ref } from 'vue'
import { HLUpload } from '@platform-ui/highrise'
const fileList = ref([])
const handleChange = fileList => {
// simulating file upload
// call actual upload API here and update the fileList with the actual file info
let progress = 0
const interval = setInterval(() => {
progress += 20
fileList.value = fileList.value.map(file => ({
...file,
status: progress >= 100 ? 'finished' : 'uploading',
percentage: progress,
url: progress >= 100 ? 'https://storage.googleapis.com/msgsndr/Vnhvoz8w8g7iFEFz37aq/media/640572bf27f37128ce68dcd2.jpeg' : undefined,
}))
if (progress >= 100) {
clearInterval(interval)
}
}
</script>
Best Practices
- Always provide a unique
id
for accessibility - Use
v-model:value
for two-way binding - Implement proper form validation
- Set appropriate file size limits
- Set appropriate file count limits
- Specify accepted file types
- Add proper ARIA labels
- Handle loading states appropriately
- Use descriptive labels
- Implement proper error handling
- Consider using tooltips for additional information
- Handle disabled states properly
- Use consistent spacing and alignment
- Consider file preview options
- Handle file type validation
- Consider drag and drop UX
Additional Notes
- The component automatically handles focus states
- Error states are managed through validation status
- Supports keyboard navigation
- Maintains consistent styling with other form components
- Handles disabled states consistently
- Integrates seamlessly with form validation
- 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 validation support
- Supports file type validation
- Handles file size validation
- Supports custom file previews
- Provides clear upload feedback
- Supports drag and drop
- Handles file list management