2022-04-26 14:11:02 +00:00
|
|
|
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
|
2022-06-24 22:44:49 +00:00
|
|
|
width: "2" | "3" | "4" | "5" | "6" | "8" | "12";
|
|
|
|
height: "2" | "3" | "4" | "5" | "6" | "8" | "12";
|
2022-04-26 14:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface SkeletonContainer {
|
|
|
|
as?: keyof JSX.IntrinsicElements;
|
2022-05-17 19:31:49 +00:00
|
|
|
children?: React.ReactNode;
|
2022-06-24 22:45:38 +00:00
|
|
|
className?: string;
|
2022-04-26 14:11:02 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 02:25:06 +00:00
|
|
|
const SkeletonAvatar: React.FC<AvatarProps> = ({ width, height, className }) => {
|
2022-04-26 14:11:02 +00:00
|
|
|
return (
|
2022-06-28 02:28:25 +00:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
`mt-1 rounded-full bg-gray-200 ltr:mr-2 rtl:ml-2 w-${width} h-${height}`,
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
/>
|
2022-04-26 14:11:02 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-06-28 02:25:06 +00:00
|
|
|
const SkeletonText: React.FC<SkeletonBaseProps> = ({ width, height, className }) => {
|
2022-06-27 21:01:46 +00:00
|
|
|
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-27 21:01:46 +00:00
|
|
|
/>
|
|
|
|
);
|
2022-04-26 14:11:02 +00:00
|
|
|
};
|
|
|
|
|
2022-06-28 02:25:06 +00:00
|
|
|
const SkeletonButton: React.FC<SkeletonBaseProps> = ({ width, height, className }) => {
|
2022-06-01 17:24:41 +00:00
|
|
|
return (
|
|
|
|
<SkeletonContainer>
|
2022-06-28 02:28:25 +00:00
|
|
|
<div className={classNames(`w-${width} h-${height} bg-gray-200`, className)} />
|
2022-06-01 17:24:41 +00:00
|
|
|
</SkeletonContainer>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-06-24 22:45:38 +00:00
|
|
|
const SkeletonContainer: React.FC<SkeletonContainer> = ({ children, as, className }) => {
|
2022-04-26 14:11:02 +00:00
|
|
|
const Component = as || "div";
|
2022-06-24 22:45:38 +00:00
|
|
|
return <Component className={classNames("animate-pulse", className)}>{children}</Component>;
|
2022-04-26 14:11:02 +00:00
|
|
|
};
|
|
|
|
|
2022-06-01 17:24:41 +00:00
|
|
|
export { SkeletonAvatar, SkeletonText, SkeletonButton, SkeletonContainer };
|