Skip to content

Commit 95a1283

Browse files
committed
FaSlider 组件增加 tooltip 属性
1 parent 42b1d20 commit 95a1283

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/ui/components/FaSlider/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const props = withDefaults(defineProps<{
1616
step?: SliderRootProps['step']
1717
orientation?: SliderRootProps['orientation']
1818
thumbAlignment?: SliderRootProps['thumbAlignment']
19+
tooltip?: boolean
1920
class?: HTMLAttributes['class']
2021
}>(), {
2122
defaultValue: () => [0],
@@ -26,6 +27,7 @@ const props = withDefaults(defineProps<{
2627
step: 1,
2728
orientation: 'horizontal',
2829
thumbAlignment: 'contain',
30+
tooltip: true,
2931
})
3032
3133
const modelValue = defineModel<number[]>()

src/ui/components/FaSlider/slider/Slider.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { reactiveOmit } from '@vueuse/core'
55
import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from 'reka-ui'
66
import { cn } from '@/utils'
77
8-
const props = defineProps<SliderRootProps & { class?: HTMLAttributes['class'] }>()
8+
const props = defineProps<SliderRootProps & {
9+
class?: HTMLAttributes['class']
10+
tooltip?: boolean
11+
}>()
912
const emits = defineEmits<SliderRootEmits>()
1013
1114
const delegatedProps = reactiveOmit(props, 'class')
@@ -24,7 +27,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
2427
<SliderTrack class="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary data-[orientation=vertical]:w-2">
2528
<SliderRange class="absolute h-full bg-primary data-[orientation=vertical]:w-full" />
2629
</SliderTrack>
27-
<FaTooltip v-for="(val, key) in modelValue" :key="key" :text="val.toString()" disable-closing-trigger>
30+
<FaTooltip v-for="(val, key) in modelValue" :key="key" :text="val.toString()" disable-closing-trigger :disabled="!props.tooltip">
2831
<SliderThumb
2932
class="block h-5 w-5 border-2 border-primary rounded-full bg-background ring-offset-background transition-colors disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring"
3033
/>

0 commit comments

Comments
 (0)