|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { useState } from "react"; |
| 4 | +import { |
| 5 | + LightbulbOffIcon, |
| 6 | + LightbulbIcon, |
| 7 | + LayersIcon, |
| 8 | + GlobeIcon, |
| 9 | + Layers2Icon, |
| 10 | + FlowerIcon, |
| 11 | +} from "lucide-react"; |
| 12 | +import { useGardenStore } from "lib/hooks/store"; |
| 13 | + |
| 14 | +import { |
| 15 | + Button, |
| 16 | + Collapsible, |
| 17 | + CollapsibleContent, |
| 18 | + CollapsibleTrigger, |
| 19 | +} from "components/ui"; |
| 20 | +import type { Theme } from "generated/garden.types"; |
| 21 | + |
| 22 | +const GardenFlowHints = () => { |
| 23 | + const [isOpen, setIsOpen] = useState(false); |
| 24 | + const { activeGarden } = useGardenStore(); |
| 25 | + |
| 26 | + // Extract theme colors with fallbacks |
| 27 | + const theme: Theme | null = activeGarden?.theme || null; |
| 28 | + const primaryColor = theme?.primary_color || "hsl(var(--garden))"; |
| 29 | + const secondaryColor = theme?.secondary_color || "hsl(var(--garden)/30)"; |
| 30 | + const textColor = theme?.text_color || "hsl(var(--foreground))"; |
| 31 | + |
| 32 | + return ( |
| 33 | + <Collapsible |
| 34 | + open={isOpen} |
| 35 | + onOpenChange={setIsOpen} |
| 36 | + className="flex w-[350px] flex-col gap-2" |
| 37 | + > |
| 38 | + <div className="flex flex-col items-end gap-2"> |
| 39 | + <div |
| 40 | + className="rounded-md px-3 py-1.5 text-sm font-medium shadow-sm backdrop-blur-sm border flex items-center gap-2" |
| 41 | + style={{ |
| 42 | + backgroundColor: `${primaryColor}10`, |
| 43 | + color: primaryColor, |
| 44 | + borderColor: secondaryColor, |
| 45 | + }} |
| 46 | + > |
| 47 | + <FlowerIcon className="h-4 w-4" /> |
| 48 | + {activeGarden?.name || "Garden"} |
| 49 | + |
| 50 | + {activeGarden?.icon && ( |
| 51 | + <span className="ml-1">{activeGarden.icon}</span> |
| 52 | + )} |
| 53 | + </div> |
| 54 | + |
| 55 | + <CollapsibleTrigger asChild className="z-10 ml-auto w-fit gap-2 px-4"> |
| 56 | + <Button |
| 57 | + variant="outline" |
| 58 | + size="icon" |
| 59 | + className="hover:border-opacity-60" |
| 60 | + style={{ |
| 61 | + borderColor: `${primaryColor}30`, |
| 62 | + }} |
| 63 | + > |
| 64 | + {isOpen ? ( |
| 65 | + <LightbulbOffIcon size={16} style={{ color: primaryColor }} /> |
| 66 | + ) : ( |
| 67 | + <LightbulbIcon size={16} style={{ color: primaryColor }} /> |
| 68 | + )} |
| 69 | + <span className="sr-only">Toggle</span> |
| 70 | + |
| 71 | + <p>Help</p> |
| 72 | + </Button> |
| 73 | + </CollapsibleTrigger> |
| 74 | + </div> |
| 75 | + |
| 76 | + <CollapsibleContent className="flex flex-col gap-2"> |
| 77 | + <div |
| 78 | + className="z-10 flex flex-col gap-2 rounded-md bg-background/90 p-3 text-xs shadow-md backdrop-blur-sm border" |
| 79 | + style={{ borderColor: secondaryColor }} |
| 80 | + > |
| 81 | + <div className="flex items-center gap-2"> |
| 82 | + <div |
| 83 | + className="h-3 w-3 rounded-full border-2 border-dashed" |
| 84 | + style={{ borderColor: primaryColor }} |
| 85 | + /> |
| 86 | + |
| 87 | + <p style={{ color: textColor }}> |
| 88 | + Click on dashed nodes to navigate into that garden |
| 89 | + </p> |
| 90 | + </div> |
| 91 | + |
| 92 | + <div className="flex items-center gap-2"> |
| 93 | + <div className="flex h-3 w-3 items-center justify-center"> |
| 94 | + <LayersIcon className="h-3 w-3" style={{ color: primaryColor }} /> |
| 95 | + </div> |
| 96 | + |
| 97 | + <p style={{ color: textColor }}> |
| 98 | + Use the{" "} |
| 99 | + <LayersIcon |
| 100 | + className="mx-1 inline h-3 w-3" |
| 101 | + style={{ color: primaryColor }} |
| 102 | + />{" "} |
| 103 | + /{" "} |
| 104 | + <Layers2Icon |
| 105 | + className="mx-1 inline h-3 w-3" |
| 106 | + style={{ color: primaryColor }} |
| 107 | + />{" "} |
| 108 | + toggle to expand or condense subgardens |
| 109 | + </p> |
| 110 | + </div> |
| 111 | + </div> |
| 112 | + </CollapsibleContent> |
| 113 | + </Collapsible> |
| 114 | + ); |
| 115 | +}; |
| 116 | + |
| 117 | +export default GardenFlowHints; |
0 commit comments