From cf0950706f699cfd5124aeb824639215569958c5 Mon Sep 17 00:00:00 2001 From: jeslage Date: Sun, 13 Aug 2023 11:09:09 +0200 Subject: [PATCH] feat: remove useColor hook remove useColor hook due to no usage in component BREAKING CHANGE: remove useColor hook due to no usage in component --- README.md | 35 ++++++++++++----------------------- src/hooks/useColor.ts | 16 ---------------- src/index.tsx | 14 ++++++-------- 3 files changed, 18 insertions(+), 47 deletions(-) delete mode 100644 src/hooks/useColor.ts diff --git a/README.md b/README.md index 6addae1..401557b 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,13 @@ yarn add react-pick-color ## Usage ```js -import React, { useState } from "react"; -import ColorPicker from "react-pick-color"; +import React, { useState } from 'react'; +import ColorPicker from 'react-pick-color'; const App = () => { - const [color, setColor] = useState("#fff"); + const [color, setColor] = useState('#fff'); - return ( - setColor(color.hex)} /> - ); + return setColor(color.hex)} />; }; ``` @@ -85,19 +83,19 @@ You can add a custom theme for styling the colorpicker component or choose one f **Custom Theme** ```js -import ColorPicker from "react-pick-color"; +import ColorPicker from 'react-pick-color'; const ThemedColorPicker = () => { return ( ); @@ -109,22 +107,13 @@ const ThemedColorPicker = () => { `react-pick-color` exports a `dark` and a `light` theme. ```js -import ColorPicker, { themes } from "react-pick-color"; +import ColorPicker, { themes } from 'react-pick-color'; const ThemedColorPicker = () => { return ; }; ``` -## Hooks - -```js -import { useColor } from "react-pick-color"; - -// A color as a hex string or rgba/hsla object. Will return a color object. -const { hex, rgb, hsl, hsv, alpha } = useColor("#fff"); -``` - ## Roadmap - [ ] Size optimization diff --git a/src/hooks/useColor.ts b/src/hooks/useColor.ts deleted file mode 100644 index b980a75..0000000 --- a/src/hooks/useColor.ts +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; - -import { Color, ColorObject } from "../types"; -import { initColor } from "../components/ColorPicker/helper"; - -const useColor = (color: Color) => { - const [col, setCol] = React.useState(initColor(color)); - - React.useEffect(() => { - setCol(initColor(color)); - }, [color]); - - return col; -}; - -export default useColor; diff --git a/src/index.tsx b/src/index.tsx index 2e1e7a3..77b14d7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,6 @@ -import ColorPicker from "./components/ColorPicker/ColorPicker"; -import themes from "./themes"; -import useColor from "./hooks/useColor"; -import { initColor } from "./components/ColorPicker/helper"; +import ColorPicker from './components/ColorPicker/ColorPicker'; +import themes from './themes'; +import { initColor } from './components/ColorPicker/helper'; import { HslColor, HsvColor, @@ -10,12 +9,11 @@ import { Theme, Color, ColorCombination, - ColorObject, -} from "./types"; + ColorObject +} from './types'; export { themes, - useColor, initColor, ColorPicker, HslColor, @@ -25,6 +23,6 @@ export { Theme, Color, ColorCombination, - ColorObject, + ColorObject }; export default ColorPicker;