Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor:slider #6250

Merged
merged 2 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions components/slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import classNames from '../_util/classNames';
import { useInjectFormItemContext } from '../form/FormItemContext';
import type { FocusEventHandler } from '../_util/EventInterface';

// CSSINJS
import useStyle from './style';

export type SliderValue = number | [number, number];

interface SliderMarks {
Expand Down Expand Up @@ -87,6 +90,10 @@ const Slider = defineComponent({
setup(props, { attrs, slots, emit, expose }) {
const { prefixCls, rootPrefixCls, direction, getPopupContainer, configProvider } =
useConfigInject('slider', props);

// style
const [wrapSSR, hashId] = useStyle(prefixCls);

const formItemContext = useInjectFormItemContext();
const sliderRef = ref();
const visibles = ref<Visibles>({});
Expand Down Expand Up @@ -156,9 +163,13 @@ const Slider = defineComponent({
...restProps
} = props;
const tooltipPrefixCls = configProvider.getPrefixCls('tooltip', customizeTooltipPrefixCls);
const cls = classNames(attrs.class, {
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
});
const cls = classNames(
attrs.class,
{
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
},
hashId.value,
);

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

if (range) {
return (
return wrapSSR(
<VcRange
{...attrs}
{...restProps}
step={restProps.step!}
draggableTrack={draggableTrack}
Expand All @@ -190,11 +202,12 @@ const Slider = defineComponent({
onChange={handleChange}
onBlur={handleBlur}
v-slots={{ mark: slots.mark }}
/>
/>,
);
}
return (
return wrapSSR(
<VcSlider
{...attrs}
{...restProps}
id={id}
step={restProps.step!}
Expand All @@ -211,7 +224,7 @@ const Slider = defineComponent({
onChange={handleChange}
onBlur={handleBlur}
v-slots={{ mark: slots.mark }}
/>
/>,
);
};
},
Expand Down
212 changes: 0 additions & 212 deletions components/slider/style/index.less

This file was deleted.

Loading