jan/joi/src/core/Dropdown/index.tsx
Louis 83f090826e
feat: Jan Hub Revamp (#4491)
* feat: model hub revamp UI

* chore: model description - consistent markdown css

* chore: add model versions dropdown

* chore: integrate APIs - model sources

* chore: update model display name

* chore: lint fix

* chore: page transition animation

* feat: model search dropdown - deeplink

* chore: bump cortex version

* chore: add remote model sources

* chore: model download state

* chore: fix model metadata label

* chore: polish model detail page markdown

* test: fix test cases

* chore: initialize default Hub model sources

* chore: fix model stats

* chore: clean up click outside and inside hooks

* feat: change hub banner

* chore: lint fix

* chore: fix css long model id
2025-01-28 22:23:25 +07:00

46 lines
1.4 KiB
TypeScript

import React, { Fragment, PropsWithChildren, ReactNode } from 'react'
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
import './styles.scss'
import { twMerge } from 'tailwind-merge'
type Props = {
options?: { name: ReactNode; value: string; suffix?: ReactNode }[]
className?: string
onValueChanged?: (value: string) => void
}
const Dropdown = (props: PropsWithChildren & Props) => {
return (
<DropdownMenu.Root>
<DropdownMenu.Trigger asChild>{props.children}</DropdownMenu.Trigger>
<DropdownMenu.Portal>
<DropdownMenu.Content
className={twMerge(props.className, 'DropdownMenuContent')}
sideOffset={0}
align="end"
>
{props.options?.map((e, i) => (
<Fragment key={e.value}>
{i !== 0 && (
<DropdownMenu.Separator className="DropdownMenuSeparator" />
)}
<DropdownMenu.Item
className="DropdownMenuItem"
onClick={() => props.onValueChanged?.(e.value)}
>
{e.name}
<div />
{e.suffix}
</DropdownMenu.Item>
</Fragment>
))}
<DropdownMenu.Arrow className="DropdownMenuArrow" />
</DropdownMenu.Content>
</DropdownMenu.Portal>
</DropdownMenu.Root>
)
}
export { Dropdown }