Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new button hover changes #33

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
21 changes: 17 additions & 4 deletions src/components/HeaderDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { ChevronDown, Zap } from "lucide-react"
import { Link } from "wouter"
import { Link, useLocation } from "wouter"
import { useState } from "react"

export default function HeaderDropdown() {
const [isHovered, setIsHovered] = useState(false)
const [, navigate] = useLocation() // useLocation to navigate on button click
const blankTemplates = [
{ name: "Blank Circuit Board", type: "board", badgeColor: "bg-blue-500" },
{
Expand All @@ -21,17 +24,24 @@ export default function HeaderDropdown() {
]

return (
<DropdownMenu>
<DropdownMenu open={isHovered}>
<DropdownMenuTrigger asChild>
<Button
size="sm"
variant="default"
className="bg-blue-600 hover:bg-blue-700"
onMouseEnter={() => setIsHovered(true)} // Show dropdown on hover
onMouseLeave={() => setIsHovered(false)} // Hide dropdown when not hovering
onClick={() => navigate("/editor")} // Navigate on click
PALLAVIKHEDLE marked this conversation as resolved.
Show resolved Hide resolved
>
New <ChevronDown className="ml-1 h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-fit">
<DropdownMenuContent
className="w-fit"
onMouseEnter={() => setIsHovered(true)} // Keep dropdown open when hovering over content
onMouseLeave={() => setIsHovered(false)} // Hide dropdown when not hovering
>
<DropdownMenuItem asChild>
<Link href="/quickstart" className="flex items-center cursor-pointer">
<Zap className="mr-2 h-3 w-3" />
Expand All @@ -41,7 +51,9 @@ export default function HeaderDropdown() {
{blankTemplates.map((template, index) => (
<DropdownMenuItem key={index} asChild>
<a
href={`/editor?template=${template.name.toLowerCase().replace(/ /g, "-")}`}
href={`/editor?template=${template.name
.toLowerCase()
.replace(/ /g, "-")}`}
className="flex items-center cursor-pointer"
>
<span
Expand All @@ -55,3 +67,4 @@ export default function HeaderDropdown() {
</DropdownMenu>
)
}

Loading