diff --git a/src/components/BrandSection/ColorCardBtn/ColorCardBtn.tsx b/src/components/BrandSection/ColorCardBtn/ColorCardBtn.tsx
index 9b613545..321787b9 100644
--- a/src/components/BrandSection/ColorCardBtn/ColorCardBtn.tsx
+++ b/src/components/BrandSection/ColorCardBtn/ColorCardBtn.tsx
@@ -2,10 +2,18 @@ import React, { useState } from "react"
import classes from "./style.module.css"
import { Block } from "baseui/block"
import Icons from "~/components/Icons"
+import BrandColorPicker from "../ColorPicker/BrandColorPicker"
-const ColorCardBtn = ({ Width, Height, ColorCode, HandleOnClick }: any) => {
+const ColorCardBtn = ({ ColorCode, index, handleDelete, handleEdit, type }: any) => {
const [isHover, setIsHover] = useState(false)
const [openPopup, setOpenPopup] = useState(false)
+ const [isEdit, setIsEdit] = useState(false)
+
+ const handleCloseEdit = () => {
+ setIsEdit(false)
+ }
+
+
return (
{
setOpenPopup(false)
}}
>
- {isHover && setOpenPopup(!openPopup)}>}
+ {isHover && (
+ setOpenPopup(!openPopup)}>
+
+
+ )}
- {openPopup &&
- Copy Color Code
- Edit
- Delete
-
}
+ {openPopup && (
+
+ {
+ navigator.clipboard.writeText(ColorCode)
+ setOpenPopup(false)
+ }}
+ className={classes.popupOption}
+ >
+ Copy Color Code
+
+ setIsEdit(!isEdit)} className={classes.popupOption}>Edit
+ {
+ handleDelete(index)
+ setOpenPopup(false)
+ }}
+ className={classes.popupOption}
+ >
+ Delete
+
+
+ )}
{ColorCode ? ColorCode.toUpperCase() : "#F259E8"}
+
+ {isEdit && }
+
)
}
diff --git a/src/components/BrandSection/ColorCardBtn/style.module.css b/src/components/BrandSection/ColorCardBtn/style.module.css
index 102ef6ec..ce75ab41 100644
--- a/src/components/BrandSection/ColorCardBtn/style.module.css
+++ b/src/components/BrandSection/ColorCardBtn/style.module.css
@@ -1,4 +1,5 @@
.brandColorCardBtn {
+ position: relative;
width: 120px;
height: 120px;
display: flex;
diff --git a/src/components/BrandSection/ColorPicker/BrandColorPicker.tsx b/src/components/BrandSection/ColorPicker/BrandColorPicker.tsx
index 77cb9507..85fe116e 100644
--- a/src/components/BrandSection/ColorPicker/BrandColorPicker.tsx
+++ b/src/components/BrandSection/ColorPicker/BrandColorPicker.tsx
@@ -1,29 +1,24 @@
import { Block } from "baseui/block"
import { useState } from "react"
import classes from "./style.module.css"
-import { RgbaColorPicker } from "react-colorful"
-import { throttle } from "lodash"
+import { RgbaColorPicker, HslaColorPicker } from "react-colorful"
import { Button } from "baseui/button"
import Icons from "~/components/Icons"
+import { rgbaTohex } from "~/utils/colorConverter"
-const BrandColorPicker = ({ isOpen, handleClose, inputColor, handleChangeColor }: any) => {
- const [color, setColor] = useState(inputColor)
+const BrandColorPicker = ({ type, handleAddColor, close, index }: any) => {
+ const [color, setColor] = useState({ r: 0, g: 0, b: 0, a: 1 })
const [hexColor, setHexColor] = useState("#000000")
- const [opacity, setOpacity] = useState('100%')
- const close = () => {
- handleClose()
+ const [hslaColor, setHslaColor] = useState({ h: 270, s: 0, l: 0, a: 1 })
+ const [opacity, setOpacity] = useState("100%")
+ const [selectedColorFormat, setSelectedColorFormat] = useState("Hex")
+
+ const handleColorFormatChange = (event: any) => {
+ setSelectedColorFormat(event.target.value)
}
- const updateObjectFill = throttle((color: string) => {
- handleChangeColor(color)
- setColor(color)
- close()
- }, 1000)
-
- function rgba2hex() {
- var hex = '#' +
- (parseInt(`${color?.r}`, 10) | (1 << 8)).toString(16).slice(1) +
- (parseInt(`${color?.g}`, 10) | (1 << 8)).toString(16).slice(1) +
- (parseInt(`${color?.b}`, 10) | (1 << 8)).toString(16).slice(1)
+
+ const rgba2hex = async () => {
+ var hex = rgbaTohex(color.r, color.g, color.b, color.a)
setHexColor(hex)
setOpacity(`${Math.round(color?.a * 100)}%`)
}
@@ -46,13 +41,19 @@ const BrandColorPicker = ({ isOpen, handleClose, inputColor, handleChangeColor }
- {
+ {(selectedColorFormat === 'Hex' || selectedColorFormat === 'Rgba' || selectedColorFormat === 'Css') ?
{
setColor(color)
rgba2hex()
}}
/>
+ :
+ {
+ setHslaColor(hslaColor)
+ }}
+ />
}
@@ -61,30 +62,154 @@ const BrandColorPicker = ({ isOpen, handleClose, inputColor, handleChangeColor }
-
+
-
- {
- BgSolidColors.map((colors, ind) => {
- return
- })
- }
+ HandleSolidColorCreateClick("SolidBgColor")} />
+ {BgSolidColors.map((colors, ind) => {
+ return
+ })}
@@ -81,13 +139,11 @@ const BrandSection = () => {
Gradient Colors
-
+
- {
- GradientColors.map((colors, ind) => {
- return
- })
- }
+ {GradientColors.map((colors, ind) => {
+ return
+ })}
@@ -95,7 +151,6 @@ const BrandSection = () => {
)
}
-
const UplaodModal = ({ isAddFolderOpen, HandleCloseAddModal }: any) => {
return (
{
backgroundColor: "white",
width: "636px",
height: "auto",
- borderRadius: '24px',
- padding: '40px 32px',
- margin: '0px'
+ borderRadius: "24px",
+ padding: "40px 32px",
+ margin: "0px",
}),
},
}}
@@ -133,15 +188,13 @@ const UplaodModal = ({ isAddFolderOpen, HandleCloseAddModal }: any) => {
Add Logo
- HandleCloseAddModal()}>
+ HandleCloseAddModal()}>
-
-
)
diff --git a/src/components/HomePage/index.tsx b/src/components/HomePage/index.tsx
index 40011617..523c6c5f 100644
--- a/src/components/HomePage/index.tsx
+++ b/src/components/HomePage/index.tsx
@@ -8,7 +8,7 @@ const Home = () => {
return (
-
+ {/* */}
diff --git a/src/utils/colorConverter.ts b/src/utils/colorConverter.ts
new file mode 100644
index 00000000..a5c07528
--- /dev/null
+++ b/src/utils/colorConverter.ts
@@ -0,0 +1,81 @@
+export const rgbaTohex = (r: number, g: number, b: number, a: number) => {
+ var hex =
+ "#" +
+ (parseInt(`${r}`, 10) | (1 << 8)).toString(16).slice(1) +
+ (parseInt(`${g}`, 10) | (1 << 8)).toString(16).slice(1) +
+ (parseInt(`${b}`, 10) | (1 << 8)).toString(16).slice(1)
+ // setHexColor(hex)
+ // setOpacity(`${Math.round(a * 100)}%`)
+
+ return hex
+}
+
+export const rgbaTohsva = (r: number, g: number, b: number, a: number) => {
+ // Validate input values
+ if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 1) {
+ throw new Error("Invalid RGBA values. Values must be numbers in the specified range.")
+ }
+
+ // Normalize input values
+ r = r / 255
+ g = g / 255
+ b = b / 255
+ a = Math.min(1, Math.max(0, a))
+
+ // Find the maximum and minimum values among R, G, and B
+ const max = Math.max(r, g, b)
+ const min = Math.min(r, g, b)
+
+ // Calculate the hue
+ let h
+ if (max === min) {
+ h = 0 // achromatic (grayscale)
+ } else {
+ const d = max - min
+ h = max === r ? ((g - b) / d + (g < b ? 6 : 0)) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4
+ h = Math.floor(h * 60) // round down to the nearest whole number
+ }
+
+ // Calculate the saturation
+ const s = max === 0 ? 0 : Math.floor(((max - min) / max) * 100) // round down to the nearest whole number
+
+ // Calculate the value/brightness
+ const v = Math.floor(max * 100) // round down to the nearest whole number
+
+ return { h, s, v, a }
+}
+
+export const rgbaTohsla = (r: number, g: number, b: number, a: number) => {
+ // Validate input values
+ if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 1) {
+ throw new Error("Invalid RGBA values. Values must be numbers in the specified range.")
+ }
+
+ // Normalize input values
+ r = r / 255
+ g = g / 255
+ b = b / 255
+ a = Math.min(1, Math.max(0, a))
+
+ // Find the maximum and minimum values among R, G, and B
+ const max = Math.max(r, g, b)
+ const min = Math.min(r, g, b)
+
+ // Calculate the hue
+ let h
+ if (max === min) {
+ h = 0 // achromatic (grayscale)
+ } else {
+ const d = max - min
+ h = max === r ? ((g - b) / d + (g < b ? 6 : 0)) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4
+ h = Math.round(h * 60) // round to the nearest whole number
+ }
+
+ // Calculate the lightness
+ const l = Math.round(((max + min) / 2) * 100) // round to the nearest whole number
+
+ // Calculate the saturation
+ const s = max === min ? 0 : Math.round(((max - min) / (1 - Math.abs((2 * l) / 100 - 1))) * 100) // round to the nearest whole number
+
+ return { h, s, l, a }
+}