mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 02:39:45 +00:00
шиммер для заголовка
This commit is contained in:
1 parent
ab8a55998c
commit
778fd4c8a1
5 files changed
+167
-5
No files matched your search
@@ -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;
|
||||
}
|
||||
@@ -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 (
|
||||
<div className={cardClass}>
|
||||
<div className={styles.pic}>
|
||||
<div className={styles.shimmer}></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SkeletonCard;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 (
|
||||
<div className={styles.mainContainer}>
|
||||
<div
|
||||
className={styles.gridСontainer}
|
||||
style={{
|
||||
"--desktop-columns": gridConfig.desktop,
|
||||
"--tablet-columns": gridConfig.tablet,
|
||||
"--mobile-columns": gridConfig.mobile,
|
||||
} as React.CSSProperties}
|
||||
>
|
||||
{[...Array(count)].map((_, index) => (
|
||||
<SkeletonCard key={index} variant={variant} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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 (
|
||||
<SkeletonGrid
|
||||
count={count}
|
||||
gridConfig={gridConfig}
|
||||
variant={variant}
|
||||
/>
|
||||
<div>
|
||||
<div className={styles.titleSkeleton}></div>
|
||||
<SkeletonGrid
|
||||
count={count}
|
||||
gridConfig={gridConfig}
|
||||
variant={variant}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user