From 2f080d083202644ff89326086734f6182c7802c1 Mon Sep 17 00:00:00 2001 From: Josh Daniel Date: Sat, 18 Mar 2023 22:13:01 +0800 Subject: [PATCH] refactor: move ColorPicker to a file --- src/components/ColorPicker.tsx | 42 ++++++++++++++++++++++++++++++ src/components/StringToQRCode.tsx | 43 +------------------------------ src/pages/index.tsx | 1 - 3 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 src/components/ColorPicker.tsx diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx new file mode 100644 index 0000000..85ed921 --- /dev/null +++ b/src/components/ColorPicker.tsx @@ -0,0 +1,42 @@ +import { ChromePicker } from "@hello-pangea/color-picker"; +import Tippy from "@tippyjs/react"; + +interface IColorPickerProps { + hoverContent: string; + color: string; + setColor: (color: string) => any; +} +export const ColorPicker: React.FC = ({ + color, + setColor, + hoverContent, +}) => { + return ( +
+ +
+ + setColor(v.hex)} + /> +
+ } + > +
+
+
+ + + ); +}; diff --git a/src/components/StringToQRCode.tsx b/src/components/StringToQRCode.tsx index 92d8630..4cf165c 100644 --- a/src/components/StringToQRCode.tsx +++ b/src/components/StringToQRCode.tsx @@ -1,12 +1,11 @@ import React, { useState, useCallback, useRef } from "react"; import { nanoid } from "nanoid"; import QRCode from "react-qr-code"; -import Tippy from "@tippyjs/react"; import { toPng } from "html-to-image"; // import { addNote, notes } from "../store"; // import { useStore } from "@nanostores/react"; -import { ChromePicker } from "@hello-pangea/color-picker"; import { VscLoading as LoadingIcon } from "react-icons/vsc"; +import { ColorPicker } from "./ColorPicker"; const StringToQRCode = () => { const qrRef = useRef(null); @@ -116,43 +115,3 @@ const StringToQRCode = () => { }; export default StringToQRCode; - -interface IColorPickerProps { - hoverContent: string; - color: string; - setColor: (color: string) => any; -} -const ColorPicker: React.FC = ({ - color, - setColor, - hoverContent, -}) => { - return ( -
- -
- - setColor(v.hex)} - /> -
- } - > -
-
-
- - - ); -}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index b89121d..05221d1 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,6 +1,5 @@ import StringToQRCode from "@/components/StringToQRCode"; import Head from "next/head"; -import Image from "next/image"; import Link from "next/link"; export default function Home() {