Migrating from ghl-ui Slider to HighRise InputSlider
This guide will help you migrate from the ghl-ui Slider component to the new HighRise InputSlider component.
Component Implementation Changes
Import Changes
diff
- import { UISlider } from '@gohighlevel/ghl-ui'
+ import { HLInputSlider } from '@platform-ui/highrise'
Basic Usage Changes
diff
- <UISlider
- v-model:value="value"
- label="Select Value"
- />
+ <HLInputSlider
+ id="input-slider"
+ v-model:value="value"
+ label="Select Value"
+ />
Form Integration Changes
diff
- <UIForm :model="formModel">
- <UIFormItem label="Rating">
- <UISlider
- v-model:value="formModel.rating"
- label="Select Rating"
- />
- </UIFormItem>
- </UIForm>
+ <HLForm :model="formModel" :rules="rules">
+ <HLFormItem
+ label="Rating"
+ path="rating"
+ required
+ >
+ <HLInputSlider
+ id="rating-slider"
+ v-model:value="formModel.rating"
+ label="Select Rating"
+ />
+ </HLFormItem>
+ </HLForm>
Props Changes
ghl-ui Prop | HighRise Prop | Notes |
---|---|---|
v-model:value | v-model:value | Changed to use value prop |
status | status | New prop for validation status |
validation-message | validation-message | New prop for validation feedback |
size | size | New size options: 'sm', 'md', 'lg' |
showInput | showInput | New prop for number input display |
marks | marks | New prop for custom marks |
range | range | New prop for range selection |
Examples
Basic InputSlider
vue
<template>
<HLInputSlider id="basic-slider" v-model:value="value" label="Select Value" :min="0" :max="100" />
</template>
<script setup>
import { HLInputSlider } from '@platform-ui/highrise'
import { ref } from 'vue'
const value = ref(30)
</script>
InputSlider with Validation
vue
<template>
<HLForm :model="formModel" :rules="rules">
<HLFormItem label="Rating" path="rating" required>
<HLInputSlider
id="rating-slider"
v-model:value="formModel.rating"
label="Select Rating"
:min="0"
:max="5"
:step="0.5"
:status="validationStatus"
:validation-message="validationMessage"
/>
</HLFormItem>
</HLForm>
</template>
<script setup>
import { ref, computed } from 'vue'
import { HLForm, HLFormItem, HLInputSlider } from '@platform-ui/highrise'
const formModel = ref({
rating: 0,
})
const validationStatus = computed(() => {
if (formModel.value.rating < 1) return 'error'
return undefined
})
const validationMessage = computed(() => {
if (formModel.value.rating < 1) return 'Please select a rating'
return undefined
})
const rules = {
rating: [
{
required: true,
message: 'Please select a rating',
trigger: 'change',
},
],
}
</script>
InputSlider with Different Sizes
vue
<template>
<div class="space-y-4">
<HLInputSlider id="slider-lg" v-model:value="value" size="lg" label="Large Slider" :min="0" :max="100" />
<HLInputSlider id="slider-md" v-model:value="value" size="md" label="Medium Slider" :min="0" :max="100" />
<HLInputSlider id="slider-sm" v-model:value="value" size="sm" label="Small Slider" :min="0" :max="100" />
</div>
</template>
<script setup>
import { HLInputSlider, HLForm, HLFormItem } from '@platform-ui/highrise'
import { ref } from 'vue'
const value = ref(50)
</script>
InputSlider with Number Input
vue
<template>
<HLInputSlider id="slider-input" v-model:value="value" label="Select Value" :min="0" :max="100" :showInput="true" />
</template>
<script setup>
import { ref } from 'vue'
import { HLInputSlider } from '@platform-ui/highrise'
const value = ref(50)
</script>
InputSlider with Custom Marks
vue
<template>
<HLInputSlider id="slider-marks" v-model:value="value" label="Select Value" :min="0" :max="100" :marks="marks" />
</template>
<script setup>
import { ref } from 'vue'
import { HLInputSlider } from '@platform-ui/highrise'
const value = ref(50)
const marks = {
0: '0%',
25: '25%',
50: '50%',
75: '75%',
100: '100%',
}
</script>
Breaking Changes
Required ID
- New required
id
prop for accessibility - Must be unique within the page
- New required
Type System
- New
type
prop to specify single/dual handle mode - Default is now 'dual' instead of single value
- New
Input Controls
- New
showInput
prop for numeric input fields - Different input field behavior and validation
- New
Size System
- New size options with consistent scaling
- Different default sizes and spacing
Event System
- New drag events
- Modified event payloads
- Stricter type checking
Marks System
- Removed marks prop
- Use step prop for incremental values
Styling System
- New CSS variable names
- Different theming approach
- Modified default styles
Best Practices
- Always provide a unique
id
for accessibility - Use
v-model:value
for two-way binding - Implement proper form validation
- Use appropriate size variants
- Consider mobile responsiveness
- 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 step size appropriateness
- Handle min/max value constraints
- Use appropriate marks for context
- Consider number input visibility
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 value format validation
- Handles value parsing and formatting
- Supports custom value formats
- Provides clear value input validation
- Supports range selection
- Handles mark customization