Skip to content

Commit 2f04932

Browse files
authored
refactor:slider (#6250)
1 parent 350dbfe commit 2f04932

File tree

7 files changed

+368
-298
lines changed

7 files changed

+368
-298
lines changed

components/slider/index.tsx

+20-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import classNames from '../_util/classNames';
1212
import { useInjectFormItemContext } from '../form/FormItemContext';
1313
import type { FocusEventHandler } from '../_util/EventInterface';
1414

15+
// CSSINJS
16+
import useStyle from './style';
17+
1518
export type SliderValue = number | [number, number];
1619

1720
interface SliderMarks {
@@ -87,6 +90,10 @@ const Slider = defineComponent({
8790
setup(props, { attrs, slots, emit, expose }) {
8891
const { prefixCls, rootPrefixCls, direction, getPopupContainer, configProvider } =
8992
useConfigInject('slider', props);
93+
94+
// style
95+
const [wrapSSR, hashId] = useStyle(prefixCls);
96+
9097
const formItemContext = useInjectFormItemContext();
9198
const sliderRef = ref();
9299
const visibles = ref<Visibles>({});
@@ -156,9 +163,13 @@ const Slider = defineComponent({
156163
...restProps
157164
} = props;
158165
const tooltipPrefixCls = configProvider.getPrefixCls('tooltip', customizeTooltipPrefixCls);
159-
const cls = classNames(attrs.class, {
160-
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
161-
});
166+
const cls = classNames(
167+
attrs.class,
168+
{
169+
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
170+
},
171+
hashId.value,
172+
);
162173

163174
// make reverse default on rtl direction
164175
if (direction.value === 'rtl' && !restProps.vertical) {
@@ -172,8 +183,9 @@ const Slider = defineComponent({
172183
}
173184

174185
if (range) {
175-
return (
186+
return wrapSSR(
176187
<VcRange
188+
{...attrs}
177189
{...restProps}
178190
step={restProps.step!}
179191
draggableTrack={draggableTrack}
@@ -190,11 +202,12 @@ const Slider = defineComponent({
190202
onChange={handleChange}
191203
onBlur={handleBlur}
192204
v-slots={{ mark: slots.mark }}
193-
/>
205+
/>,
194206
);
195207
}
196-
return (
208+
return wrapSSR(
197209
<VcSlider
210+
{...attrs}
198211
{...restProps}
199212
id={id}
200213
step={restProps.step!}
@@ -211,7 +224,7 @@ const Slider = defineComponent({
211224
onChange={handleChange}
212225
onBlur={handleBlur}
213226
v-slots={{ mark: slots.mark }}
214-
/>
227+
/>,
215228
);
216229
};
217230
},

components/slider/style/index.less

-212
This file was deleted.

0 commit comments

Comments
 (0)