minor fix

This commit is contained in:
Red Adaya 2024-12-18 15:22:40 +08:00
parent e4bda65be2
commit bd3cb70d3a
2 changed files with 7 additions and 6 deletions

View File

@ -5,6 +5,7 @@
width: max-content;
background-color: rgb(from var(--block-bg-color) r g b / 70%);
color: var(--main-text-color);
padding: 4px 8px;
padding: 8px 10px;
border-radius: 4px;
font-size: 12px;
}

View File

@ -28,12 +28,12 @@ interface TooltipOptions {
onOpenChange?: (open: boolean) => void;
}
export function useTooltip({
export const useTooltip = ({
initialOpen = false,
placement = "top",
open: controlledOpen,
onOpenChange: setControlledOpen,
}: TooltipOptions = {}) {
}: TooltipOptions = {}) => {
const arrowRef = React.useRef(null);
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(initialOpen);
@ -72,7 +72,7 @@ export function useTooltip({
}),
[open, setOpen, arrowRef, interactions, data]
);
}
};
type ContextType = ReturnType<typeof useTooltip> | null;
@ -88,12 +88,12 @@ export const useTooltipState = () => {
return context;
};
export function Tooltip({ children, ...options }: { children: React.ReactNode } & TooltipOptions) {
export const Tooltip = ({ children, ...options }: { children: React.ReactNode } & TooltipOptions) => {
// This can accept any props as options, e.g. `placement`,
// or other positioning options.
const tooltip = useTooltip(options);
return <TooltipContext.Provider value={tooltip}>{children}</TooltipContext.Provider>;
}
};
export const TooltipTrigger = React.forwardRef<HTMLElement, React.HTMLProps<HTMLElement> & { asChild?: boolean }>(
function TooltipTrigger({ children, asChild = false, ...props }, propRef) {