Skip to content

Commit

Permalink
🚧 wip: 非受控模式进度 70%
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Mar 29, 2022
1 parent 5713040 commit ad3a96a
Show file tree
Hide file tree
Showing 17 changed files with 433 additions and 344 deletions.
18 changes: 18 additions & 0 deletions packages/color-picker/demos/Controlled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { useState } from 'react';

import SketchPicker from '@arvinxu/color-picker';

const Demo = () => {
const [x, setX] = useState();
return (
<SketchPicker
color={x}
onChange={(e) => {
console.log(e);
setX(e);
}}
/>
);
};

export default Demo;
10 changes: 8 additions & 2 deletions packages/color-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
"clean": "rm -rf es lib dist build coverage .umi"
},
"dependencies": {
"reactcss": "^1.2.3",
"chroma-js": "^2.1.1",
"classnames": "^2.3.1",
"lodash": "^4.17.21",
"tinycolor2": "^1.4.2"
"reactcss": "^1.2.3",
"tinycolor2": "^1.4.2",
"zustand": "^3.7.1"
},
"devDependencies": {
"@types/lodash": "^4.14.181"
}
}
4 changes: 2 additions & 2 deletions packages/color-picker/src/ColorPicker.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: ColorPicker
title: ColorPicker 取色器
order: 2
group:
path: /
nav:
path: /components
---

# ColorPicker
# ColorPicker 取色器

一个更好用的取色器

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@

import React from 'react';
import reactCSS from 'reactcss';
import * as color from '../../helpers/color';
import * as color from '../helpers/color';

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

export const SketchFields: React.FC<{
hex?: string;
hsl?: HSLColor;
rgb?: RGBColor;
hsv?: RGBColor;
renderers?: any;
width?: any;
onChange?: (color: any, e: React.ChangeEvent<HTMLInputElement>) => void | undefined;
disableAlpha?: boolean;
}> = ({ onChange, rgb, hsl, hex, disableAlpha }) => {
}> = ({ onChange, disableAlpha }) => {
const { rgb, hsl, hex } = useStore(colorSelector, isEqual);

const styles = reactCSS(
{
default: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { ChangeEvent } from 'react';
import type { ChangeEvent } from 'react';
import React from 'react';

import { Swatch } from '../common';
import { ColorChangeHandler, ColorResult, PresetColor } from './Sketch';
import type { ColorChangeHandler, ColorResult, PresetColor } from '../types';
import { Swatch } from './common';

export const SketchPresetColors: React.FC<{
colors?: PresetColor[] | undefined;
Expand Down
72 changes: 0 additions & 72 deletions packages/color-picker/src/components/common/ColorWrap.js

This file was deleted.

10 changes: 2 additions & 8 deletions packages/color-picker/src/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// @ts-ignore
// @ts-nocheck

export { default as Alpha } from './Alpha';
// @ts-ignore
export { default as Checkboard } from './Checkboard';
// @ts-ignore
export { default as Hue } from './Hue';
// @ts-ignore
export { default as Saturation } from './Saturation';
// @ts-ignore
export { default as ColorWrap } from './ColorWrap';
// @ts-ignore
export { default as EditableInput } from './EditableInput';
// @ts-ignore
export { default as Swatch } from './Swatch';
Loading

0 comments on commit ad3a96a

Please sign in to comment.