From e54e2f1ae90d2381ff231f61265cdaaa54ba75a7 Mon Sep 17 00:00:00 2001 From: xomimishka Date: Fri, 11 Jul 2025 11:30:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BE=D0=B2=D1=8B=D1=87=D0=BA=D0=B8=20=D0=B8=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=20=D1=81=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=B0=20=D1=81?= =?UTF-8?q?=D1=82=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/NewsItem/NewsItem.styles.scss | 29 +++++++++++++++++++- src/pages/NewsItem/NewsItem.tsx | 36 +++++++++++++++++++------ 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/pages/NewsItem/NewsItem.styles.scss b/src/pages/NewsItem/NewsItem.styles.scss index d26b265..6e6075c 100644 --- a/src/pages/NewsItem/NewsItem.styles.scss +++ b/src/pages/NewsItem/NewsItem.styles.scss @@ -3,7 +3,7 @@ justify-content: space-between; margin-top: 2em; - > * { + >* { display: inline-block; width: fit-content; } @@ -29,3 +29,30 @@ } } } + +#news-item-page { + .single-image-container { + height: 600px; + display: flex; + justify-content: center; + align-items: center; + margin-bottom: 20px; + + img { + max-height: 100%; + width: auto; + max-width: 100%; + object-fit: contain; + pointer-events: none; + } + + @media (max-width: 768px) { + height: auto; + img { + width: 100%; + height: auto; + object-fit: contain; + } + } + } +} diff --git a/src/pages/NewsItem/NewsItem.tsx b/src/pages/NewsItem/NewsItem.tsx index 674fe96..544dbf9 100644 --- a/src/pages/NewsItem/NewsItem.tsx +++ b/src/pages/NewsItem/NewsItem.tsx @@ -10,6 +10,18 @@ import { useNewsById } from "@/modules/news/hooks/useNewsById"; import { PageContent, PageHeader } from "@/widgets/WpPost"; import Slider from "@/widgets/Slider/Slider"; export const vkWallUrl = "https://vk.com/skbkit?w=wall-172789021"; +import { useEffect } from "react"; +import { useLocation } from "react-router-dom"; + +export const ScrollToTop = () => { + const { pathname } = useLocation(); + + useEffect(() => { + window.scrollTo({ top: 0, left: 0, behavior: "instant" }); + }, [pathname]); + + return null; +}; function NewsItem() { const params = useParams(); @@ -28,6 +40,7 @@ function NewsItem() { if (isLoading) return (
+ {[...Array(1)].map((_, index) => ( ))} @@ -38,8 +51,8 @@ function NewsItem() { <> - Ошибка загрузки новости | СКБ "Компьютерное инновационное - творчество" + Ошибка загрузки новости | СКБ «Компьютерное инновационное + творчество» @@ -55,8 +68,8 @@ function NewsItem() { <> - {news.heading || "Новость"} | СКБ "Компьютерное инновационное - творчество" + {news.heading || "Новость"} | СКБ «Компьютерное инновационное + творчество» @@ -77,7 +89,15 @@ function NewsItem() {

{news.heading}

- {news.photos.length !== 0 && } + {news.photos.length !== 0 && + (news.photos.length === 1 ? ( +
+ {news.heading} +
+ ) : ( + + )) + } {news.text.map((textRow, index) => (

))}