From 778fd4c8a19f26e8a291c1ad5ad39facbe1e59b9 Mon Sep 17 00:00:00 2001 From: xomimishka Date: Wed, 30 Apr 2025 19:17:02 +0300 Subject: [PATCH] =?UTF-8?q?=D1=88=D0=B8=D0=BC=D0=BC=D0=B5=D1=80=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Skeleton/SkeletonCard.module.scss | 87 +++++++++++++++++++ .../Components/Skeleton/SkeletonCard.tsx | 23 +++++ .../Skeleton/SkeletonGrid.module.scss | 15 ++++ .../Components/Skeleton/SkeletonGrid.tsx | 33 +++++++ .../Components/WithLoading/WithLoading.tsx | 14 +-- 5 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 src/shared/Components/Skeleton/SkeletonCard.module.scss create mode 100644 src/shared/Components/Skeleton/SkeletonCard.tsx create mode 100644 src/shared/Components/Skeleton/SkeletonGrid.module.scss create mode 100644 src/shared/Components/Skeleton/SkeletonGrid.tsx diff --git a/src/shared/Components/Skeleton/SkeletonCard.module.scss b/src/shared/Components/Skeleton/SkeletonCard.module.scss new file mode 100644 index 0000000..e894101 --- /dev/null +++ b/src/shared/Components/Skeleton/SkeletonCard.module.scss @@ -0,0 +1,87 @@ +.card { + position: relative; + width: 100%; + height: 250px; + border-radius: 8px; + background-color: #e0e0e0; + overflow: hidden; + + @media (max-width: 768px) { + height: 215px !important; + } +} + +.pic { + width: 100%; + height: 100%; + border-radius: 8px; + background-color: #ddd; + position: relative; +} + +.shimmer { + position: absolute; + top: 0; + left: -150%; + width: 100%; + height: 100%; + background: linear-gradient(90deg, + rgba(255, 255, 255, 0) 0%, + rgba(255, 255, 255, 0.6) 50%, + rgba(255, 255, 255, 0) 100%); + animation: shimmer 1.5s infinite; +} + +@keyframes shimmer { + 0% { + left: -150%; + } + + 100% { + left: 150%; + } +} + +.labsCard { + height: 300px; + + @media (max-width: 768px) { + height: 215px !important; + } +} + +.titleSkeleton { + margin: 0 10%; + + @include mediaMax($mobile-xs-width) { + margin: 0 5%; + } + height: 40px; + width: 25.5%; + border-radius: 4px; + background-color: #e0e0e0; + position: relative; + overflow: hidden; + margin-bottom: 16px; + + @media (max-width: 768px) { + height: 32px; + width: 70%; + } +} + +.titleSkeleton::after { + content: ""; + position: absolute; + top: 0; + left: -150%; + width: 100%; + height: 100%; + background: linear-gradient( + 90deg, + rgba(255, 255, 255, 0) 0%, + rgba(255, 255, 255, 0.6) 50%, + rgba(255, 255, 255, 0) 100% + ); + animation: shimmer 1.5s infinite; +} \ No newline at end of file diff --git a/src/shared/Components/Skeleton/SkeletonCard.tsx b/src/shared/Components/Skeleton/SkeletonCard.tsx new file mode 100644 index 0000000..9336a68 --- /dev/null +++ b/src/shared/Components/Skeleton/SkeletonCard.tsx @@ -0,0 +1,23 @@ +// shared/Components/SkeletonCard/SkeletonCard.tsx +import styles from "./SkeletonCard.module.scss"; + +interface SkeletonCardProps { + variant?: "default" | "lab"; +} + +const SkeletonCard = ({ variant = "default" }: SkeletonCardProps) => { + const cardClass = + variant === "lab" + ? `${styles.card} ${styles.labsCard}` + : styles.card; + + return ( +
+
+
+
+
+ ); +}; + +export default SkeletonCard; diff --git a/src/shared/Components/Skeleton/SkeletonGrid.module.scss b/src/shared/Components/Skeleton/SkeletonGrid.module.scss new file mode 100644 index 0000000..889114a --- /dev/null +++ b/src/shared/Components/Skeleton/SkeletonGrid.module.scss @@ -0,0 +1,15 @@ +.skeletonGrid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 2rem; + width: 100%; + margin: 0 10%; + + @media (max-width: 768px) { + grid-template-columns: repeat(1, 1fr); + } + + @media (min-width: 769px) and (max-width: 1024px) { + grid-template-columns: repeat(2, 1fr); + } +} \ No newline at end of file diff --git a/src/shared/Components/Skeleton/SkeletonGrid.tsx b/src/shared/Components/Skeleton/SkeletonGrid.tsx new file mode 100644 index 0000000..aa4da02 --- /dev/null +++ b/src/shared/Components/Skeleton/SkeletonGrid.tsx @@ -0,0 +1,33 @@ +// shared/ui/SkeletonGrid/SkeletonGrid.tsx +import React from "react"; +import SkeletonCard from "./SkeletonCard"; +import styles from "@/shared/styles/cardGrid.module.scss"; + +interface SkeletonGridProps { + count?: number; + gridConfig?: { desktop: number; tablet: number; mobile: number }; + variant?: "default" | "lab"; +} + +export const SkeletonGrid = ({ + count = 3, + gridConfig = { desktop: 3, tablet: 2, mobile: 1 }, + variant = "default", +}: SkeletonGridProps) => { + return ( +
+
+ {[...Array(count)].map((_, index) => ( + + ))} +
+
+ ); +}; \ No newline at end of file diff --git a/src/shared/Components/WithLoading/WithLoading.tsx b/src/shared/Components/WithLoading/WithLoading.tsx index f2c6acf..866a7d0 100644 --- a/src/shared/Components/WithLoading/WithLoading.tsx +++ b/src/shared/Components/WithLoading/WithLoading.tsx @@ -1,6 +1,7 @@ // shared/lib/withLoading/withLoading.tsx import React from "react"; import { SkeletonGrid } from "../SkeletonGrid/SkeletonGrid"; +import styles from "../Skeleton/SkeletonCard.module.scss"; interface WithLoadingProps { isLoading: boolean; @@ -21,11 +22,14 @@ export const WithLoading = ({ }: WithLoadingProps) => { if (isLoading) { return ( - +
+
+ +
); }