Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ yarn.lock
storybook/
es/
package-lock.json
pnpm-lock.yaml
src/*.js
src/*.map
tslint.json
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
"dependencies": {
"@ant-design/fast-color": "^3.0.0",
"@rc-component/util": "^1.3.0",
"classnames": "^2.2.6"
"clsx": "^2.1.1"
},
"devDependencies": {
"@rc-component/father-plugin": "^2.0.4",
"@rc-component/np": "^1.0.0",
"@rc-component/trigger": "^1.13.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@types/classnames": "^2.2.6",
"@types/node": "^24.5.2",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@types/warning": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CSSProperties } from 'react';
import React, { forwardRef, useMemo } from 'react';
import { ColorPickerPrefixCls, defaultColor } from './util';

import classNames from 'classnames';
import { clsx } from 'clsx';
import { Color } from './color';
import ColorBlock from './components/ColorBlock';
import Picker from './components/Picker';
Expand Down Expand Up @@ -119,7 +119,7 @@ const ColorPicker = forwardRef<HTMLDivElement, ColorPickerProps>(
};

// ============================ Render ============================
const mergeCls = classNames(`${prefixCls}-panel`, className, {
const mergeCls = clsx(`${prefixCls}-panel`, className, {
[`${prefixCls}-panel-disabled`]: disabled,
});

Expand All @@ -138,7 +138,7 @@ const ColorPicker = forwardRef<HTMLDivElement, ColorPickerProps>(
/>
<div className={`${prefixCls}-slider-container`}>
<div
className={classNames(`${prefixCls}-slider-group`, {
className={clsx(`${prefixCls}-slider-group`, {
[`${prefixCls}-slider-group-disabled-alpha`]: disabledAlpha,
})}
>
Expand Down
14 changes: 4 additions & 10 deletions src/components/ColorBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from 'classnames';
import type { FC } from 'react';
import { clsx } from 'clsx';
import React from 'react';

export type ColorBlockProps = {
Expand All @@ -10,7 +9,7 @@ export type ColorBlockProps = {
onClick?: React.MouseEventHandler<HTMLDivElement>;
};

const ColorBlock: FC<ColorBlockProps> = ({
const ColorBlock: React.FC<ColorBlockProps> = ({
color,
prefixCls,
className,
Expand All @@ -20,16 +19,11 @@ const ColorBlock: FC<ColorBlockProps> = ({
const colorBlockCls = `${prefixCls}-color-block`;
return (
<div
className={classNames(colorBlockCls, className)}
className={clsx(colorBlockCls, className)}
style={style}
onClick={onClick}
>
<div
className={`${colorBlockCls}-inner`}
style={{
background: color,
}}
/>
<div className={`${colorBlockCls}-inner`} style={{ background: color }} />
</div>
);
};
Expand Down
11 changes: 4 additions & 7 deletions src/components/Handler.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import classNames from 'classnames';
import type { FC } from 'react';
import { clsx } from 'clsx';
import React from 'react';

type HandlerSize = 'default' | 'small';

const Handler: FC<{
const Handler: React.FC<{
size?: HandlerSize;
color?: string;
prefixCls?: string;
}> = ({ size = 'default', color, prefixCls }) => {
return (
<div
className={classNames(`${prefixCls}-handler`, {
className={clsx(`${prefixCls}-handler`, {
[`${prefixCls}-handler-sm`]: size === 'small',
})}
style={{
backgroundColor: color,
}}
style={{ backgroundColor: color }}
/>
);
};
Expand Down
16 changes: 6 additions & 10 deletions src/components/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { FC } from 'react';
import React, { useRef } from 'react';
import useColorDrag from '../hooks/useColorDrag';
import type { HsbaColorType, TransformOffset } from '../interface';
import Palette from './Palette';

import { useEvent } from '@rc-component/util';
import classNames from 'classnames';
import { clsx } from 'clsx';
import { Color } from '../color';
import { calcOffset, calculateColor } from '../util';
import Gradient from './Gradient';
Expand All @@ -25,7 +24,7 @@ export interface BaseSliderProps {
color: Color;
}

const Slider: FC<BaseSliderProps> = props => {
const Slider: React.FC<BaseSliderProps> = props => {
const {
prefixCls,
colors,
Expand All @@ -36,9 +35,9 @@ const Slider: FC<BaseSliderProps> = props => {
type,
} = props;

const sliderRef = useRef();
const transformRef = useRef();
const colorRef = useRef(color);
const sliderRef = useRef<HTMLDivElement>(null);
const transformRef = useRef<HTMLDivElement>(null);
const colorRef = useRef<Color>(color);

const getValue = (c: Color) => {
return type === 'hue' ? c.getHue() : c.a * 100;
Expand Down Expand Up @@ -94,10 +93,7 @@ const Slider: FC<BaseSliderProps> = props => {
return (
<div
ref={sliderRef}
className={classNames(
`${prefixCls}-slider`,
`${prefixCls}-slider-${type}`,
)}
className={clsx(`${prefixCls}-slider`, `${prefixCls}-slider-${type}`)}
onMouseDown={dragStartHandle}
onTouchStart={dragStartHandle}
>
Expand Down