Доработан навбар и адаптирован под мобильную версию

This commit is contained in:
mimi committed 2025-03-04 17:04:10 +03:00
1 parent e7d59c19ae
commit 402067cd3c
2 files changed
+26 -35

No files matched your search

+24 -33
View File
@@ -1,22 +1,21 @@
@import "../../assets/styles/theme.scss"; @import "../../assets/styles/theme.scss";
@import "bootstrap/scss/bootstrap"; // Подключаем Bootstrap @import "bootstrap/scss/bootstrap";
#navbar { #navbar {
position: fixed; position: fixed;
top: 0; top: 0;
width: 100vw; // 80% width: 100vw;
max-width: 100vw; // max-width: 100vw;
height: 108px; height: 108px;
padding: $navbar-padding-tb 10%; padding: $navbar-padding-tb 10%;
background-color:rgb(255, 255, 255); background-color:rgb(255, 255, 255);
z-index: 100; z-index: 100;
//transition: height .3s ease-out, background-color .3s ease-out;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
transition: transform 0.3s ease-out, height 0.3s ease-out, background-color 0.3s ease-out; transition: transform 0.3s ease-out, height 0.3s ease-out, background-color 0.8s ease-out;
&.hidden { &.hidden {
transform: translateY(-110%); // Убираем navbar вверх transform: translateY(-110%); // Убираем navbar вверх
@@ -28,32 +27,33 @@
&.transparent { &.transparent {
background-color: transparent !important; background-color: transparent !important;
transition: none;
.bar .nav-link { .bar .nav-link {
color: $text-secondary; color: $text-secondary;
} @media (max-width: 768px) {
color:black;
}
}
.logo { .logo {
filter: brightness(0) invert(1); filter: brightness(0) invert(1);
} }
} }
.nav-link:has(> .logo) { .nav-link:has(> .logo) {
display: flex; display: flex;
height: 100%; height: 100%;
align-items: center; // Центрируем элементы по высоте align-items: center;
.logo { .logo {
width: $navbar-logo-height; // 100% width: $navbar-logo-height;
height: auto; // 100% height: auto;
} }
} }
.bar { .bar {
display: flex; display: flex;
align-items: center; align-items: center;
//flex-grow: 1; // Позволяем .bar занимать доступное пространство
.nav-link { .nav-link {
font-size: 16px; font-size: 16px;
@@ -82,25 +82,25 @@
} }
.bar { .bar {
display: none; // Скрываем меню по умолчанию display: none;
flex-direction: column; // Вертикальное расположение flex-direction: column;
position: fixed; position: fixed;
top: 0; // Сдвигаем меню вниз под бургер-кнопку top: 0;
right: 0; // Выравниваем по левому краю right: 0;
background-color: white; // Фон меню background-color: white;
width: 50%; // Ширина меню равна ширине навбара width: 50%;
height: 200vh; height: 200vh;
z-index: 9; // Убедитесь, что меню выше других элементов z-index: 9;
padding: 60px 0px; padding: 60px 0px;
&.open { &.open {
display: flex; // Показываем меню при открытии display: flex;
} }
.nav-link { .nav-link {
padding: 10px 5px; // Отступы: 10px сверху и снизу, 5px слева и справа padding: 10px 5px;
width: 100%; // Занимаем всю ширину родительского элемента width: 100%;
text-align: left; // Выравнивание текста по левому краю text-align: left;
} }
} }
@@ -113,7 +113,7 @@
.line { .line {
width: 25px; width: 25px;
height: 3px; height: 3px;
background-color: black; background-color: #072ac8;
margin: 4px 0; margin: 4px 0;
transition: all 0.3s ease; transition: all 0.3s ease;
} }
@@ -122,12 +122,3 @@
} }
} }
#root:has(#mainpageheader) #navbar {
.burger .line {
background-color: $text-secondary;
}
&.transparent {}
}
+2 -2
View File
@@ -14,7 +14,7 @@ function Root() {
const [setRef, isTargetVisible] = useElementOnScreen({ const [setRef, isTargetVisible] = useElementOnScreen({
root: null, root: null,
rootMargin: '0px', rootMargin: '0px',
threshold: 0.0, threshold: 0.9,
}); });
const [isOnTopVisible, setIsOnTopVisible] = useState(false); // Состояние для видимости кнопки const [isOnTopVisible, setIsOnTopVisible] = useState(false); // Состояние для видимости кнопки
@@ -42,7 +42,7 @@ function Root() {
const handleScroll = () => { const handleScroll = () => {
const headerHeight = document.getElementById('mainpageheader')?.offsetHeight || 0; const headerHeight = document.getElementById('mainpageheader')?.offsetHeight || 0;
if (window.scrollY > headerHeight && !hasScrolled) { if (window.scrollY > headerHeight && !hasScrolled) {
setHasScrolled(true); // Обновим флаг, когда пользователь прокрутит страницу setHasScrolled(true);
} }
setIsOnTopVisible(window.scrollY > headerHeight); // Показываем кнопку setIsOnTopVisible(window.scrollY > headerHeight); // Показываем кнопку
}; };