-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b90e039
commit 2a1bf31
Showing
15 changed files
with
658 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import toast from "react-hot-toast"; | ||
import { | ||
ActiveColorBox as ColorBox, | ||
InactiveColorBox, | ||
} from "@/components/colorbox"; | ||
import { ColorInfo } from "@/types/uploader"; | ||
import { MaxPaletteSize } from "@/constants"; | ||
|
||
type Props = { | ||
colorPalette: ColorInfo[] | null; | ||
}; | ||
|
||
const ColorList = ({ colorPalette }: Props) => { | ||
const handleOnCopyToClipboard = (selectedColor: string): void => { | ||
navigator.clipboard.writeText(selectedColor ?? ""); | ||
toast.success("Copied to clipboard"); | ||
}; | ||
|
||
const InactivePanel = () => { | ||
const boxes = Array.from({ length: MaxPaletteSize }, (_, index) => ( | ||
<InactiveColorBox key={index} /> | ||
)); | ||
|
||
return ( | ||
<div className="flex flex-row justify-around flex-wrap gap-2"> | ||
{boxes} | ||
</div> | ||
); | ||
}; | ||
|
||
const ActivePanel = () => { | ||
const boxes = (colorPalette || []) | ||
.slice(0, MaxPaletteSize) | ||
.map((colorInfo, index) => ( | ||
<ColorBox | ||
key={index} | ||
color={colorInfo.hex} | ||
handleOnCopyToClipboard={handleOnCopyToClipboard} | ||
/> | ||
)); | ||
|
||
return ( | ||
<div className="flex flex-row justify-around flex-wrap gap-2"> | ||
{boxes} | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className="pt-14"> | ||
{colorPalette && colorPalette?.length > 0 ? ( | ||
<ActivePanel /> | ||
) : ( | ||
<InactivePanel /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ColorList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ProhibitIcon from "../icons/prohibit"; | ||
|
||
type Props = { | ||
color: string; | ||
handleOnCopyToClipboard: (color: string) => void; | ||
}; | ||
|
||
const ColorBox = ({ color, handleOnCopyToClipboard }: Props) => { | ||
return ( | ||
<div | ||
className="bg-transparent p-1 w-12 h-12 md:w-28 md:h-28 lg:w-28 lg:h-28 rounded-lg shadow-xl border-2 border-gray-300 border-dashed" | ||
onClick={() => { | ||
handleOnCopyToClipboard(color); | ||
}} | ||
> | ||
<div | ||
className="transform active:scale-y-75 transition-transform cursor-pointer flex flex-col justify-end h-full rounded-lg p-0" | ||
style={{ | ||
backgroundColor: color, | ||
}} | ||
> | ||
<p className="p-2 rounded-b-lg rounded-none w-full text-white text-xs md:text-sm hidden md:block"> | ||
{color} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ColorBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ProhibitIcon from "../icons/prohibit"; | ||
|
||
type Props = { | ||
color?: string; | ||
}; | ||
|
||
const Disabled = ({ color = "#E5E5E5" }: Props) => { | ||
const backgroundColor = `bg-[${color}]`; | ||
|
||
return ( | ||
<div className="bg-transparent p-1 w-12 h-12 md:w-28 md:h-28 lg:w-28 lg:h-28 rounded-lg shadow-xl border-2 border-gray-300 border-dashed"> | ||
<div | ||
className={`cursor-not-allowed flex flex-col justify-center items-center h-full rounded-lg p-0 ${backgroundColor}`} | ||
> | ||
<ProhibitIcon /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default Disabled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as ActiveColorBox } from "./active"; | ||
export { default as InactiveColorBox } from "./disabled"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const ProhibitIcon = () => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="57" | ||
height="57" | ||
fill="none" | ||
viewBox="0 0 57 57" | ||
> | ||
<path | ||
fill="#FF5A79" | ||
d="M28.457.533C12.894.533.332 13.095.332 28.657c0 15.563 12.563 28.125 28.125 28.125 15.563 0 28.125-12.562 28.125-28.124C56.582 13.094 44.019.532 28.457.532zm20.625 28.124a20.43 20.43 0 01-3.656 11.72L16.738 11.688a20.429 20.429 0 0111.719-3.656c11.438 0 20.625 9.28 20.625 20.625zm-41.25 0a20.43 20.43 0 013.656-11.718l28.688 28.687a20.43 20.43 0 01-11.719 3.657C17.113 49.282 7.832 40 7.832 28.656z" | ||
></path> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default ProhibitIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const HeroColors = [ | ||
"#FF5117", | ||
"#FF8E00", | ||
"#F9D81E", | ||
"#97CC37", | ||
"#8177FA", | ||
"#00C0E9", | ||
"#C902E6", | ||
]; | ||
|
||
export const MaxPaletteSize = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.