diff --git a/.vscode/launch.json b/.vscode/launch.json
index 446c5b9..f7d0565 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,10 +1,12 @@
{
"configurations": [
+
{
"type": "chrome",
"name": "http://localhost:3000/",
"request": "launch",
- "url": "http://localhost:3000/"
+ "url": "http://localhost:3000/",
+ "runtimeExecutable": "C:\\Users\\mrifr\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe"
}
]
}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 998b45d..e8f79f9 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,10 +14,12 @@
"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",
"scroll-carousel-react": "^1.0.0",
+ "use-callback-ref": "^1.3.1",
"web-vitals": "^2.1.4",
"wpapi": "^1.2.2"
}
@@ -15060,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",
@@ -17357,6 +17371,26 @@
"requires-port": "^1.0.0"
}
},
+ "node_modules/use-callback-ref": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.1.tgz",
+ "integrity": "sha512-Lg4Vx1XZQauB42Hw3kK7JM6yjVjgFmFC5/Ab797s79aARomD2nEErc4mCgM8EZrARLmmbWpi5DGCadmK50DcAQ==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "peerDependencies": {
+ "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0",
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
diff --git a/package.json b/package.json
index 85aa886..aa1b4e1 100755
--- a/package.json
+++ b/package.json
@@ -9,10 +9,12 @@
"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",
"scroll-carousel-react": "^1.0.0",
+ "use-callback-ref": "^1.3.1",
"web-vitals": "^2.1.4",
"wpapi": "^1.2.2"
},
diff --git a/src/assets/styles/global.scss b/src/assets/styles/global.scss
index ba7ec0b..5caa9ee 100644
--- a/src/assets/styles/global.scss
+++ b/src/assets/styles/global.scss
@@ -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 {
diff --git a/src/assets/styles/theme.scss b/src/assets/styles/theme.scss
index 7d1cd8d..0ae58f3 100644
--- a/src/assets/styles/theme.scss
+++ b/src/assets/styles/theme.scss
@@ -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);
\ No newline at end of file
+$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;
\ No newline at end of file
diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx
index 69deed2..54f5ff8 100755
--- a/src/components/Navbar/Navbar.jsx
+++ b/src/components/Navbar/Navbar.jsx
@@ -1,6 +1,6 @@
-import { scb as logo } from '../../assets/images';
-import { NavLink } from "react-router-dom";
import NavbarLink from './NavbarLink';
+
+import { scb as logo } from '../../assets/images';
import './Navbar.styles.scss';
const mock = [
@@ -33,11 +33,9 @@ const mock = [
function Navbar({ links = mock }) {
return (
-
-
-
-

-
+
+
+
{links.map((link, index) =>
)}
diff --git a/src/components/Navbar/Navbar.styles.scss b/src/components/Navbar/Navbar.styles.scss
index 5c1bd01..02919eb 100755
--- a/src/components/Navbar/Navbar.styles.scss
+++ b/src/components/Navbar/Navbar.styles.scss
@@ -1,20 +1,20 @@
@import "../../assets/styles/theme.scss";
-.navbar {
- position: absolute;
+#navbar {
+ position: fixed;
top: 0;
width: 80%;
- height: 60px;
- max-height: 80px;
- padding: 1em 10%;
- background: transparent;
- 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 {
@@ -43,4 +43,8 @@
background: $text-secondary;
}
}
+}
+
+#navbar.transparent{
+ background-color: transparent;
}
\ No newline at end of file
diff --git a/src/lib/useElementOnScreen.js b/src/lib/useElementOnScreen.js
new file mode 100644
index 0000000..08ba11b
--- /dev/null
+++ b/src/lib/useElementOnScreen.js
@@ -0,0 +1,30 @@
+import { useEffect, useState } from "react";
+
+const useElementOnScreen = (options) => {
+
+ const [ref, setRef] = useState(null);
+ const [isVisible, setIsVisible] = useState(false);
+
+ const observerCallback = (entries) => {
+ const [entry] = entries;
+ setIsVisible(entry.isIntersecting);
+ };
+
+ useEffect(() => {
+ const observer = new IntersectionObserver(observerCallback, options);
+
+ if (ref) {
+ observer.observe(ref);
+ }
+
+ return () => {
+ if (ref) {
+ observer.unobserve(ref);
+ }
+ }
+ }, [ref, options]);
+
+ return [setRef, isVisible];
+}
+
+export default useElementOnScreen;
\ No newline at end of file
diff --git a/src/pages/Main/Main.jsx b/src/pages/Main/Main.jsx
index 82b017b..38a3b55 100755
--- a/src/pages/Main/Main.jsx
+++ b/src/pages/Main/Main.jsx
@@ -1,13 +1,32 @@
+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';
+
+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 (
<>
-
- Думай иначе, будь креативным!
- Студенческое конструкторское бюро
- "Компьютерное инновационное творчество"
- Связаться с нами
+ setRef(element)}>
+
+
Думай иначе, будь креативным!
+ Студенческое конструкторское бюро
+ "Компьютерное инновационное творчество"
+ Связаться с нами
+
diff --git a/src/pages/Main/Main.styles.scss b/src/pages/Main/Main.styles.scss
new file mode 100644
index 0000000..323bab0
--- /dev/null
+++ b/src/pages/Main/Main.styles.scss
@@ -0,0 +1,40 @@
+@import "../../assets/styles/theme.scss";
+
+#page:has(> #mainpageheader) {
+ margin-top: 0;
+
+ #mainpageheader {
+ position: relative;
+
+ height: 100vh;
+ padding: 0 10%;
+
+ color: $text-secondary;
+ background-image: url(/assets/images/car.jpeg);
+ background-color: $bg-image;
+ background-blend-mode: multiply;
+ background-position: center;
+ background-size: cover;
+
+ .container {
+ position: absolute;
+ top: 40%;
+ display: flex;
+ flex-direction: column;
+
+
+ h1 {
+ font-size: 60px;
+ font-weight: 600;
+ line-height: 63px;
+ margin: 0;
+ }
+
+ h2 {
+ font-size: 24px;
+ font-weight: 400;
+ line-height: 36px;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/pages/Main/components/ContactUs/ContactUs.jsx b/src/pages/Main/components/ContactUs/ContactUs.jsx
index f7d71ca..7611135 100755
--- a/src/pages/Main/components/ContactUs/ContactUs.jsx
+++ b/src/pages/Main/components/ContactUs/ContactUs.jsx
@@ -4,7 +4,7 @@ import './ContactUs.styles.scss';
function ContactUs() {
return (
-
+
Нужна помощь?
Команда способных IT-специалистов готова вам помочь!
diff --git a/src/pages/Main/components/ContactUs/ContactUs.styles.scss b/src/pages/Main/components/ContactUs/ContactUs.styles.scss
index 7fff3a6..9b38d60 100644
--- a/src/pages/Main/components/ContactUs/ContactUs.styles.scss
+++ b/src/pages/Main/components/ContactUs/ContactUs.styles.scss
@@ -1,10 +1,14 @@
-.contact-us {
+#contact-us {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 60px;
.half {
- flex: 1 1 50%;
+ flex: 0 0 50%;
+ }
+
+ .contact-form {
+ max-width: 500px;
}
}
\ No newline at end of file
diff --git a/src/pages/Main/components/Gallery/Gallery.styles.scss b/src/pages/Main/components/Gallery/Gallery.styles.scss
index dcdcaf9..54bb4d4 100644
--- a/src/pages/Main/components/Gallery/Gallery.styles.scss
+++ b/src/pages/Main/components/Gallery/Gallery.styles.scss
@@ -1,4 +1,4 @@
-#page .content .gallery {
+#page .content #gallery {
margin-left: 0;
margin-right: 0;
diff --git a/src/pages/Main/components/Labs/Labs.jsx b/src/pages/Main/components/Labs/Labs.jsx
index e66e85d..c2ef2f5 100755
--- a/src/pages/Main/components/Labs/Labs.jsx
+++ b/src/pages/Main/components/Labs/Labs.jsx
@@ -51,7 +51,7 @@ const mock = [
function Labs({ labs = mock }) {
return (
-
+
{ labs.map( lab =>
) }
diff --git a/src/pages/Main/components/Labs/Labs.styles.scss b/src/pages/Main/components/Labs/Labs.styles.scss
index 9301c63..0bae36c 100755
--- a/src/pages/Main/components/Labs/Labs.styles.scss
+++ b/src/pages/Main/components/Labs/Labs.styles.scss
@@ -1,6 +1,6 @@
@import "../../../../assets/styles/theme.scss";
-.labs {
+#labs {
.row {
display: flex;
flex-wrap: wrap;
diff --git a/src/pages/Main/components/News/News.jsx b/src/pages/Main/components/News/News.jsx
index a52a3ac..492b275 100755
--- a/src/pages/Main/components/News/News.jsx
+++ b/src/pages/Main/components/News/News.jsx
@@ -29,7 +29,7 @@ const mock = [
function News({ news = mock }) {
return (
-
+
{ news.map(item =>
) }
diff --git a/src/pages/Main/components/News/News.styles.scss b/src/pages/Main/components/News/News.styles.scss
index bf5d939..cd9dbde 100755
--- a/src/pages/Main/components/News/News.styles.scss
+++ b/src/pages/Main/components/News/News.styles.scss
@@ -1,4 +1,4 @@
-.news {
+#news {
.row {
display: flex;
justify-content: space-between;
diff --git a/src/pages/Main/components/Partners/Partners.jsx b/src/pages/Main/components/Partners/Partners.jsx
index 1b2f3c3..a06bd84 100755
--- a/src/pages/Main/components/Partners/Partners.jsx
+++ b/src/pages/Main/components/Partners/Partners.jsx
@@ -43,7 +43,7 @@ const mock = [
function Partners({ partners = mock }) {
return (
-
+
+
{projects.map(item =>
)}
diff --git a/src/pages/Main/components/Projects/Projects.styles.scss b/src/pages/Main/components/Projects/Projects.styles.scss
index 14d2be4..18d19a2 100755
--- a/src/pages/Main/components/Projects/Projects.styles.scss
+++ b/src/pages/Main/components/Projects/Projects.styles.scss
@@ -1,6 +1,6 @@
@import "../../../../assets/styles/theme.scss";
-.projects {
+#projects {
.row {
display: flex;
diff --git a/src/pages/Root/Root.jsx b/src/pages/Root/Root.jsx
index d7abecb..fab2288 100755
--- a/src/pages/Root/Root.jsx
+++ b/src/pages/Root/Root.jsx
@@ -1,24 +1,45 @@
import { Outlet } from "react-router-dom";
+import { createContext, useEffect } from 'react';
import { getMedia } from "../../api";
+import useElementOnScreen from '../../lib/useElementOnScreen';
import Navbar from '../../components/Navbar';
import Footer from "../../components/Footer";
import './Root.styles.scss';
+export const RootContext = createContext();
+
async function loader() {
const media = getMedia();
return { media };
}
function Root() {
+ const [setRef, isVisible] = useElementOnScreen({
+ root: null,
+ rootMargin: '0px',
+ threshold: 0.6,
+ });
+
+ useEffect(() => {
+ const navbar = document.getElementById('navbar');
+ if (isVisible) {
+ navbar.classList.add('transparent');
+ } else {
+ navbar.classList.remove('transparent');
+ }
+ }, [isVisible]);
+
return (
- <>
+
- >
+
);
}
diff --git a/src/pages/Root/Root.styles.scss b/src/pages/Root/Root.styles.scss
index 2ca7c72..db85967 100755
--- a/src/pages/Root/Root.styles.scss
+++ b/src/pages/Root/Root.styles.scss
@@ -1,36 +1,7 @@
@import "../../assets/styles/theme.scss";
#page {
-
- .header {
- height: 100vh;
- padding: 0 10%;
-
- display: flex;
- flex-direction: column;
-
- color: $text-secondary;
- background-image: url(/assets/images/car.jpeg);
- background-color: $bg-image;
- background-blend-mode: multiply;
- background-position: center;
- background-size: cover;
-
- h1 {
- font-size: 60px;
- font-weight: 600;
- line-height: 63px;
-
- margin-top: 40vh;
- margin-bottom: 0;
- }
-
- h2 {
- font-size: 24px;
- font-weight: 400;
- line-height: 36px;
- }
- }
+ margin-top: calc($navbar-height + 3 * $navbar-padding-tb);
.content {
background: $bg-primary;
@@ -65,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%;
@@ -87,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%;
}
\ No newline at end of file
diff --git a/src/pages/Root/index.js b/src/pages/Root/index.js
index 08297f1..f2c23ae 100755
--- a/src/pages/Root/index.js
+++ b/src/pages/Root/index.js
@@ -1 +1 @@
-export { default as Root, loader } from './Root';
\ No newline at end of file
+export { default as Root, RootContext, loader } from './Root';
\ No newline at end of file