mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 13:28:38 +08:00
新增 FaSlider 组件
This commit is contained in:
@@ -198,6 +198,14 @@ const routes: RouteRecordRaw = {
|
||||
title: '选择器',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'slider',
|
||||
name: 'componentExampleBuiltInSlider',
|
||||
component: () => import('@/views/component_built_in_example/slider.vue'),
|
||||
meta: {
|
||||
title: '滑块',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'switch',
|
||||
name: 'componentExampleBuiltInSwitch',
|
||||
|
||||
Vendored
+1
@@ -35,6 +35,7 @@ declare module 'vue' {
|
||||
FaScrollArea: typeof import('./../ui/components/FaScrollArea/index.vue')['default']
|
||||
FaSearchBar: typeof import('./../ui/components/FaSearchBar/index.vue')['default']
|
||||
FaSelect: typeof import('./../ui/components/FaSelect/index.vue')['default']
|
||||
FaSlider: typeof import('./../ui/components/FaSlider/index.vue')['default']
|
||||
FaSmartFixedBlock: typeof import('./../ui/components/FaSmartFixedBlock/index.vue')['default']
|
||||
FaSwitch: typeof import('./../ui/components/FaSwitch/index.vue')['default']
|
||||
FaSystemInfo: typeof import('./../ui/components/FaSystemInfo/index.vue')['default']
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import type { SliderRootProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { Slider } from './slider'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
defaultValue?: SliderRootProps['defaultValue']
|
||||
disabled?: SliderRootProps['disabled']
|
||||
inverted?: SliderRootProps['inverted']
|
||||
max?: SliderRootProps['max']
|
||||
min?: SliderRootProps['min']
|
||||
step?: SliderRootProps['step']
|
||||
orientation?: SliderRootProps['orientation']
|
||||
thumbAlignment?: SliderRootProps['thumbAlignment']
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
defaultValue: () => [0],
|
||||
disabled: false,
|
||||
inverted: false,
|
||||
max: 100,
|
||||
min: 0,
|
||||
step: 1,
|
||||
orientation: 'horizontal',
|
||||
thumbAlignment: 'contain',
|
||||
})
|
||||
|
||||
const modelValue = defineModel<number[]>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slider v-bind="props" v-model="modelValue" />
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import type { SliderRootEmits, SliderRootProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/utils'
|
||||
import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from 'reka-ui'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<SliderRootProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<SliderRootEmits>()
|
||||
|
||||
const delegatedProps = computed(() => {
|
||||
const { class: _, ...delegated } = props
|
||||
|
||||
return delegated
|
||||
})
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SliderRoot
|
||||
:class="cn(
|
||||
'relative flex w-full touch-none select-none items-center data-[orientation=vertical]:flex-col data-[orientation=vertical]:w-2 data-[orientation=vertical]:h-full',
|
||||
props.class,
|
||||
)"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<SliderTrack class="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary data-[orientation=vertical]:w-2">
|
||||
<SliderRange class="absolute h-full bg-primary data-[orientation=vertical]:w-full" />
|
||||
</SliderTrack>
|
||||
<FaTooltip v-for="(val, key) in modelValue" :key="key" :text="val.toString()" disable-closing-trigger>
|
||||
<SliderThumb
|
||||
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"
|
||||
/>
|
||||
</FaTooltip>
|
||||
</SliderRoot>
|
||||
</template>
|
||||
@@ -0,0 +1 @@
|
||||
export { default as Slider } from './Slider.vue'
|
||||
@@ -0,0 +1,20 @@
|
||||
<route lang="yaml">
|
||||
meta:
|
||||
enabled: false
|
||||
</route>
|
||||
|
||||
<script setup lang="ts">
|
||||
const value = ref<number[]>([0])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<FaPageHeader title="滑块" description="FaSlider" />
|
||||
<FaPageMain>
|
||||
<FaSlider v-model="value" />
|
||||
</FaPageMain>
|
||||
<FaPageMain>
|
||||
<FaSlider v-model="value" orientation="vertical" class="data-[orientation=vertical]:h-100" />
|
||||
</FaPageMain>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user