mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:59:45 +00:00
Анимация навбара
This commit is contained in:
1 parent
29c213578e
commit
2fe8bc2cd9
22 files changed
+78
-49
No files matched your search
Generated
+13
@@ -14,6 +14,7 @@
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.22.0",
|
||||
"react-router-hash-link": "^2.4.3",
|
||||
"react-scripts": "5.0.1",
|
||||
"reactpress": "^1.0.0",
|
||||
"sass": "^1.70.0",
|
||||
@@ -15061,6 +15062,18 @@
|
||||
"react-dom": ">=16.8"
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-hash-link": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "https://registry.npmjs.org/react-router-hash-link/-/react-router-hash-link-2.4.3.tgz",
|
||||
"integrity": "sha512-NU7GWc265m92xh/aYD79Vr1W+zAIXDWp3L2YZOYP4rCqPnJ6LI6vh3+rKgkidtYijozHclaEQTAHaAaMWPVI4A==",
|
||||
"dependencies": {
|
||||
"prop-types": "^15.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=15",
|
||||
"react-router-dom": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/react-scripts": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.22.0",
|
||||
"react-router-hash-link": "^2.4.3",
|
||||
"react-scripts": "5.0.1",
|
||||
"reactpress": "^1.0.0",
|
||||
"sass": "^1.70.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@import "../../assets/styles/theme.scss";
|
||||
@import "./theme.scss";
|
||||
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');
|
||||
|
||||
input {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//Цвета
|
||||
$bg-primary: white;
|
||||
$bg-secondary: #343434;
|
||||
$bg-footer: #222222;
|
||||
@@ -13,5 +14,9 @@ $text-card-project-bg: rgba(255, 255, 255, 0.75);
|
||||
$shadow-primary: rgba(0, 0, 0, 0.25);
|
||||
|
||||
$btn-primary-text: white;
|
||||
$btn-primary-bg: linear-gradient(93.25deg, #4942E4 0%, #11009E 50%, #4942E4 100%),
|
||||
linear-gradient(0deg, #585858, #585858);
|
||||
$btn-primary-bg: linear-gradient(93.25deg, #4942E4 0%, #11009E 50%, #4942E4 100%), linear-gradient(0deg, #585858, #585858);
|
||||
|
||||
// Размеры
|
||||
$navbar-height: 60px;
|
||||
$navbar-height-mini: 30px;
|
||||
$navbar-padding-tb: 10px;
|
||||
@@ -33,11 +33,9 @@ const mock = [
|
||||
|
||||
function Navbar({ links = mock }) {
|
||||
return (
|
||||
<div className="navbar">
|
||||
<NavbarLink link={{ to: "/" }} >
|
||||
<div className="logo-container">
|
||||
<div id="navbar">
|
||||
<NavbarLink className="logo-container" link={{ to: "/" }} >
|
||||
<img src={logo} className="logo" alt="SCB logo" />
|
||||
</div>
|
||||
</NavbarLink>
|
||||
<div className="bar">
|
||||
{links.map(link => <NavbarLink link={link} />)}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
@import "../../assets/styles/theme.scss";
|
||||
|
||||
.navbar {
|
||||
#navbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 80%;
|
||||
height: 60px;
|
||||
max-height: 80px;
|
||||
padding: 1em 10%;
|
||||
background: $bg-secondary;
|
||||
z-index: 1;
|
||||
height: $navbar-height;
|
||||
padding: $navbar-padding-tb 10%;
|
||||
background-color: $bg-secondary;
|
||||
z-index: 10;
|
||||
transition: height .3s ease-out, background-color .3s ease-out;
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.logo-container {
|
||||
.nav-link:has(> .logo) {
|
||||
height: 100%;
|
||||
|
||||
.logo {
|
||||
@@ -45,7 +45,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
.navbar.absolute {
|
||||
position: absolute;
|
||||
background: transparent;
|
||||
#navbar.transparent{
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
// #navbar.mini {
|
||||
// height: $navbar-height-mini;
|
||||
|
||||
// .nav-link:has(> .logo) {
|
||||
// height: 130%;
|
||||
// }
|
||||
// }
|
||||
+11
-1
@@ -1,4 +1,5 @@
|
||||
import { useContext, useEffect } from 'react';
|
||||
import { HashLink } from 'react-router-hash-link';
|
||||
|
||||
import { News, Projects, Labs, Partners, Gallery, ContactUs } from './components';
|
||||
import { RootContext } from '../Root';
|
||||
@@ -8,6 +9,15 @@ import './Main.styles.scss';
|
||||
function Main() {
|
||||
const { setRef } = useContext(RootContext);
|
||||
|
||||
useEffect(() => {
|
||||
const navbar = document.getElementById("navbar");
|
||||
navbar.classList.add('transparent'); // Mount
|
||||
|
||||
return () => {
|
||||
navbar.classList.remove('transparent'); // Unmount
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<header id="mainpageheader" ref={element => setRef(element)}>
|
||||
@@ -15,7 +25,7 @@ function Main() {
|
||||
<h1>Думай иначе, будь креативным!</h1>
|
||||
<h2>Студенческое конструкторское бюро<br />
|
||||
"Компьютерное инновационное творчество"</h2>
|
||||
<a className="btn" href="">Связаться с нами</a>
|
||||
<HashLink smooth to="#contact-us" className="btn">Связаться с нами</HashLink>
|
||||
</div>
|
||||
</header>
|
||||
<div className="content">
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
@import "../../assets/styles/theme.scss";
|
||||
|
||||
#page:has(> #mainpageheader) {
|
||||
margin-top: 0;
|
||||
|
||||
#mainpageheader {
|
||||
position: relative;
|
||||
|
||||
@@ -34,3 +37,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import './ContactUs.styles.scss';
|
||||
|
||||
function ContactUs() {
|
||||
return (
|
||||
<div className="block contact-us">
|
||||
<div className="block" id="contact-us">
|
||||
<h1 className="half">Нужна помощь?<br/> Команда способных IT-специалистов готова вам помочь!</h1>
|
||||
<ContactForm />
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.contact-us {
|
||||
#contact-us {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
|
||||
@@ -4,7 +4,7 @@ import './Gallery.styles.scss';
|
||||
|
||||
function Gallery() {
|
||||
return (
|
||||
<div className="block gallery">
|
||||
<div className="block" id="gallery">
|
||||
<h1>СКБ «КИТ» - реальные технологические проекты<br/>
|
||||
под руководством наставников<br/>
|
||||
из университета и бизнеса.</h1>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#page .content .gallery {
|
||||
#page .content #gallery {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ const mock = [
|
||||
|
||||
function Labs({ labs = mock }) {
|
||||
return (
|
||||
<div className="block labs">
|
||||
<div className="block" id="labs">
|
||||
<BlockHeading heading="Наши лаборатории" />
|
||||
<div className="row">
|
||||
{ labs.map( lab => <LabCard key={ lab.id } lab={ lab } />) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@import "../../../../assets/styles/theme.scss";
|
||||
|
||||
.labs {
|
||||
#labs {
|
||||
.row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
@@ -29,7 +29,7 @@ const mock = [
|
||||
function News({ news = mock }) {
|
||||
|
||||
return (
|
||||
<div className="block news">
|
||||
<div className="block" id="news">
|
||||
<BlockHeading heading='Новости' linkText='Все новости' link='https://vk.com/skbkit' />
|
||||
<div className="row">
|
||||
{ news.map(item => <NewsCard key={ item.id } news={ item } />) }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.news {
|
||||
#news {
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -43,7 +43,7 @@ const mock = [
|
||||
|
||||
function Partners({ partners = mock }) {
|
||||
return (
|
||||
<div className="block partners">
|
||||
<div className="block" id="partners">
|
||||
<BlockHeading heading="Наши партнеры" />
|
||||
<ScrollCarousel
|
||||
autoplay
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#page .content .partners {
|
||||
#page .content #partners {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ const mock = [
|
||||
|
||||
function Projects({ projects = mock }) {
|
||||
return (
|
||||
<div className="block projects">
|
||||
<div className="block" id="projects">
|
||||
<BlockHeading heading="Наши проекты" linkText="Все проекты" link="/projects" />
|
||||
<div className="row">
|
||||
{projects.map(item => <ProjectCard key={ item.id } project={item} />)}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@import "../../../../assets/styles/theme.scss";
|
||||
|
||||
.projects {
|
||||
#projects {
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
|
||||
+4
-15
@@ -15,29 +15,18 @@ async function loader() {
|
||||
}
|
||||
|
||||
function Root() {
|
||||
const currentRoot = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
const [navbar] = document.getElementsByClassName('navbar');
|
||||
if (currentRoot.pathname !== '/') {
|
||||
navbar.classList.remove('absolute');
|
||||
} else {
|
||||
navbar.classList.add('absolute');
|
||||
}
|
||||
}, [currentRoot]);
|
||||
|
||||
const [setRef, isVisible] = useElementOnScreen({
|
||||
root: null,
|
||||
rootMargin: '0px',
|
||||
threshold: 0,
|
||||
threshold: 0.6,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const [navbar] = document.getElementsByClassName('navbar');
|
||||
const navbar = document.getElementById('navbar');
|
||||
if (isVisible) {
|
||||
navbar.classList.add('absolute');
|
||||
navbar.classList.add('transparent');
|
||||
} else {
|
||||
navbar.classList.remove('absolute');
|
||||
navbar.classList.remove('transparent');
|
||||
}
|
||||
}, [isVisible]);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@import "../../assets/styles/theme.scss";
|
||||
|
||||
#page {
|
||||
margin-top: calc($navbar-height + 3 * $navbar-padding-tb);
|
||||
|
||||
.content {
|
||||
background: $bg-primary;
|
||||
|
||||
@@ -34,12 +36,12 @@
|
||||
}
|
||||
|
||||
.block .heading a,
|
||||
.navbar .nav-link {
|
||||
#navbar .nav-link {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.block .heading a::after,
|
||||
.navbar .nav-link::after {
|
||||
#navbar .nav-link::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
left: 50%;
|
||||
@@ -56,7 +58,7 @@
|
||||
}
|
||||
|
||||
.block .heading a:hover:after,
|
||||
.navbar .nav-link:hover:after,
|
||||
.navbar .nav-link.active:after {
|
||||
#navbar .nav-link:hover:after,
|
||||
#navbar .nav-link.active:after {
|
||||
width: 100%;
|
||||
}
|
||||
Reference in new issue
Block a user