fix(web): 修复 HoverBorderGradient 泛型 Tag 传递与 JSX children 类型推导
This commit is contained in:
@@ -43,7 +43,7 @@ export function HoverBorderGradient<T extends ElementType = "button">({
|
|||||||
onMouseLeave,
|
onMouseLeave,
|
||||||
...props
|
...props
|
||||||
}: HoverBorderGradientProps<T>) {
|
}: HoverBorderGradientProps<T>) {
|
||||||
const Tag = (as || "button") as ElementType;
|
const Tag = (as || "button") as any;
|
||||||
const reducedMotion = useReducedMotion();
|
const reducedMotion = useReducedMotion();
|
||||||
const [hovered, setHovered] = useState(false);
|
const [hovered, setHovered] = useState(false);
|
||||||
const [direction, setDirection] = useState<Direction>("TOP");
|
const [direction, setDirection] = useState<Direction>("TOP");
|
||||||
@@ -58,15 +58,15 @@ export function HoverBorderGradient<T extends ElementType = "button">({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Tag
|
<Tag
|
||||||
{...props}
|
{...(props as any)}
|
||||||
className={cn("relative flex h-min w-full content-center items-center overflow-hidden bg-[var(--user-surface)] p-px transition-colors duration-500", containerClassName)}
|
className={cn("relative flex h-min w-full content-center items-center overflow-hidden bg-[var(--user-surface)] p-px transition-colors duration-500", containerClassName)}
|
||||||
onMouseEnter={(event: MouseEvent<HTMLElement>) => {
|
onMouseEnter={(event: MouseEvent<HTMLElement>) => {
|
||||||
setHovered(true);
|
setHovered(true);
|
||||||
onMouseEnter?.(event as never);
|
(onMouseEnter as any)?.(event);
|
||||||
}}
|
}}
|
||||||
onMouseLeave={(event: MouseEvent<HTMLElement>) => {
|
onMouseLeave={(event: MouseEvent<HTMLElement>) => {
|
||||||
setHovered(false);
|
setHovered(false);
|
||||||
onMouseLeave?.(event as never);
|
(onMouseLeave as any)?.(event);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={cn("relative z-10 w-full rounded-[inherit]", className)}>{children}</div>
|
<div className={cn("relative z-10 w-full rounded-[inherit]", className)}>{children}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user