diff --git a/src/lib/components/Dropdown/index.tsx b/src/lib/components/Dropdown/index.tsx index 6e8044ee0..f3c8b09df 100644 --- a/src/lib/components/Dropdown/index.tsx +++ b/src/lib/components/Dropdown/index.tsx @@ -1,8 +1,6 @@ import type { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react'; import { useMemo } from 'react'; import { HiOutlineChevronDown, HiOutlineChevronLeft, HiOutlineChevronRight, HiOutlineChevronUp } from 'react-icons/hi'; -import classNames from 'classnames'; - import type { ButtonComponentProps } from '../Button'; import { Button } from '../Button'; import type { TooltipProps } from '../Tooltip'; @@ -10,6 +8,7 @@ import { Tooltip } from '../Tooltip'; import { DropdownItem } from './DropdownItem'; import { DropdownDivider } from './DropdownDivider'; import { DropdownHeader } from './DropdownHeader'; +import { excludeClassName } from '../../helpers/exclude'; export type DropdownProps = ButtonComponentProps & Omit & { @@ -28,7 +27,8 @@ const icons: Record>> = { }; const DropdownComponent: FC = (props) => { - const { children, className, label, inline, tooltipArrow = false, arrowIcon = true, ...restProps } = props; + const theirProps = excludeClassName(props) as DropdownProps; + const { children, label, inline, tooltipArrow = false, arrowIcon = true, ...restProps } = theirProps; const { placement = inline ? 'bottom-start' : 'bottom', trigger = 'click', ...buttonProps } = restProps; const Icon = useMemo(() => { @@ -43,7 +43,6 @@ const DropdownComponent: FC = (props) => { return ( , 'className' | 'style'>> { content: ReactNode; placement?: 'auto' | Placement; trigger?: 'hover' | 'click'; style?: 'dark' | 'light' | 'auto'; animation?: false | `duration-${number}`; arrow?: boolean; -}>; +} /** * @see https://floating-ui.com/docs/react-dom-interactions @@ -33,13 +34,15 @@ export const Tooltip: FC = ({ animation = 'duration-300', arrow = true, children, - className, content, placement = 'top', style = 'dark', trigger = 'hover', - ...rest + ...props }) => { + const theme = useTheme().theme.tooltip; + const theirProps = excludeClassName(props); + const arrowRef = useRef(null); const [open, setOpen] = useState(false); @@ -76,23 +79,17 @@ export const Tooltip: FC = ({ return ( <> -
+
{children}
= ({ top: y ?? ' ', left: x ?? ' ', }, - ...rest, + ...theirProps, })} > -
{content}
+
{content}
{arrow && (
= ({ left: arrowX ?? ' ', right: ' ', bottom: ' ', - [floatingArrowPlacement({ placement: floatingTooltip.placement })]: '-4px', + [floatingArrowPlacement({ placement: floatingTooltip.placement })]: theme.arrow.placement, }} >   diff --git a/src/lib/theme/default.ts b/src/lib/theme/default.ts index cdc9fad9b..f6021388b 100644 --- a/src/lib/theme/default.ts +++ b/src/lib/theme/default.ts @@ -411,4 +411,25 @@ export default { icon: 'h-5 w-5 shrink-0', }, }, + tooltip: { + target: 'w-fit', + base: 'absolute inline-block rounded-lg py-2 px-3 text-sm font-medium shadow-sm', + animation: 'transition-opacity', + hidden: 'invisible opacity-0', + style: { + dark: 'bg-gray-900 text-white dark:bg-gray-700', + light: 'border border-gray-200 bg-white text-gray-900', + auto: 'border border-gray-200 bg-white text-gray-900 dark:border-none dark:bg-gray-700 dark:text-white', + }, + content: 'relative z-20', + arrow: { + base: 'absolute z-10 h-2 w-2 rotate-45', + style: { + dark: 'bg-gray-900 dark:bg-gray-700', + light: 'bg-white', + auto: 'bg-white dark:bg-gray-700', + }, + placement: '-4px', + }, + }, };