mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-29 03:36:55 +00:00
0cb5fae947
Install motion + animate-ui, overhaul design tokens with brand cyan accent, and replace CSS keyframe animations in Dialog, Tabs, Switch, and Tooltip with spring-physics and blur-fade transitions via animate-ui Radix primitives.
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import {
|
|
motion,
|
|
type HTMLMotionProps,
|
|
type LegacyAnimationControls,
|
|
type TargetAndTransition,
|
|
type Transition,
|
|
} from 'motion/react';
|
|
|
|
import { useAutoHeight } from '@/hooks/use-auto-height';
|
|
import { Slot, type WithAsChild } from '@/components/animate-ui/primitives/animate/slot';
|
|
|
|
type AutoHeightProps = WithAsChild<
|
|
{
|
|
children: React.ReactNode;
|
|
deps?: React.DependencyList;
|
|
animate?: TargetAndTransition | LegacyAnimationControls;
|
|
transition?: Transition;
|
|
} & Omit<HTMLMotionProps<'div'>, 'animate'>
|
|
>;
|
|
|
|
function AutoHeight({
|
|
children,
|
|
deps = [],
|
|
transition = {
|
|
type: 'spring',
|
|
stiffness: 300,
|
|
damping: 30,
|
|
bounce: 0,
|
|
restDelta: 0.01,
|
|
},
|
|
style,
|
|
animate,
|
|
asChild = false,
|
|
...props
|
|
}: AutoHeightProps) {
|
|
const { ref, height } = useAutoHeight<HTMLDivElement>(deps);
|
|
|
|
const Comp = asChild ? Slot : motion.div;
|
|
|
|
return (
|
|
<Comp
|
|
style={{ overflow: 'hidden', ...style }}
|
|
animate={{ height, ...animate }}
|
|
transition={transition}
|
|
{...props}
|
|
>
|
|
<div ref={ref}>{children}</div>
|
|
</Comp>
|
|
);
|
|
}
|
|
|
|
export { AutoHeight, type AutoHeightProps };
|