From d154905c264af18762ec34889b7786dd2ee486ca Mon Sep 17 00:00:00 2001 From: xomimishka Date: Thu, 27 Mar 2025 12:47:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=88=D0=B8=D0=BC=D0=B5=D1=80=20=D0=B4=D0=BB=D1=8F=20=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D1=81=D1=82=D0=B8,=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=B8=D0=B8,=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Labs/LabList.jsx | 14 +++++- src/components/Labs/LabList.styles.scss | 50 +++++++++++++++---- src/components/News/News.styles.scss | 32 ++++++++++++ src/components/News/NewsList.jsx | 28 +++++++---- .../Projects/ProjectCard.styles.scss | 33 +++++++++++- src/components/Projects/ProjectList.jsx | 10 +++- 6 files changed, 145 insertions(+), 22 deletions(-) diff --git a/src/components/Labs/LabList.jsx b/src/components/Labs/LabList.jsx index f51eb31..a88cd0d 100644 --- a/src/components/Labs/LabList.jsx +++ b/src/components/Labs/LabList.jsx @@ -48,18 +48,30 @@ const mock = { function LabList() { const [labList, setLabList] = useState(mock); + const [isLoading, setIsLoading] = useState(true); useEffect(() => { const loadData = async () => { const newLabList = await getLabs(); setLabList(newLabList); + setIsLoading(false); }; loadData(); }, []); return (
- {Object.values(labList).map(lab => )} + {isLoading ? ( + // Отображаем карточки с эффектом мерцания во время загрузки + [...Array(6)].map((_, index) => ( +
+
+
+
+
+ )) + ) : ( Object.values(labList).map(lab => ) + )}
); } diff --git a/src/components/Labs/LabList.styles.scss b/src/components/Labs/LabList.styles.scss index a249f15..09d8d21 100644 --- a/src/components/Labs/LabList.styles.scss +++ b/src/components/Labs/LabList.styles.scss @@ -1,29 +1,61 @@ @import "../../assets/styles/theme.scss"; +@keyframes shimmer { + from { + transform: translateX(-200%); + } + + to { + transform: translateX(200%); + } +} + .row.lab-list { display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - /* Используем 1fr для равных колонок */ - justify-content: space-between; + grid-template-columns: repeat(3, 1fr); // Изменено на 1fr + justify-content: center; // Изменено на center gap: $row-gap; - max-width: 100%; // Гарантия, что не выйдет за границы width: 100%; - box-sizing: border-box; // Учитываем padding и border внутри ширины + box-sizing: border-box; .card { display: block; position: relative; height: 300px; border-radius: 8px; - border-width: 1px; - border-style: solid; - border-color: transparent; + border: 1px solid transparent; color: $text-secondary; - border: 1px solid transparent; + &.loading { + width: 100%; + padding: 0; + left: 12px; + .pic { + border-radius: 8px; + width: 100%; + height: 100%; + background-color: #ddd; // Серый фон заглушки + } + + .shimmer { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient(100deg, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 80%); + animation: shimmer 2s infinite linear; + } + + .image { + display: none; + /* Скрыть изображение, когда идет загрузка */ + } + } + .image { position: absolute; object-fit: cover; diff --git a/src/components/News/News.styles.scss b/src/components/News/News.styles.scss index 9b1ac53..02fd211 100644 --- a/src/components/News/News.styles.scss +++ b/src/components/News/News.styles.scss @@ -18,6 +18,29 @@ $news-card-gap: 1em; height: 215px; // Меньшая высота для мобильных } + &.loading { + .pic { + background-color: #ddd; + &::before { + background:none; + } + } + + .shimmer { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient(100deg, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 80%); + animation: shimmer 2s infinite linear; + } + + .image { + display: none; /* Скрыть изображение, когда идет загрузка */ + } + } + .pic { aspect-ratio: 1 / 1; position: relative; @@ -76,4 +99,13 @@ $news-card-gap: 1em; } } } +} + +@keyframes shimmer { + from { + transform: translateX(-200%); + } + to { + transform: translateX(200%); + } } \ No newline at end of file diff --git a/src/components/News/NewsList.jsx b/src/components/News/NewsList.jsx index e8a9df4..7caf683 100644 --- a/src/components/News/NewsList.jsx +++ b/src/components/News/NewsList.jsx @@ -1,43 +1,51 @@ import { useState, useEffect } from 'react'; - import NewsCard from './NewsCard'; - import { getNews } from '../../api'; - import './News.styles.scss'; import LoadMore from '../LoadMore'; function NewsList({ isMainPage = false }) { const [newsList, setNewsList] = useState(); const [isFullList, setIsFullList] = useState(false); + const [isLoading, setIsLoading] = useState(true); // Состояние загрузки const count = isMainPage ? 4 : 8; useEffect(() => { const loadData = async () => { + setIsLoading(true); // Начинаем загрузку const newNewsList = await getNews(count); setNewsList(newNewsList); if (newNewsList.length < count) { setIsFullList(true); } + setIsLoading(false); // Останавливаем загрузку после получения данных }; loadData(); }, []); return ( <> - {newsList ? ( + {isLoading ? ( +
+
+ {[...Array(count)].map((_, index) => ( +
+
+
+
+
+ ))} +
+
+ ) : (
{newsList.map(item => )}
- { !isMainPage && !isFullList && + {!isMainPage && !isFullList && ( - } -
- ) : ( -
- Загрузка... + )}
)} diff --git a/src/components/Projects/ProjectCard.styles.scss b/src/components/Projects/ProjectCard.styles.scss index 50d3af7..d1c5aa1 100644 --- a/src/components/Projects/ProjectCard.styles.scss +++ b/src/components/Projects/ProjectCard.styles.scss @@ -1,15 +1,46 @@ @import "../../assets/styles/theme.scss"; +@keyframes shimmer { + from { + transform: translateX(-200%); + } + + to { + transform: translateX(200%); + } +} + .project-list { .card { display: block; position: relative; height: 250px; + @media (max-width: 768px) { max-width: 100%; height: 215px; } + + &.loading { + .pic { + border-radius: 8px; + width: 100%; + height: 100%; + background-color: #ddd; + } + + .shimmer { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient(100deg, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 80%); + animation: shimmer 2s infinite linear; + } + } + border-width: 1px; border-style: solid; border-color: transparent; @@ -33,7 +64,7 @@ font-size: clamp(12px, 1.8vw, 20px); font-weight: 600; line-height: clamp(14px, 2vw, 24px); - + @media (max-width: 768px) { padding: 22px 16px; font-size: 20px; diff --git a/src/components/Projects/ProjectList.jsx b/src/components/Projects/ProjectList.jsx index baad4ee..5e6f314 100644 --- a/src/components/Projects/ProjectList.jsx +++ b/src/components/Projects/ProjectList.jsx @@ -18,7 +18,15 @@ function ProjectList({ laboratory }) { return (
- {Object.keys(projectList).map(id => )} + {Object.keys(projectList).length === 0 ? ( + [...Array(3)].map((_, index) => ( +
+
+
+ )) + ) : ( + Object.keys(projectList).map(id => ) + )}
); }