diff --git a/src/components/UI/Skeleton/Skeleton.styled.tsx b/src/components/UI/Skeleton/Skeleton.styled.tsx new file mode 100644 index 000000000..a7cba3f02 --- /dev/null +++ b/src/components/UI/Skeleton/Skeleton.styled.tsx @@ -0,0 +1,13 @@ +import { keyframes, styled } from "src/styles/stitches.config"; + +const pulseAnimation = keyframes({ + "50%": { opacity: 0.5 }, +}); + +const SkeletonStyled = styled("div", { + animation: `${pulseAnimation} 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;`, + borderRadius: "0.375rem", + backgroundColor: "rgb(17 24 39 / 0.4)", +}); + +export { SkeletonStyled }; diff --git a/src/components/UI/Skeleton/Skeleton.tsx b/src/components/UI/Skeleton/Skeleton.tsx new file mode 100644 index 000000000..6242ce95b --- /dev/null +++ b/src/components/UI/Skeleton/Skeleton.tsx @@ -0,0 +1,10 @@ +import React from "react"; +import { SkeletonStyled } from "./Skeleton.styled"; + +const Skeleton: React.FC> = ({ + ...props +}) => { + return ; +}; + +export default Skeleton; diff --git a/src/components/Viewer/Viewer/ViewerSkeleton.styled.tsx b/src/components/Viewer/Viewer/ViewerSkeleton.styled.tsx new file mode 100644 index 000000000..2070f396b --- /dev/null +++ b/src/components/Viewer/Viewer/ViewerSkeleton.styled.tsx @@ -0,0 +1,62 @@ +import { styled } from "src/styles/stitches.config"; +import Skeleton from "src/components/UI/Skeleton/Skeleton"; + +const TitleSkeleton = styled(Skeleton, { + margin: "1rem", + width: "340px", + height: "30px", +}); + +const ViewerContainer = styled("div", { + display: "flex", + flexDirection: "row", +}); + +const ViewerSkeletonWrapper = styled(Skeleton, { + variants: { + hasInformationPanel: { + true: { + width: "61.8%", + }, + false: { + width: "100%", + }, + }, + }, + height: "500px", + marginRight: "0.25rem", +}); + +const InformationPanel = styled("div", { + display: "flex", + flexDirection: "column", + rowGap: "0.25rem", + width: "38.2%", + marginLeft: "0.25rem", +}); + +const TabSkeleton = styled(Skeleton, { + width: "100%", + height: "40px", +}); + +const TextContainer = styled("div", { + padding: "1.618rem 0px", + display: "flex", + flexDirection: "column", + rowGap: "0.5rem", +}); + +const TextSkeleton = styled(Skeleton, { + height: "20px", +}); + +export { + TitleSkeleton, + ViewerContainer, + ViewerSkeletonWrapper, + InformationPanel, + TabSkeleton, + TextContainer, + TextSkeleton, +}; diff --git a/src/components/Viewer/Viewer/ViewerSkeleton.tsx b/src/components/Viewer/Viewer/ViewerSkeleton.tsx new file mode 100644 index 000000000..578e11529 --- /dev/null +++ b/src/components/Viewer/Viewer/ViewerSkeleton.tsx @@ -0,0 +1,51 @@ +import { ViewerConfigOptions } from "src/context/viewer-context"; +import { + TitleSkeleton, + ViewerContainer, + ViewerSkeletonWrapper, + InformationPanel, + TabSkeleton, + TextContainer, + TextSkeleton, +} from "./ViewerSkeleton.styled"; + +export interface ViewerSkeletonProps { + options: ViewerConfigOptions | undefined; +} + +const ViewerSkeleton: React.FC = ({ options }) => { + return ( + <> + {/* Title */} + + + + {/* Viewer */} + + + {/* Information Panel */} + {!!options?.informationPanel?.open && ( + + {/* Tab */} + + + {/* Text */} + + + + + + + + + + )} + + + ); +}; + +export default ViewerSkeleton; diff --git a/src/components/Viewer/index.tsx b/src/components/Viewer/index.tsx index 260caec52..cd0cba85a 100644 --- a/src/components/Viewer/index.tsx +++ b/src/components/Viewer/index.tsx @@ -22,6 +22,7 @@ import { getActiveManifest, } from "src/lib/iiif"; import { ContentSearchQuery } from "src/types/annotations"; +import ViewerSkeleton from "./Viewer/ViewerSkeleton"; export interface CloverViewerProps { canvasIdCallback?: (arg0: string) => void; @@ -197,7 +198,7 @@ const RenderViewer: React.FC = ({ const CustomLoadingComponent = options.customLoadingComponent; return ; } else { - return <>Loading; + return ; } }