({
example,
isOpen,
onToggle,
}: {
example: any;
isOpen: boolean;
onToggle: () => void;
})
| 155 | ]; |
| 156 | |
| 157 | const ExampleCard = ({ |
| 158 | example, |
| 159 | isOpen, |
| 160 | onToggle, |
| 161 | }: { |
| 162 | example: any; |
| 163 | isOpen: boolean; |
| 164 | onToggle: () => void; |
| 165 | }) => { |
| 166 | const [copied, setCopied] = useState(false); |
| 167 | |
| 168 | const handleCopy = (e: React.MouseEvent, text: string) => { |
| 169 | e.stopPropagation(); // prevent collapsing when copying |
| 170 | navigator.clipboard.writeText(text); |
| 171 | setCopied(true); |
| 172 | toast({ |
| 173 | title: "Copied to clipboard!", |
| 174 | description: "The code snippet has been copied to your clipboard.", |
| 175 | }); |
| 176 | setTimeout(() => setCopied(false), 2000); |
| 177 | }; |
| 178 | |
| 179 | return ( |
| 180 | <div> |
| 181 | <Collapsible open={isOpen} onOpenChange={onToggle}> |
| 182 | <CollapsibleTrigger asChild> |
| 183 | <div className="cursor-pointer"> |
| 184 | <GlassCard hoverable={true} className={`transition-all duration-300 ${isOpen ? 'rounded-b-none border-b-0' : ''}`}> |
| 185 | <div className="p-6"> |
| 186 | <div className="flex flex-col-reverse gap-5 md:gap-0 md:flex-row items-center md:items-start justify-between"> |
| 187 | <div className="text-center md:text-left"> |
| 188 | <h4 className="text-[11px] font-black uppercase tracking-widest text-white"> |
| 189 | {example.title} |
| 190 | </h4> |
| 191 | <p className="text-[10px] font-mono uppercase tracking-widest text-gray-500 mt-1"> |
| 192 | {example.description} |
| 193 | </p> |
| 194 | </div> |
| 195 | <div className="flex items-center gap-2 self-start sm:self-auto"> |
| 196 | <div className="flex items-center gap-1 bg-white/10 text-white border border-white/10 px-3 py-1.5 rounded-lg text-xs font-mono shadow-sm"> |
| 197 | <span>{example.tool}</span> |
| 198 | <ChevronDown |
| 199 | className={`h-3.5 w-3.5 transition-transform ${isOpen ? "rotate-180" : "" |
| 200 | }`} |
| 201 | /> |
| 202 | </div> |
| 203 | </div> |
| 204 | </div> |
| 205 | </div> |
| 206 | </GlassCard> |
| 207 | </div> |
| 208 | </CollapsibleTrigger> |
| 209 | |
| 210 | <CollapsibleContent> |
| 211 | <GlassCard hoverable={false} className="rounded-t-none border-t-0 bg-black/20"> |
| 212 | <div className="p-6 pt-2"> |
| 213 | <div className="space-y-3"> |
| 214 | <div className="flex items-center justify-between flex-wrap gap-2 mb-2"> |
nothing calls this directly
no test coverage detected