Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit ad3a96a

Browse files
committed
🚧 wip: 非受控模式进度 70%
1 parent 5713040 commit ad3a96a

File tree

17 files changed

+433
-344
lines changed

17 files changed

+433
-344
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React, { useState } from 'react';
2+
3+
import SketchPicker from '@arvinxu/color-picker';
4+
5+
const Demo = () => {
6+
const [x, setX] = useState();
7+
return (
8+
<SketchPicker
9+
color={x}
10+
onChange={(e) => {
11+
console.log(e);
12+
setX(e);
13+
}}
14+
/>
15+
);
16+
};
17+
18+
export default Demo;

packages/color-picker/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@
2323
"clean": "rm -rf es lib dist build coverage .umi"
2424
},
2525
"dependencies": {
26-
"reactcss": "^1.2.3",
26+
"chroma-js": "^2.1.1",
27+
"classnames": "^2.3.1",
2728
"lodash": "^4.17.21",
28-
"tinycolor2": "^1.4.2"
29+
"reactcss": "^1.2.3",
30+
"tinycolor2": "^1.4.2",
31+
"zustand": "^3.7.1"
32+
},
33+
"devDependencies": {
34+
"@types/lodash": "^4.14.181"
2935
}
3036
}

packages/color-picker/src/ColorPicker.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: ColorPicker
2+
title: ColorPicker 取色器
33
order: 2
44
group:
55
path: /
66
nav:
77
path: /components
88
---
99

10-
# ColorPicker
10+
# ColorPicker 取色器
1111

1212
一个更好用的取色器
1313

packages/color-picker/src/components/sketch/SketchFields.tsx renamed to packages/color-picker/src/components/SketchFields.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22

33
import React from 'react';
44
import reactCSS from 'reactcss';
5-
import * as color from '../../helpers/color';
5+
import * as color from '../helpers/color';
66

7-
import { EditableInput } from '../common';
8-
import type { HSLColor, RGBColor } from './Sketch';
7+
import { EditableInput } from './common';
8+
import { colorSelector, useStore } from '@arvinxu/color-picker/store';
9+
import isEqual from 'lodash/isEqual';
910

1011
export const SketchFields: React.FC<{
11-
hex?: string;
12-
hsl?: HSLColor;
13-
rgb?: RGBColor;
14-
hsv?: RGBColor;
15-
renderers?: any;
16-
width?: any;
1712
onChange?: (color: any, e: React.ChangeEvent<HTMLInputElement>) => void | undefined;
1813
disableAlpha?: boolean;
19-
}> = ({ onChange, rgb, hsl, hex, disableAlpha }) => {
14+
}> = ({ onChange, disableAlpha }) => {
15+
const { rgb, hsl, hex } = useStore(colorSelector, isEqual);
16+
2017
const styles = reactCSS(
2118
{
2219
default: {

packages/color-picker/src/components/sketch/SketchPresetColors.tsx renamed to packages/color-picker/src/components/SketchPresetColors.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { ChangeEvent } from 'react';
1+
import type { ChangeEvent } from 'react';
2+
import React from 'react';
23

3-
import { Swatch } from '../common';
4-
import { ColorChangeHandler, ColorResult, PresetColor } from './Sketch';
4+
import type { ColorChangeHandler, ColorResult, PresetColor } from '../types';
5+
import { Swatch } from './common';
56

67
export const SketchPresetColors: React.FC<{
78
colors?: PresetColor[] | undefined;

packages/color-picker/src/components/common/ColorWrap.js

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
// @ts-ignore
1+
// @ts-nocheck
2+
23
export { default as Alpha } from './Alpha';
3-
// @ts-ignore
44
export { default as Checkboard } from './Checkboard';
5-
// @ts-ignore
65
export { default as Hue } from './Hue';
7-
// @ts-ignore
86
export { default as Saturation } from './Saturation';
9-
// @ts-ignore
10-
export { default as ColorWrap } from './ColorWrap';
11-
// @ts-ignore
127
export { default as EditableInput } from './EditableInput';
13-
// @ts-ignore
148
export { default as Swatch } from './Swatch';

0 commit comments

Comments
 (0)