forked from datopian/flowershow
-
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.
[pkg/core,site,datopian#120][s]: Remove navbar dropdown and frontpage…
… edits * Remove navbar dropdown support * Bump core v0.3.2 * Make images smaller in frontpage
- Loading branch information
1 parent
1ab19be
commit 5686d72
Showing
10 changed files
with
46 additions
and
183 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
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 |
---|---|---|
@@ -1,82 +1,21 @@ | ||
import { Menu, Transition } from "@headlessui/react"; | ||
import { Menu } from "@headlessui/react"; | ||
import Link from "next/link.js"; | ||
import { Fragment, useRef, useState } from "react"; | ||
|
||
import { BaseLink } from "../Base"; | ||
|
||
import { NavLink, NavDropdown, isNavDropdown } from "../types"; | ||
import { NavLink } from "../types"; | ||
|
||
interface Props { | ||
link: NavLink | NavDropdown; | ||
link: NavLink; | ||
} | ||
|
||
export const NavItem: React.FC<Props> = ({ link }) => { | ||
const dropdownRef = useRef(null); | ||
const [showDropdown, setshowDropdown] = useState(false); | ||
|
||
const timeoutDuration = 200; | ||
let timeoutId; | ||
|
||
const openDropdown = () => { | ||
clearTimeout(timeoutId); | ||
setshowDropdown(true); | ||
}; | ||
const closeDropdown = () => { | ||
timeoutId = setTimeout(() => setshowDropdown(false), timeoutDuration); | ||
}; | ||
|
||
return ( | ||
<Menu as="div" className="relative"> | ||
<Menu.Button | ||
onClick={() => setshowDropdown(!showDropdown)} | ||
onMouseEnter={openDropdown} | ||
onMouseLeave={closeDropdown} | ||
<Link | ||
href={link.href} | ||
className="text-slate-500 inline-flex items-center mr-2 px-1 pt-1 text-sm font-medium hover:text-slate-600" | ||
> | ||
{!isNavDropdown(link) ? ( | ||
<Link | ||
href={link.href} | ||
className="text-slate-500 inline-flex items-center mr-2 px-1 pt-1 text-sm font-medium hover:text-slate-600" | ||
> | ||
{link.name} | ||
</Link> | ||
) : ( | ||
<div className="text-slate-500 inline-flex items-center mr-2 px-1 pt-1 text-sm font-medium hover:text-slate-600 fill-slate-500 hover:fill-slate-600"> | ||
{link.name} | ||
</div> | ||
)} | ||
</Menu.Button> | ||
|
||
{isNavDropdown(link) && ( | ||
<Transition | ||
as={Fragment} | ||
show={showDropdown} | ||
enter="transition ease-out duration-200" | ||
enterFrom="transform opacity-0 scale-5" | ||
enterTo="transform opacity-100 scale-100" | ||
leave="transition ease-in duration-75" | ||
leaveFrom="transform opacity-100 scale-100" | ||
leaveTo="transform opacity-0 scale-5" | ||
> | ||
<Menu.Items | ||
className="absolute top-5 flex flex-col dark:bg-slate-900/95 backdrop-blur" | ||
ref={dropdownRef} | ||
onMouseEnter={openDropdown} | ||
onMouseLeave={closeDropdown} | ||
> | ||
{link.subItems.map(({ name, href }) => ( | ||
<Menu.Item key={name}> | ||
<BaseLink | ||
href={href} | ||
onClick={() => setshowDropdown(false)} | ||
className="text-slate-500 inline-flex items-center mt-2 px-1 pt-1 text-sm font-medium hover:text-slate-600" | ||
> | ||
{name} | ||
</BaseLink> | ||
</Menu.Item> | ||
))} | ||
</Menu.Items> | ||
</Transition> | ||
)} | ||
{link.name} | ||
</Link> | ||
</Menu> | ||
); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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