cal.pub0.org/packages/ui/skeleton/index.tsx

52 lines
1.4 KiB
TypeScript
Raw Normal View History

import classNames from "@calcom/lib/classNames";
type SkeletonBaseProps = {
width: string;
height: string;
className?: string;
};
interface AvatarProps extends SkeletonBaseProps {
// Limit this cause we don't use avatars bigger than thi
width: "2" | "3" | "4" | "5" | "6" | "8" | "12";
height: "2" | "3" | "4" | "5" | "6" | "8" | "12";
}
interface SkeletonContainer {
as?: keyof JSX.IntrinsicElements;
children?: React.ReactNode;
className?: string;
}
2022-06-28 02:25:06 +00:00
const SkeletonAvatar: React.FC<AvatarProps> = ({ width, height, className }) => {
return (
2022-06-28 02:25:06 +00:00
<div className={`mt-1 rounded-full bg-gray-200 ltr:mr-2 rtl:ml-2 w-${width} h-${height} ${className}`} />
);
};
2022-06-28 02:25:06 +00:00
const SkeletonText: React.FC<SkeletonBaseProps> = ({ width, height, className }) => {
return (
<div
2022-06-28 02:25:06 +00:00
className={classNames(
`dark:white-300 animate-pulse rounded-md bg-gray-300 w-${width} h-${height}`,
className
)}
/>
);
};
2022-06-28 02:25:06 +00:00
const SkeletonButton: React.FC<SkeletonBaseProps> = ({ width, height, className }) => {
return (
<SkeletonContainer>
2022-06-28 02:25:06 +00:00
<div className={`w-${width} h-${height} bg-gray-200 ${className}`} />
</SkeletonContainer>
);
};
const SkeletonContainer: React.FC<SkeletonContainer> = ({ children, as, className }) => {
const Component = as || "div";
return <Component className={classNames("animate-pulse", className)}>{children}</Component>;
};
export { SkeletonAvatar, SkeletonText, SkeletonButton, SkeletonContainer };