|
| 1 | +import React, { useState } from "react"; |
| 2 | + |
| 3 | +import Image from "next/image"; |
| 4 | + |
| 5 | +// ui |
| 6 | +import { Button } from "@plane/ui"; |
| 7 | + |
| 8 | +type Props = { |
| 9 | + title: string; |
| 10 | + description?: React.ReactNode; |
| 11 | + image: any; |
| 12 | + comicBox?: { |
| 13 | + direction: "left" | "right"; |
| 14 | + title: string; |
| 15 | + description: string; |
| 16 | + extraPadding?: boolean; |
| 17 | + }; |
| 18 | + primaryButton?: { |
| 19 | + icon?: any; |
| 20 | + text: string; |
| 21 | + onClick: () => void; |
| 22 | + }; |
| 23 | + secondaryButton?: React.ReactNode; |
| 24 | + disabled?: boolean; |
| 25 | +}; |
| 26 | + |
| 27 | +export const NewEmptyState: React.FC<Props> = ({ |
| 28 | + title, |
| 29 | + description, |
| 30 | + image, |
| 31 | + primaryButton, |
| 32 | + secondaryButton, |
| 33 | + disabled = false, |
| 34 | + comicBox, |
| 35 | +}) => { |
| 36 | + const [isHovered, setIsHovered] = useState(false); |
| 37 | + |
| 38 | + const handleMouseEnter = () => { |
| 39 | + setIsHovered(true); |
| 40 | + }; |
| 41 | + |
| 42 | + const handleMouseLeave = () => { |
| 43 | + setIsHovered(false); |
| 44 | + }; |
| 45 | + return ( |
| 46 | + <div className=" flex flex-col justify-center items-center h-full w-full "> |
| 47 | + <div className="border border-custom-border-200 rounded-xl px-10 py-7 flex flex-col gap-5 max-w-6xl m-5 md:m-16 shadow-sm"> |
| 48 | + <h3 className="font-semibold text-2xl">{title}</h3> |
| 49 | + {description && <p className=" text-lg">{description}</p>} |
| 50 | + <div className="relative w-full max-w-6xl"> |
| 51 | + <Image src={image} className="w-52 sm:w-60" alt={primaryButton?.text} /> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div className="flex justify-center items-start relative"> |
| 55 | + {primaryButton && ( |
| 56 | + <Button |
| 57 | + className={`max-w-min m-3 relative !px-6 ${comicBox?.direction === "left" ? "flex-row-reverse" : ""}`} |
| 58 | + size="lg" |
| 59 | + variant="primary" |
| 60 | + onClick={primaryButton.onClick} |
| 61 | + disabled={disabled} |
| 62 | + > |
| 63 | + {primaryButton.text} |
| 64 | + <div |
| 65 | + onMouseEnter={handleMouseEnter} |
| 66 | + onMouseLeave={handleMouseLeave} |
| 67 | + className={`bg-blue-300 absolute ${ |
| 68 | + comicBox?.direction === "left" ? "left-0 ml-2" : "right-0 mr-2" |
| 69 | + } h-2.5 w-2.5 z-10 rounded-full animate-ping`} |
| 70 | + /> |
| 71 | + <div |
| 72 | + className={`bg-blue-400/40 absolute ${ |
| 73 | + comicBox?.direction === "left" ? "left-0 ml-2.5" : "right-0 mr-2.5" |
| 74 | + } h-1.5 w-1.5 rounded-full`} |
| 75 | + /> |
| 76 | + </Button> |
| 77 | + )} |
| 78 | + {comicBox && |
| 79 | + isHovered && |
| 80 | + (comicBox.direction === "right" ? ( |
| 81 | + <div |
| 82 | + className={`flex max-w-sm absolute top-0 left-1/2 ${ |
| 83 | + comicBox?.extraPadding ? "ml-[125px]" : "ml-[90px]" |
| 84 | + } pb-5`} |
| 85 | + > |
| 86 | + <div className="relative w-0 h-0 border-t-[11px] mt-5 border-custom-border-200 border-b-[11px] border-r-[11px] border-y-transparent"> |
| 87 | + <div className="absolute top-[-10px] right-[-12px] w-0 h-0 border-t-[10px] border-custom-background-100 border-b-[10px] border-r-[10px] border-y-transparent" /> |
| 88 | + </div> |
| 89 | + <div className="border border-custom-border-200 rounded-md bg-custom-background-100"> |
| 90 | + <h1 className="p-5"> |
| 91 | + <h3 className="font-semibold text-lg">{comicBox?.title}</h3> |
| 92 | + <h4 className="text-sm mt-1">{comicBox?.description}</h4> |
| 93 | + </h1> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + ) : ( |
| 97 | + <div className="flex flex-row-reverse max-w-sm absolute top-0 right-1/2 mr-[90px] pb-5"> |
| 98 | + <div className="relative w-0 h-0 border-t-[11px] mt-5 border-custom-border-200 border-b-[11px] border-l-[11px] border-y-transparent"> |
| 99 | + <div className="absolute top-[-10px] left-[-12px] w-0 h-0 border-t-[10px] border-custom-background-100 border-b-[10px] border-l-[10px] border-y-transparent" /> |
| 100 | + </div> |
| 101 | + <div className="border border-custom-border-200 rounded-md bg-custom-background-100"> |
| 102 | + <h1 className="p-5"> |
| 103 | + <h3 className="font-semibold text-lg">{comicBox?.title}</h3> |
| 104 | + <h4 className="text-sm mt-1">{comicBox?.description}</h4> |
| 105 | + </h1> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + ))} |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + </div> |
| 112 | + ); |
| 113 | +}; |
0 commit comments