manifold/web/components/nav/menu.tsx
James Grugett 25ee793208
🏠 New home (#889)
* Factor out section header

* Remove daily balance change

* Remove dead code

* Layout, add streak

* Fix visibility observer to work on server

* Tweak

* Search perserved by url

* Add pill query param

* Add search page

* Extract component for ProbChangeRow

* Explore groups page

* Add search row

* Add trending groups section

* Add unfollow option for group

* Experimental home: accommodate old saved sections.

* Tweaks to search layout

* Rearrange layout

* Daily movers page

* Add streak grayed out indicator

* Use firebase query instead of algolia search for groups

* Replace trending group card with pills

* Hide streak if you turned off that notification

* Listen for group updates

* Better UI for adding / removing groups

* Toast feedback for join/leave group. Customize button moved to bottom.

* Remove Home title

* Refactor arrange home

* Add new for you section

* Add prefetch

* Move home out of experimental!

* Remove unused import

* Show non-public markets from group
2022-09-16 16:12:24 -05:00

58 lines
1.8 KiB
TypeScript

import React, { Fragment } from 'react'
import { Menu, Transition } from '@headlessui/react'
import clsx from 'clsx'
export type MenuItem = {
name: string
href?: string
onClick?: () => void
}
export function MenuButton(props: {
buttonContent: JSX.Element
menuItems: MenuItem[]
className?: string
}) {
const { buttonContent, menuItems, className } = props
return (
<Menu
as="div"
className={clsx(className ? className : 'relative z-40 flex-shrink-0')}
>
<Menu.Button className="w-full rounded-full">
<span className="sr-only">Open user menu</span>
{buttonContent}
</Menu.Button>
<Transition
as={Fragment}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="absolute left-0 mt-2 w-40 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
{menuItems.map((item) => (
<Menu.Item key={item.href}>
{({ active }) => (
<a
href={item.href}
target={item.href?.startsWith('http') ? '_blank' : undefined}
onClick={item.onClick}
className={clsx(
active ? 'bg-gray-100' : '',
'line-clamp-3 block cursor-pointer py-1.5 px-4 text-sm text-gray-700'
)}
>
{item.name}
</a>
)}
</Menu.Item>
))}
</Menu.Items>
</Transition>
</Menu>
)
}