Removes dynamic dimensions for V2 Skeletons in favor of classnames (#4263)

* WIP

* Removes dynamic width in favor of classnames

* Update useLocale.ts

Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
Omar Lópezandsean-brydon authored and GitHub committed 2022-09-09 08:22:39 +00:00
1 parent d7e523d365
commit 99f11dcc5c
8 files changed
+32 -47

No files matched your search

@@ -1,5 +1,3 @@
import React from "react";
import { SkeletonAvatar, SkeletonContainer, SkeletonText } from "@calcom/ui";
import { Icon } from "@calcom/ui/Icon";
@@ -7,10 +5,10 @@ function SkeletonLoader() {
return (
<SkeletonContainer>
<div className="mb-4 flex items-center">
<SkeletonAvatar width="8" height="8" />
<SkeletonAvatar className="h-8 w-8" />
<div className="space-y-1">
<SkeletonText height="4" width="16" />
<SkeletonText height="4" width="24" />
<SkeletonText className="h-4 w-16" />
<SkeletonText className="h-4 w-24" />
</div>
</div>
<ul className="divide-y divide-neutral-200 border border-gray-200 bg-white sm:mx-0 sm:overflow-hidden">
@@ -80,9 +80,9 @@ const ConnectedCalendars = (props: IConnectCalendarsProps) => {
{[0, 0, 0, 0].map((_item, index) => {
return (
<li className="flex w-full flex-row justify-center border-b-0 py-6" key={index}>
<SkeletonAvatar width="8" height="8" className="mx-6 px-4" />
<SkeletonText width="full" height="5" className="ml-1 mr-4 mt-3" />
<SkeletonButton height="8" width="20" className="mr-6 rounded-md p-5" />
<SkeletonAvatar className="mx-6 h-8 w-8 px-4" />
<SkeletonText className="ml-1 mr-4 mt-3 h-5 w-full" />
<SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
</li>
);
})}
+1 -1
View File
@@ -197,7 +197,7 @@ const Component = ({
/>
)
) : (
<SkeletonButton width="24" height="10" />
<SkeletonButton className="h-10 w-24" />
)}
{price !== 0 && (
<span className="block text-right">
+3 -3
View File
@@ -59,14 +59,14 @@ export function TeamSettingsPage() {
<SkeletonText width="16" height="6" />
</div>
}
subtitle={<SkeletonText width="12" height="4" />}
HeadingLeftIcon={<SkeletonAvatar width="12" height="12" className="mt-1" />}>
subtitle={<SkeletonText className="h-4 w-12" />}
HeadingLeftIcon={<SkeletonAvatar className="mt-1 h-12 w-12" />}>
<>
<div className="block sm:flex md:max-w-5xl">
<div className="w-full ltr:mr-2 rtl:ml-2 sm:w-9/12">
<div className="-mx-0 h-[531px] rounded-sm border border-neutral-200 bg-white px-4 sm:px-6" />
<div className="mb-3 mt-7 flex items-center justify-between">
<SkeletonText width="12" height="4" />
<SkeletonText className="h-4 w-12" />
</div>
<div className="-mx-0 h-16 rounded-sm border border-neutral-200 bg-white px-4 sm:px-6" />
</div>
+11 -3
View File
@@ -1,15 +1,19 @@
import classNames from "@calcom/lib/classNames";
type SkeletonBaseProps = {
/** @deprecated @see https://tailwindcss.com/docs/content-configuration#dynamic-class-names */
width?: string;
/** @deprecated @see https://tailwindcss.com/docs/content-configuration#dynamic-class-names */
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";
// 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";
}
interface SkeletonContainer {
@@ -18,6 +22,7 @@ interface SkeletonContainer {
className?: string;
}
/** @deprecated */
const SkeletonAvatar: React.FC<AvatarProps> = ({ width, height, className }) => {
return (
<div
@@ -29,6 +34,7 @@ const SkeletonAvatar: React.FC<AvatarProps> = ({ width, height, className }) =>
);
};
/** @deprecated */
const SkeletonText: React.FC<SkeletonBaseProps> = ({ width = "", height = "", className = "" }) => {
className = width ? `${className} w-${width}` : className;
className = height ? `${className} h-${height}` : className;
@@ -42,6 +48,7 @@ const SkeletonText: React.FC<SkeletonBaseProps> = ({ width = "", height = "", cl
);
};
/** @deprecated */
const SkeletonButton: React.FC<SkeletonBaseProps> = ({ width, height, className }) => {
return (
<SkeletonContainer>
@@ -50,6 +57,7 @@ const SkeletonButton: React.FC<SkeletonBaseProps> = ({ width, height, className
);
};
/** @deprecated */
const SkeletonContainer: React.FC<SkeletonContainer> = ({ children, as, className }) => {
const Component = as || "div";
return <Component className={classNames("animate-pulse", className)}>{children}</Component>;
+2 -6
View File
@@ -594,11 +594,7 @@ const MobileNavigationItem: React.FC<{
aria-current={current ? "page" : undefined}
/>
)}
{isLocaleReady ? (
<span className="block truncate">{t(item.name)}</span>
) : (
<SkeletonText className="" />
)}
{isLocaleReady ? <span className="block truncate">{t(item.name)}</span> : <SkeletonText />}
</a>
</Link>
);
@@ -622,7 +618,7 @@ const MobileNavigationMoreItem: React.FC<{
{item.icon && (
<item.icon className="h-5 w-5 flex-shrink-0 ltr:mr-3 rtl:ml-3" aria-hidden="true" />
)}
{isLocaleReady ? t(item.name) : <SkeletonText className="" />}
{isLocaleReady ? t(item.name) : <SkeletonText />}
</span>
<Icon.FiArrowRight className="h-5 w-5 text-gray-500" />
</a>
+6 -23
View File
@@ -1,51 +1,34 @@
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;
}
const SkeletonAvatar: React.FC<AvatarProps> = ({ width, height, className }) => {
return (
<div
className={classNames(
`mt-1 rounded-full bg-gray-200 ltr:mr-2 rtl:ml-2 w-${width} h-${height}`,
className
)}
/>
);
const SkeletonAvatar: React.FC<SkeletonBaseProps> = ({ className }) => {
return <div className={classNames(`mt-1 rounded-full bg-gray-200 ltr:mr-2 rtl:ml-2`, className)} />;
};
const SkeletonText: React.FC<SkeletonBaseProps> = ({ width = "", height = "", className = "" }) => {
className = width ? `${className} w-${width}` : className;
className = height ? `${className} h-${height}` : className;
const SkeletonText: React.FC<SkeletonBaseProps> = ({ className = "" }) => {
return (
<span
className={classNames(
`dark:white-300 animate-pulse rounded-md bg-gray-300 empty:before:inline-block empty:before:content-[''] w-${width} h-${height}`,
`font-size-0 dark:white-300 animate-pulse rounded-md bg-gray-300 empty:before:inline-block empty:before:content-['']`,
className
)}
/>
);
};
const SkeletonButton: React.FC<SkeletonBaseProps> = ({ width, height, className }) => {
const SkeletonButton: React.FC<SkeletonBaseProps> = ({ className }) => {
return (
<SkeletonContainer>
<div className={classNames(`w-${width} h-${height} bg-gray-200`, className)} />
<div className={classNames(`bg-gray-200`, className)} />
</SkeletonContainer>
);
};
+3 -3
View File
@@ -5,7 +5,7 @@ import { useEmbedStyles } from "@calcom/embed-core/embed-iframe";
import classNames from "@calcom/lib/classNames";
import { daysInMonth, yyyymmdd } from "@calcom/lib/date-fns";
import { weekdayNames } from "@calcom/lib/weekday";
import { SkeletonText } from "@calcom/ui/skeleton";
import { SkeletonText } from "@calcom/ui/v2";
export type DatePickerProps = {
/** which day of the week to render the calendar. Usually Sunday (=0) or Monday (=1) - default: Sunday */
@@ -92,7 +92,7 @@ const Days = ({
className=" dark:bg-darkgray-200 absolute top-0 left-0 right-0 bottom-0 mx-auto flex w-full items-center justify-center rounded-sm border-transparent bg-gray-50 text-center text-gray-400 opacity-50 dark:text-gray-400"
key={`e-${idx}`}
disabled>
<SkeletonText width="5" height="4" />
<SkeletonText className="h-4 w-5" />
</button>
) : (
<DayComponent
@@ -145,7 +145,7 @@ const DatePicker = ({
<span className="text-bookinglight text-sm font-medium">{browsingDate.format("YYYY")}</span>
</>
) : (
<SkeletonText width="24" height="8" />
<SkeletonText className="h-8 w-24" />
)}
</span>
<div className="text-black dark:text-white">