From ce0752c7eb2f6acf6db1a5b60f42b7b33c1be867 Mon Sep 17 00:00:00 2001 From: Ifraim Solomonov Date: Mon, 4 Mar 2024 11:38:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=B8=D0=BB=20useEffect=20=D0=B8=D0=B7=20Main=20=D0=B2?= =?UTF-8?q?=20Root=20=20=D0=B8=20=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BA=D0=B0=D0=BA=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Main/Main.jsx | 31 ++++++++++------------------ src/pages/Main/Main.styles.scss | 36 +++++++++++++++++++++++++++++++++ src/pages/Root/Root.jsx | 27 ++++++++++++++++++++++--- src/pages/Root/Root.styles.scss | 31 ---------------------------- src/pages/Root/index.js | 2 +- 5 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 src/pages/Main/Main.styles.scss diff --git a/src/pages/Main/Main.jsx b/src/pages/Main/Main.jsx index 40d021b..36ccfc8 100755 --- a/src/pages/Main/Main.jsx +++ b/src/pages/Main/Main.jsx @@ -1,31 +1,22 @@ -import { useEffect } from 'react'; +import { useContext } from 'react'; import { News, Projects, Labs, Partners, Gallery, ContactUs } from './components'; -import useElementOnScreen from '../../lib/useElementOnScreen'; +import { RootContext } from '../Root'; + +import './Main.styles.scss'; function Main() { - const [containerRef, isVisible] = useElementOnScreen({ - root: null, - rootMargin: '0px', - threshold: 0, - }); - - useEffect(() => { - const [ navbar ] = document.getElementsByClassName('navbar'); - if (isVisible) { - navbar.classList.add('absolute'); - } else { - navbar.classList.remove('absolute'); - } - }, [isVisible]); + const { containerRef } = useContext(RootContext); return ( <>
-

Думай иначе, будь креативным!

-

Студенческое конструкторское бюро
- "Компьютерное инновационное творчество"

- Связаться с нами +
+

Думай иначе, будь креативным!

+

Студенческое конструкторское бюро
+ "Компьютерное инновационное творчество"

+ Связаться с нами +
diff --git a/src/pages/Main/Main.styles.scss b/src/pages/Main/Main.styles.scss new file mode 100644 index 0000000..84a7d9b --- /dev/null +++ b/src/pages/Main/Main.styles.scss @@ -0,0 +1,36 @@ +@import "../../assets/styles/theme.scss"; + +#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/Root/Root.jsx b/src/pages/Root/Root.jsx index f3d0cc9..e07af02 100755 --- a/src/pages/Root/Root.jsx +++ b/src/pages/Root/Root.jsx @@ -1,25 +1,46 @@ import { Outlet, useLoaderData } from "react-router-dom"; +import { createContext, useEffect } from 'react'; import { getContacts } 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 contacts = await getContacts(); return { contacts }; } function Root() { - const { contacts } = useLoaderData(); + + const [containerRef, isVisible] = useElementOnScreen({ + root: null, + rootMargin: '0px', + threshold: 0, + }); + + useEffect(() => { + const [navbar] = document.getElementsByClassName('navbar'); + if (isVisible) { + navbar.classList.add('absolute'); + } else { + navbar.classList.remove('absolute'); + } + }, [isVisible]); + return ( - <> +