mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 04:49:45 +00:00
перенес структуру Севы со своими правками
This commit is contained in:
1 parent
3a1cac0dfe
commit
808d97eb4b
331 files changed
+12260
-19950
No files matched your search
@@ -0,0 +1,161 @@
|
||||
// Общий стиль
|
||||
#root {
|
||||
position: relative; // Убедитесь, что #root имеет relative
|
||||
background-repeat: no-repeat;
|
||||
background-position: center bottom;
|
||||
background-image: url("/assets/images/backround/bg_footer_02.svg");
|
||||
background-size: 100% auto;
|
||||
z-index: 0; // Задний план
|
||||
opacity: 0; // Сделаем #root видимым сразу
|
||||
min-height: 100vh; // Устанавливаем минимальную высоту для #root
|
||||
|
||||
// Псевдоэлемент для фона в верхней части страницы
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 160px;
|
||||
left: 0; // Слева
|
||||
width: 100%; // На всю ширину
|
||||
height: 364px; // Ограничиваем максимальную высоту
|
||||
background-image: url("../../assets/images/backround/bg_news_block.svg"); // Картинка
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
background-size: contain;
|
||||
z-index: -1; // Картинка на заднем плане, за остальными элементами
|
||||
|
||||
@media (max-width: 768px) {
|
||||
display: none; // Прячем картинку на мобильных устройствах
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Для главной страницы
|
||||
#root:has(> #react-page #mainpageheader) {
|
||||
background-image: url("/assets/images/backround/bg_footer.svg");
|
||||
&::before {
|
||||
background-image: none;
|
||||
}
|
||||
}
|
||||
#react-page:has(> #mainpageheader) {
|
||||
margin-top: 0;
|
||||
}
|
||||
.page-loaded #root {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
#react-page {
|
||||
margin-top: calc($navbar-height + 5 * $navbar-padding-tb);
|
||||
|
||||
.header,
|
||||
.content {
|
||||
margin-left: 10%;
|
||||
margin-right: 10%;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
background: $bg-primary;
|
||||
//padding: 0 1em;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
//box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.block .heading a,
|
||||
#navbar .nav-link {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.block .heading a::after,
|
||||
#navbar .nav-link::after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
bottom: 0;
|
||||
display: block;
|
||||
width: 0;
|
||||
height: 1px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.block .heading a::after {
|
||||
background: $text-primary;
|
||||
}
|
||||
|
||||
.block .heading a:hover:after,
|
||||
#navbar .nav-link:hover:after,
|
||||
#navbar .nav-link.active:after {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.scroll-to-top {
|
||||
position: fixed;
|
||||
right: 2vw; // Используем vw для адаптивности
|
||||
bottom: 7.5vh; // Используем vh для адаптивности
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
width: 61px;
|
||||
height: 61px;
|
||||
z-index: 10;
|
||||
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
animation: scaleIn 0.5s forwards; /* Анимация появления */
|
||||
box-shadow: 5px 6px 15px rgba(0, 0, 0, 0.05);
|
||||
&.visible {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
box-shadow: 5px 6px 15px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&.hidden {
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
animation: scaleOut 0.5s forwards; /* Анимация исчезновения */
|
||||
}
|
||||
|
||||
img {
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* Анимация для появления кнопки */
|
||||
@keyframes scaleIn {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Анимация для исчезновения кнопки */
|
||||
@keyframes scaleOut {
|
||||
0% {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.scroll-to-top {
|
||||
display: none; // Скрыть кнопку на мобильных устройствах
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { Outlet, useLocation } from "react-router-dom";
|
||||
import { createContext, useEffect, useState } from "react";
|
||||
|
||||
import "./Root.styles.scss";
|
||||
|
||||
import up from "@/shared/assets/images/up.svg";
|
||||
import useElementOnScreen from "@/shared/lib/ElementOnScreen/ElementOnScreen";
|
||||
import Navbar from "@/widgets/Navbar";
|
||||
import Footer from "@/widgets/Footer";
|
||||
|
||||
// Тип для контекста
|
||||
interface RootContextType {
|
||||
setRef: (element: HTMLElement | null) => void;
|
||||
}
|
||||
|
||||
// Создаем контекст с типом
|
||||
export const RootContext = createContext<RootContextType>({ setRef: () => {} });
|
||||
|
||||
function Root() {
|
||||
const location = useLocation(); // Хук для получения текущего пути
|
||||
const [setRef, isTargetVisible] = useElementOnScreen({
|
||||
root: null,
|
||||
rootMargin: "0px",
|
||||
threshold: 0.9,
|
||||
});
|
||||
|
||||
const [isOnTopVisible, setIsOnTopVisible] = useState<boolean>(false); // Состояние для видимости кнопки
|
||||
const [hasScrolled, setHasScrolled] = useState<boolean>(false); // Флаг для отслеживания прокрутки
|
||||
|
||||
// Для навбара
|
||||
useEffect(() => {
|
||||
const navbar = document.getElementById("navbar");
|
||||
if (navbar) {
|
||||
if (isTargetVisible) {
|
||||
navbar.classList.add("transparent");
|
||||
} else {
|
||||
navbar.classList.remove("transparent");
|
||||
}
|
||||
}
|
||||
}, [isTargetVisible]);
|
||||
|
||||
// Для кнопки OnTop
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
document.body.classList.add("page-loaded");
|
||||
}, 100); // Небольшая задержка, чтобы избежать мерцания
|
||||
|
||||
const handleScroll = () => {
|
||||
const headerHeight =
|
||||
document.getElementById("mainpageheader")?.offsetHeight || 0;
|
||||
if (window.scrollY > headerHeight && !hasScrolled) {
|
||||
setHasScrolled(true);
|
||||
}
|
||||
setIsOnTopVisible(window.scrollY > headerHeight); // Показываем кнопку
|
||||
};
|
||||
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
return () => {
|
||||
window.removeEventListener("scroll", handleScroll);
|
||||
};
|
||||
}, [hasScrolled]);
|
||||
|
||||
// Ускоренный плавный скролл вверх
|
||||
const scrollToTop = () => {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: "smooth",
|
||||
});
|
||||
};
|
||||
|
||||
// Определяем, находимся ли мы на главной странице
|
||||
const isHomePage = location.pathname === "/";
|
||||
|
||||
return (
|
||||
<RootContext.Provider value={{ setRef }}>
|
||||
<Navbar />
|
||||
<div
|
||||
id="react-page"
|
||||
style={{ marginTop: isHomePage ? "0px" : "" }} // Устанавливаем margin-top
|
||||
>
|
||||
<Outlet />
|
||||
</div>
|
||||
<Footer />
|
||||
{hasScrolled && (
|
||||
<button
|
||||
className={`scroll-to-top ${isOnTopVisible ? "visible" : "hidden"}`}
|
||||
onClick={scrollToTop}
|
||||
>
|
||||
<img src={up} alt="Scroll to top" />
|
||||
</button>
|
||||
)}
|
||||
</RootContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export default Root;
|
||||
Reference in new issue
Block a user