diff --git a/src/shared/Components/SkeletonGrid/SkeletonCard.module.scss b/src/shared/Components/SkeletonGrid/SkeletonCard.module.scss
new file mode 100644
index 0000000..afad60d
--- /dev/null
+++ b/src/shared/Components/SkeletonGrid/SkeletonCard.module.scss
@@ -0,0 +1,51 @@
+.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;
+ }
+}
\ No newline at end of file
diff --git a/src/shared/Components/SkeletonGrid/SkeletonCard.tsx b/src/shared/Components/SkeletonGrid/SkeletonCard.tsx
new file mode 100644
index 0000000..9336a68
--- /dev/null
+++ b/src/shared/Components/SkeletonGrid/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/SkeletonGrid/SkeletonGrid.module.scss b/src/shared/Components/SkeletonGrid/SkeletonGrid.module.scss
new file mode 100644
index 0000000..889114a
--- /dev/null
+++ b/src/shared/Components/SkeletonGrid/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/SkeletonGrid/SkeletonGrid.tsx b/src/shared/Components/SkeletonGrid/SkeletonGrid.tsx
new file mode 100644
index 0000000..aa4da02
--- /dev/null
+++ b/src/shared/Components/SkeletonGrid/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
new file mode 100644
index 0000000..f2c6acf
--- /dev/null
+++ b/src/shared/Components/WithLoading/WithLoading.tsx
@@ -0,0 +1,37 @@
+// shared/lib/withLoading/withLoading.tsx
+import React from "react";
+import { SkeletonGrid } from "../SkeletonGrid/SkeletonGrid";
+
+interface WithLoadingProps {
+ isLoading: boolean;
+ isError: boolean;
+ count?: number;
+ gridConfig?: { desktop: number; tablet: number; mobile: number };
+ variant?: "default" | "lab";
+ children: React.ReactNode;
+}
+
+export const WithLoading = ({
+ isLoading,
+ isError,
+ count = 3,
+ gridConfig = { desktop: 3, tablet: 2, mobile: 1 },
+ variant = "default",
+ children,
+}: WithLoadingProps) => {
+ if (isLoading) {
+ return (
+
+ );
+ }
+
+ if (isError) {
+ return Ошибка при загрузке данных
;
+ }
+
+ return <>{children}>;
+};
\ No newline at end of file
diff --git a/src/shared/styles/cardGrid.module.scss b/src/shared/styles/cardGrid.module.scss
new file mode 100644
index 0000000..49ca5ee
--- /dev/null
+++ b/src/shared/styles/cardGrid.module.scss
@@ -0,0 +1,52 @@
+// shared/styles/cardGrid.module.scss
+:export {
+ --desktop-columns: 3;
+ --tablet-columns: 2;
+ --mobile-columns: 1;
+}
+
+.mainContainer {
+ margin: 0 10%;
+
+ @include mediaMax($mobile-xs-width) {
+ margin: 0 5%;
+ }
+}
+
+.gridСontainer {
+ display: grid;
+ gap: 2rem;
+ margin: 0 auto;
+ width: 100%;
+ max-width: 100%;
+ box-sizing: border-box;
+
+ grid-template-columns: repeat(3, 1fr);
+
+ @media (max-width: 1024px) {
+ grid-template-columns: repeat(var(--tablet-columns), 1fr);
+ }
+
+ @media (max-width: 768px) {
+ grid-template-columns: repeat(var(--mobile-columns), 1fr);
+ }
+}
+
+.cardSizes {
+ &--lab {
+ height: 300px;
+
+ @media (max-width: 768px) {
+ height: 215px;
+ }
+ }
+
+ &--news,
+ &--project {
+ height: 250px;
+
+ @media (max-width: 768px) {
+ height: 215px;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/widgets/CardList/CardList.module.scss b/src/widgets/CardList/CardList.module.scss
index 778cba5..01b9602 100644
--- a/src/widgets/CardList/CardList.module.scss
+++ b/src/widgets/CardList/CardList.module.scss
@@ -1,17 +1,14 @@
-.mainContainer {
- margin: 0 10%;
- @include mediaMax($mobile-xs-width) {
- margin: 0 5%;
- }
-}
+@import "@/shared/styles/cardGrid.module.scss";
+
.title {
font-size: 36px;
font-weight: 600;
line-height: 44px;
margin-top: 0;
margin-bottom: 8px;
+
@include mediaMax($tablet-max-width) {
font-size: 24px;
margin-top: 0;
}
-}
+}
\ No newline at end of file
diff --git a/src/widgets/CardList/CardList.tsx b/src/widgets/CardList/CardList.tsx
index 809ee2a..4a11929 100644
--- a/src/widgets/CardList/CardList.tsx
+++ b/src/widgets/CardList/CardList.tsx
@@ -1,5 +1,6 @@
// pages/MainPage/ui/MainPage/Lists.tsx
import { CardListTemplate } from "@/widgets/CardList/CardListTemplate";
+import { WithLoading } from "@/shared/Components/WithLoading/WithLoading";
import { GridConfig } from "@/widgets/CardList/types";
import { usePosts } from "@/modules/posts/hooks/usePosts";
import styles from "./CardList.module.scss";
@@ -20,27 +21,24 @@ const NewsList = ({
}: ListProps) => {
const { data: newsData, isLoading, isError } = useNews();
- if (isLoading)
- return (
-
-
Новости
-
-
- );
-
- if (isError) return Ошибка при загрузке данных
;
-
return (
-
- {newsData && (
-
- )}
-
+
+
+ {newsData && (
+
+ )}
+
+
);
};
@@ -50,25 +48,21 @@ const LabsList = ({
const { data: postsData, isLoading, isError } = usePosts();
const labs = postsData?.labs ? Object.values(postsData.labs) : [];
- if (isLoading)
- return (
-
-
Лаборатории
-
-
- );
-
- if (isError) return Ошибка при загрузке данных
;
-
return (
-
-
-
+
+
+
+
+
);
};
@@ -79,26 +73,22 @@ const ProjectsList = ({
const { data, isError, isLoading } = usePostProjects(tag);
const projects = data ?? [];
- if (isLoading)
- return (
-
-
Наши проекты
-
-
- );
-
- if (isError || !projects) return Ошибка при загрузке данных
;
-
return (
-
-
-
+
+
+
+
+
);
};
diff --git a/src/widgets/CardList/CardListTemplate.module.scss b/src/widgets/CardList/CardListTemplate.module.scss
index bd71488..70b2e90 100644
--- a/src/widgets/CardList/CardListTemplate.module.scss
+++ b/src/widgets/CardList/CardListTemplate.module.scss
@@ -1,36 +1,40 @@
+@import "@/shared/styles/cardGrid.module.scss";
+
.title {
font-size: 36px;
font-weight: 600;
line-height: 44px;
margin-top: 0;
margin-bottom: 8px;
+
@include mediaMax($tablet-max-width) {
font-size: 24px;
margin-top: 0;
}
}
+
.list {
- display: grid;
- gap: 2rem;
- width: 100%;
- max-width: 100%;
- box-sizing: border-box;
- //margin-bottom: 32px;
+ @extend .gridСontainer;
+
&__lab {
- grid-template-columns: repeat(var(--desktop-columns, 3), 1fr);
+ grid-template-columns: repeat(var(--desktop-columns), 1fr);
+
@include mediaMax($desktop-small-width) {
- grid-template-columns: repeat(var(--tablet-columns, 3), 1fr);
+ grid-template-columns: repeat(var(--tablet-columns), 1fr);
}
+
@include mediaMax($tablet-max-width) {
- grid-template-columns: repeat(var(--mobile-columns, 3), 1fr);
+ grid-template-columns: repeat(var(--mobile-columns), 1fr);
}
}
&__news {
grid-template-columns: repeat(var(--desktop-columns, 3), 1fr);
+
@include mediaMax($desktop-small-width) {
grid-template-columns: repeat(var(--tablet-columns, 3), 1fr);
}
+
@include mediaMax($tablet-max-width) {
grid-template-columns: repeat(var(--mobile-columns, 3), 1fr);
}
@@ -38,11 +42,13 @@
&__project {
grid-template-columns: repeat(var(--desktop-columns, 3), 1fr);
+
@include mediaMax($desktop-small-width) {
grid-template-columns: repeat(var(--tablet-columns, 3), 1fr);
}
+
@include mediaMax($tablet-max-width) {
grid-template-columns: repeat(var(--mobile-columns, 3), 1fr);
}
}
-}
+}
\ No newline at end of file
diff --git a/vite.config.ts b/vite.config.ts
index 4b3d5ee..6a4ab17 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -3,7 +3,7 @@ import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
- base: "/wp-content/reactpress/apps/skb/dist/index.html",
+ // base: "/wp-content/reactpress/apps/skb/dist/index.html",
plugins: [react()],
resolve: {
alias: {