From 9df1791c72af65560340e28dad9f6a818e40e20b Mon Sep 17 00:00:00 2001 From: Camila Sosa Morales Date: Mon, 27 Mar 2023 17:53:02 -0300 Subject: [PATCH] feat: UI color picker component (#189) * wip: color picker styled * chore: color picker * style: alight color picker * style: align color picker --- .../core/icon/custom/chevron-down-icon.tsx | 17 +++++++ ui/src/components/core/icon/custom/index.ts | 1 + ui/src/components/core/icon/icon-library.tsx | 6 ++- ui/src/components/core/input/input-file.tsx | 6 ++- ui/src/components/layout/page/page.styles.ts | 1 - ui/src/views/components-test/color-picker.tsx | 15 ++++++ .../views/components-test/components-test.tsx | 2 + .../fields/logo-field/color-picker.tsx | 51 +++++++++++++++---- 8 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 ui/src/components/core/icon/custom/chevron-down-icon.tsx create mode 100644 ui/src/views/components-test/color-picker.tsx diff --git a/ui/src/components/core/icon/custom/chevron-down-icon.tsx b/ui/src/components/core/icon/custom/chevron-down-icon.tsx new file mode 100644 index 0000000..a4a5e73 --- /dev/null +++ b/ui/src/components/core/icon/custom/chevron-down-icon.tsx @@ -0,0 +1,17 @@ +import { IconStyles as IS } from '../icon.styles'; + +export const ChevronDownIcon: React.FC = (props) => ( + + + +); diff --git a/ui/src/components/core/icon/custom/index.ts b/ui/src/components/core/icon/custom/index.ts index fd31bc3..f113c6a 100644 --- a/ui/src/components/core/icon/custom/index.ts +++ b/ui/src/components/core/icon/custom/index.ts @@ -1,5 +1,6 @@ export * from './metamask-icon'; export * from './ethereum-icon'; +export * from './chevron-down-icon'; export * from './fleek-name-icon'; export * from './beta-tag-icon'; export * from './error-icon'; diff --git a/ui/src/components/core/icon/icon-library.tsx b/ui/src/components/core/icon/icon-library.tsx index b075dda..c7e4a26 100644 --- a/ui/src/components/core/icon/icon-library.tsx +++ b/ui/src/components/core/icon/icon-library.tsx @@ -2,10 +2,10 @@ import { IoLogoGithub } from '@react-icons/all-files/io5/IoLogoGithub'; import { IoArrowBackCircleSharp } from '@react-icons/all-files/io5/IoArrowBackCircleSharp'; import { IoInformationCircleSharp } from '@react-icons/all-files/io5/IoInformationCircleSharp'; import { AiOutlineCheck } from '@react-icons/all-files/ai/AiOutlineCheck'; -import { AiOutlineDown } from '@react-icons/all-files/ai/AiOutlineDown'; import { BiSearch } from '@react-icons/all-files/bi/BiSearch'; import { IoCloudUploadSharp } from '@react-icons/all-files/io5/IoCloudUploadSharp'; import { + ChevronDownIcon, MetamaskIcon, EthereumIcon, ErrorIcon, @@ -18,6 +18,7 @@ import { AiOutlineTwitter } from '@react-icons/all-files/ai/AiOutlineTwitter'; import { IoClose } from '@react-icons/all-files/io5/IoClose'; import { AiFillCheckCircle } from '@react-icons/all-files/ai/AiFillCheckCircle'; import { BiGitBranch } from '@react-icons/all-files/bi/BiGitBranch'; +import { BsFillSquareFill } from '@react-icons/all-files/bs/BsFillSquareFill'; export const IconLibrary = Object.freeze({ back: IoArrowBackCircleSharp, @@ -25,7 +26,7 @@ export const IconLibrary = Object.freeze({ branch: BiGitBranch, check: AiOutlineCheck, 'check-circle': IoCheckmarkCircleSharp, - 'chevron-down': AiOutlineDown, + 'chevron-down': ChevronDownIcon, close: IoClose, error: ErrorIcon, ethereum: EthereumIcon, @@ -36,6 +37,7 @@ export const IconLibrary = Object.freeze({ upload: IoCloudUploadSharp, metamask: MetamaskIcon, //remove if not used search: BiSearch, + square: BsFillSquareFill, success: AiFillCheckCircle, twitter: AiOutlineTwitter, }); diff --git a/ui/src/components/core/input/input-file.tsx b/ui/src/components/core/input/input-file.tsx index b337802..7baf2ba 100644 --- a/ui/src/components/core/input/input-file.tsx +++ b/ui/src/components/core/input/input-file.tsx @@ -34,6 +34,10 @@ export const StyledInputFile = forwardRef( onChange(e); }; + const handleInputClick = () => { + inputFileRef.current?.click(); + }; + return ( <> ( }} ref={ref} {...props} - onClick={() => inputFileRef.current?.click()} + onClick={handleInputClick} > {file !== '' ? ( logo diff --git a/ui/src/components/layout/page/page.styles.ts b/ui/src/components/layout/page/page.styles.ts index 7c67440..78b3d7a 100644 --- a/ui/src/components/layout/page/page.styles.ts +++ b/ui/src/components/layout/page/page.styles.ts @@ -13,7 +13,6 @@ export abstract class PageStyles { minHeight: '85vh', maxWidth: '$7xl', margin: '0 auto', - padding: '$10', display: 'grid', }); } diff --git a/ui/src/views/components-test/color-picker.tsx b/ui/src/views/components-test/color-picker.tsx new file mode 100644 index 0000000..38c85e9 --- /dev/null +++ b/ui/src/views/components-test/color-picker.tsx @@ -0,0 +1,15 @@ +import { Button, Flex, Icon } from '@/components'; + +export const ColorPickerTest = () => { + return ( + + + + ); +}; diff --git a/ui/src/views/components-test/components-test.tsx b/ui/src/views/components-test/components-test.tsx index e703f82..bfac1aa 100644 --- a/ui/src/views/components-test/components-test.tsx +++ b/ui/src/views/components-test/components-test.tsx @@ -1,10 +1,12 @@ import { Flex } from '@/components'; +import { ColorPickerTest } from './color-picker'; import { ComboboxTest } from './combobox-test'; import { ToastTest } from './toast-test'; export const ComponentsTest = () => { return ( + diff --git a/ui/src/views/mint/nfa-step/form-step/fields/logo-field/color-picker.tsx b/ui/src/views/mint/nfa-step/form-step/fields/logo-field/color-picker.tsx index ffac436..bf50915 100644 --- a/ui/src/views/mint/nfa-step/form-step/fields/logo-field/color-picker.tsx +++ b/ui/src/views/mint/nfa-step/form-step/fields/logo-field/color-picker.tsx @@ -1,4 +1,4 @@ -import { Card, Flex } from '@/components'; +import { Button, Card, Flex, Icon } from '@/components'; import { useRef } from 'react'; // @ts-ignore import ColorThief from 'colorthief'; @@ -6,6 +6,7 @@ import { Mint } from '../../../../mint.context'; export const ColorPicker = () => { const { appLogo, logoColor, setLogoColor } = Mint.useContext(); + const inputColorRef = useRef(null); const imageRef = useRef(null); const handleLogoLoad = (e: React.SyntheticEvent) => { @@ -16,17 +17,47 @@ export const ColorPicker = () => { setLogoColor(hexColor); }; + const handleColorPickerClick = () => { + inputColorRef.current?.click(); + }; + return ( - - Primary Color - {/* TODO crate color picker component */} - setLogoColor(e.target.value)} - /> - +
+ + Primary Color + {/* TODO crate color picker component */} + + setLogoColor(e.target.value)} + /> + +
+