2022-04-26 14:11:02 +00:00
|
|
|
import classNames from "@calcom/lib/classNames";
|
|
|
|
|
|
|
|
type SkeletonBaseProps = {
|
2022-09-09 08:22:39 +00:00
|
|
|
/** @deprecated @see https://tailwindcss.com/docs/content-configuration#dynamic-class-names */
|
2022-09-05 19:06:34 +00:00
|
|
|
width?: string;
|
2022-09-09 08:22:39 +00:00
|
|
|
/** @deprecated @see https://tailwindcss.com/docs/content-configuration#dynamic-class-names */
|
2022-09-05 19:06:34 +00:00
|
|
|
height?: string;
|
2022-04-26 14:11:02 +00:00
|
|
|
className?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
interface AvatarProps extends SkeletonBaseProps {
|
2022-09-09 08:22:39 +00:00
|
|
|
// Limit this cause we don't use avatars bigger than this
|
|
|
|
/** @deprecated @see https://tailwindcss.com/docs/content-configuration#dynamic-class-names */
|
|
|
|
width?: "2" | "3" | "4" | "5" | "6" | "8" | "12";
|
|
|
|
/** @deprecated @see https://tailwindcss.com/docs/content-configuration#dynamic-class-names */
|
|
|
|
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-09-09 08:22:39 +00:00
|
|
|
/** @deprecated */
|
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-09-09 08:22:39 +00:00
|
|
|
/** @deprecated */
|
2022-09-05 19:06:34 +00:00
|
|
|
const SkeletonText: React.FC<SkeletonBaseProps> = ({ width = "", height = "", className = "" }) => {
|
|
|
|
className = width ? `${className} w-${width}` : className;
|
|
|
|
className = height ? `${className} h-${height}` : className;
|
2022-06-27 21:01:46 +00:00
|
|
|
return (
|
|
|
|
<div
|
2022-06-28 02:25:06 +00:00
|
|
|
className={classNames(
|
2022-09-05 19:06:34 +00:00
|
|
|
`dark:white-300 animate-pulse rounded-md bg-gray-300 empty:before:inline-block empty:before:content-[''] dark:bg-gray-300/50 `,
|
2022-06-28 02:25:06 +00:00
|
|
|
className
|
|
|
|
)}
|
2022-06-27 21:01:46 +00:00
|
|
|
/>
|
|
|
|
);
|
2022-04-26 14:11:02 +00:00
|
|
|
};
|
|
|
|
|
2022-09-09 08:22:39 +00:00
|
|
|
/** @deprecated */
|
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-09-09 08:22:39 +00:00
|
|
|
/** @deprecated */
|
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 };
|