mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:59:45 +00:00
31 files changed
+304
-123
No files matched your search
@@ -21,3 +21,6 @@
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
#copies
|
||||||
|
*.copy
|
||||||
Vendored
+3
-1
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
"name": "http://localhost:3000/",
|
"name": "http://localhost:3000/",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"url": "http://localhost:3000/"
|
"url": "http://localhost:3000/",
|
||||||
|
"runtimeExecutable": "C:\\Users\\mrifr\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Generated
+34
@@ -14,10 +14,12 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-router-dom": "^6.22.0",
|
"react-router-dom": "^6.22.0",
|
||||||
|
"react-router-hash-link": "^2.4.3",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"reactpress": "^1.0.0",
|
"reactpress": "^1.0.0",
|
||||||
"sass": "^1.70.0",
|
"sass": "^1.70.0",
|
||||||
"scroll-carousel-react": "^1.0.0",
|
"scroll-carousel-react": "^1.0.0",
|
||||||
|
"use-callback-ref": "^1.3.1",
|
||||||
"web-vitals": "^2.1.4",
|
"web-vitals": "^2.1.4",
|
||||||
"wpapi": "^1.2.2"
|
"wpapi": "^1.2.2"
|
||||||
}
|
}
|
||||||
@@ -15060,6 +15062,18 @@
|
|||||||
"react-dom": ">=16.8"
|
"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": {
|
"node_modules/react-scripts": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz",
|
||||||
@@ -17357,6 +17371,26 @@
|
|||||||
"requires-port": "^1.0.0"
|
"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": {
|
"node_modules/util-deprecate": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
|
|||||||
+3
-1
@@ -9,16 +9,18 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-router-dom": "^6.22.0",
|
"react-router-dom": "^6.22.0",
|
||||||
|
"react-router-hash-link": "^2.4.3",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"reactpress": "^1.0.0",
|
"reactpress": "^1.0.0",
|
||||||
"sass": "^1.70.0",
|
"sass": "^1.70.0",
|
||||||
"scroll-carousel-react": "^1.0.0",
|
"scroll-carousel-react": "^1.0.0",
|
||||||
|
"use-callback-ref": "^1.3.1",
|
||||||
"web-vitals": "^2.1.4",
|
"web-vitals": "^2.1.4",
|
||||||
"wpapi": "^1.2.2"
|
"wpapi": "^1.2.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "PUBLIC_URL=/wp-content/reactpress/apps/skb/build react-scripts build",
|
"build": "set PUBLIC_URL=/wp-content/reactpress/apps/skb/build&&react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
},
|
},
|
||||||
|
|||||||
+46
-13
@@ -2,30 +2,63 @@ import * as WPAPI from 'wpapi';
|
|||||||
|
|
||||||
import reactPress from './reactPress';
|
import reactPress from './reactPress';
|
||||||
|
|
||||||
import { g1, g2, g3 } from './assets/images/gallery';
|
|
||||||
|
|
||||||
const wp = new WPAPI(
|
const wp = new WPAPI(
|
||||||
process.env.NODE_ENV === 'development'
|
process.env.NODE_ENV === 'development'
|
||||||
? {
|
? {
|
||||||
endpoint: reactPress.api.rest_url,
|
endpoint: reactPress.api.rest_url,
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: 'testapi',
|
password: 'admin',
|
||||||
}
|
}
|
||||||
: { endpoint: reactPress.api.rest_url, nonce: reactPress.api.nonce }
|
: { endpoint: reactPress.api.rest_url, nonce: reactPress.api.nonce }
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function getContacts(q = '') {
|
// Функция загрузки медабиблиотеки по категориям
|
||||||
|
async function loadMedia() {
|
||||||
|
// Пытаемся получить медиа, пока не получится
|
||||||
|
let response;
|
||||||
|
while (!response) {
|
||||||
|
try {
|
||||||
|
response = await wp.media();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Нам потребуется id, категория и url
|
||||||
|
const result = {};
|
||||||
|
for (let { id, alt_text, source_url: url } of response) {
|
||||||
|
const [category, name] = alt_text.split('_');
|
||||||
|
|
||||||
|
// Создаем ключ с пустым массивом, если еще нет
|
||||||
|
if (!result[category]) {
|
||||||
|
result[category] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Добавляем медиа в массив нужной категории
|
||||||
|
result[category].push({ id, name, url });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mediaLibrary = await loadMedia();
|
||||||
|
console.log(mediaLibrary);
|
||||||
|
|
||||||
|
export async function getPosts(q = '') {
|
||||||
try {
|
try {
|
||||||
const users = await wp.users().search(q);
|
const posts = await wp.posts().search(q);
|
||||||
return users;
|
return posts;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSliderImages() {
|
export async function getMedia(category) {
|
||||||
const mock = [ g1, g2, g3 ];
|
try {
|
||||||
|
return mediaLibrary[category];
|
||||||
return mock;
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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');
|
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');
|
||||||
|
|
||||||
input {
|
input {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//Цвета
|
||||||
$bg-primary: white;
|
$bg-primary: white;
|
||||||
$bg-secondary: #343434;
|
$bg-secondary: #343434;
|
||||||
$bg-footer: #222222;
|
$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);
|
$shadow-primary: rgba(0, 0, 0, 0.25);
|
||||||
|
|
||||||
$btn-primary-text: white;
|
$btn-primary-text: white;
|
||||||
$btn-primary-bg: linear-gradient(93.25deg, #4942E4 0%, #11009E 50%, #4942E4 100%),
|
$btn-primary-bg: linear-gradient(93.25deg, #4942E4 0%, #11009E 50%, #4942E4 100%), linear-gradient(0deg, #585858, #585858);
|
||||||
linear-gradient(0deg, #585858, #585858);
|
|
||||||
|
// Размеры
|
||||||
|
$navbar-height: 60px;
|
||||||
|
$navbar-height-mini: 30px;
|
||||||
|
$navbar-padding-tb: 10px;
|
||||||
@@ -1,23 +1,27 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
import FooterLink from './FooterLink';
|
import FooterLink from './FooterLink';
|
||||||
|
import FooterContacts from './FooterContacts';
|
||||||
|
import { getMedia } from '../../api';
|
||||||
|
|
||||||
import { scb as logo } from '../../assets/images';
|
import { scb as logo } from '../../assets/images';
|
||||||
import { iconIctis, iconSfedu, iconVK } from '../../assets/images/footer';
|
import { iconIctis, iconSfedu, iconVK } from '../../assets/images/footer';
|
||||||
import './Footer.styles.scss';
|
import './Footer.styles.scss';
|
||||||
import FooterContacts from './FooterContacts';
|
|
||||||
|
|
||||||
const mockLinks = [
|
const mockLinks = {
|
||||||
{
|
ictis: {
|
||||||
icon: iconIctis,
|
icon: iconIctis,
|
||||||
to: "https://ictis.sfedu.ru",
|
to: "https://ictis.sfedu.ru",
|
||||||
},
|
},
|
||||||
{
|
sfedu: {
|
||||||
icon: iconSfedu,
|
icon: iconSfedu,
|
||||||
to: "https://sfedu.ru",
|
to: "https://sfedu.ru",
|
||||||
},
|
},
|
||||||
{
|
vk: {
|
||||||
icon: iconVK,
|
icon: iconVK,
|
||||||
to: "https://vk.com/skbkit",
|
to: "https://vk.com/skbkit",
|
||||||
},
|
},
|
||||||
];
|
};
|
||||||
|
|
||||||
const mockContacts = {
|
const mockContacts = {
|
||||||
email: "skb@sfedu.ru",
|
email: "skb@sfedu.ru",
|
||||||
@@ -26,6 +30,22 @@ const mockContacts = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function Footer({ links = mockLinks, contacts = mockContacts }) {
|
function Footer({ links = mockLinks, contacts = mockContacts }) {
|
||||||
|
const [mediaList, setMediaList] = useState(links);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadData = async () => {
|
||||||
|
const footerMedia = await getMedia('footer');
|
||||||
|
const newMediaList = mediaList;
|
||||||
|
|
||||||
|
for (let media of footerMedia) {
|
||||||
|
newMediaList[media.name].icon = media.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
setMediaList(newMediaList);
|
||||||
|
};
|
||||||
|
loadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer className="footer">
|
<footer className="footer">
|
||||||
<div className="logo-container">
|
<div className="logo-container">
|
||||||
@@ -33,7 +53,7 @@ function Footer({ links = mockLinks, contacts = mockContacts }) {
|
|||||||
</div>
|
</div>
|
||||||
<FooterContacts contacts={ contacts } />
|
<FooterContacts contacts={ contacts } />
|
||||||
<div className="links">
|
<div className="links">
|
||||||
{ links.map(link => <FooterLink link={link} />) }
|
{ Object.keys(mediaList).map((link, index) => <FooterLink link={mediaList[link]} key={index} />) }
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { scb as logo } from '../../assets/images';
|
|
||||||
import { NavLink } from "react-router-dom";
|
|
||||||
import NavbarLink from './NavbarLink';
|
import NavbarLink from './NavbarLink';
|
||||||
|
|
||||||
|
import { scb as logo } from '../../assets/images';
|
||||||
import './Navbar.styles.scss';
|
import './Navbar.styles.scss';
|
||||||
|
|
||||||
const mock = [
|
const mock = [
|
||||||
@@ -33,14 +33,12 @@ const mock = [
|
|||||||
|
|
||||||
function Navbar({ links = mock }) {
|
function Navbar({ links = mock }) {
|
||||||
return (
|
return (
|
||||||
<div className="navbar">
|
<div id="navbar">
|
||||||
<NavbarLink link={{ to: "/" }} >
|
<NavbarLink className="logo-container" link={{ to: "/" }} >
|
||||||
<div className="logo-container">
|
<img src={logo} className="logo" alt="SCB logo" />
|
||||||
<img src={logo} className="logo" alt="SCB logo" />
|
|
||||||
</div>
|
|
||||||
</NavbarLink>
|
</NavbarLink>
|
||||||
<div className="bar">
|
<div className="bar">
|
||||||
{links.map(link => <NavbarLink link={link} />)}
|
{links.map((link, index) => <NavbarLink link={link} key={index} />)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
@import "../../assets/styles/theme.scss";
|
@import "../../assets/styles/theme.scss";
|
||||||
|
|
||||||
.navbar {
|
#navbar {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 80%;
|
width: 80%;
|
||||||
height: 60px;
|
height: $navbar-height;
|
||||||
max-height: 80px;
|
padding: $navbar-padding-tb 10%;
|
||||||
padding: 1em 10%;
|
background-color: $bg-secondary;
|
||||||
background: transparent;
|
z-index: 10;
|
||||||
z-index: 1;
|
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;
|
||||||
|
|
||||||
.logo-container {
|
.nav-link:has(> .logo) {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
@@ -44,3 +44,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#navbar.transparent{
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
@@ -4,37 +4,37 @@ import Arrows from './components/Arrows';
|
|||||||
import SlidesList from './components/SlidesList';
|
import SlidesList from './components/SlidesList';
|
||||||
import Dots from './components/Dots';
|
import Dots from './components/Dots';
|
||||||
|
|
||||||
import { getSliderImages } from '../../api';
|
import { getMedia } from '../../api';
|
||||||
import './Slider.styles.scss';
|
import './Slider.styles.scss';
|
||||||
|
|
||||||
export const SliderContext = createContext();
|
export const SliderContext = createContext();
|
||||||
|
|
||||||
function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
|
function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
|
||||||
const [items, setItems] = useState([]);
|
const [mediaList, setMediaList] = useState([]);
|
||||||
const [slide, setSlide] = useState(0);
|
const [slide, setSlide] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const images = await getSliderImages();
|
const newMediaList = await getMedia('gallery');
|
||||||
setItems(images);
|
setMediaList(newMediaList);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const changeSlide = (direction = 1) => {
|
const changeSlide = (direction = 1) => {
|
||||||
let slideNumber = 0;
|
let slideNumber = 0;
|
||||||
|
|
||||||
if (slide + direction < 0) {
|
if (slide + direction < 0) {
|
||||||
slideNumber = items.length - 1;
|
slideNumber = mediaList.length - 1;
|
||||||
} else {
|
} else {
|
||||||
slideNumber = (slide + direction) % items.length;
|
slideNumber = (slide + direction) % mediaList.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSlide(slideNumber);
|
setSlide(slideNumber);
|
||||||
};
|
};
|
||||||
|
|
||||||
const goToSlide = (number) => {
|
const goToSlide = (number) => {
|
||||||
setSlide(number % items.length);
|
setSlide(number % mediaList.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -47,7 +47,7 @@ function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
|
|||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
};
|
};
|
||||||
}, [items.length, slide]);
|
}, [mediaList.length, slide]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="slider">
|
<div className="slider">
|
||||||
@@ -55,9 +55,9 @@ function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
|
|||||||
value={{
|
value={{
|
||||||
goToSlide,
|
goToSlide,
|
||||||
changeSlide,
|
changeSlide,
|
||||||
slidesCount: items.length,
|
slidesCount: mediaList.length,
|
||||||
slideNumber: slide,
|
slideNumber: slide,
|
||||||
items
|
mediaList
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Arrows />
|
<Arrows />
|
||||||
|
|||||||
@@ -18,15 +18,11 @@
|
|||||||
|
|
||||||
& .slide-image {
|
& .slide-image {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 60vh;
|
max-height: 60vh;
|
||||||
|
max-width: calc(100% - 2 * (15% + 30px));
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
& .slide-title {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,15 @@ import Slide from "./Slide";
|
|||||||
import { SliderContext } from "../Slider";
|
import { SliderContext } from "../Slider";
|
||||||
|
|
||||||
export default function SlidesList() {
|
export default function SlidesList() {
|
||||||
const { slideNumber, items } = useContext(SliderContext);
|
const { slideNumber, mediaList } = useContext(SliderContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="slide-list"
|
className="slide-list"
|
||||||
style={{ transform: `translateX(-${slideNumber * 100}%)` }}
|
style={{ transform: `translateX(-${slideNumber * 100}%)` }}
|
||||||
>
|
>
|
||||||
{items.map((slide, index) => (
|
{mediaList.map((slide, index) => (
|
||||||
<Slide key={index} slide={slide} />
|
<Slide key={index} slide={slide.url} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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;
|
||||||
+24
-5
@@ -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 { News, Projects, Labs, Partners, Gallery, ContactUs } from './components';
|
||||||
|
import { RootContext } from '../Root';
|
||||||
|
|
||||||
|
import './Main.styles.scss';
|
||||||
|
|
||||||
function Main() {
|
function Main() {
|
||||||
|
const { setRef } = useContext(RootContext);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const navbar = document.getElementById("navbar");
|
||||||
|
navbar.classList.add('transparent'); // Mount
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
navbar.classList.remove('transparent'); // Unmount
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<header className="header">
|
<header id="mainpageheader" ref={element => setRef(element)}>
|
||||||
<h1>Думай иначе, будь креативным!</h1>
|
<div className="container">
|
||||||
<h2>Студенческое конструкторское бюро<br/>
|
<h1>Думай иначе, будь креативным!</h1>
|
||||||
"Компьютерное инновационное творчество"</h2>
|
<h2>Студенческое конструкторское бюро<br />
|
||||||
<a className="btn" href="">Связаться с нами</a>
|
"Компьютерное инновационное творчество"</h2>
|
||||||
|
<HashLink smooth to="#contact-us" className="btn">Связаться с нами</HashLink>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<News />
|
<News />
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import './ContactUs.styles.scss';
|
|||||||
|
|
||||||
function ContactUs() {
|
function ContactUs() {
|
||||||
return (
|
return (
|
||||||
<div className="block contact-us">
|
<div className="block" id="contact-us">
|
||||||
<h1 className="half">Нужна помощь?<br/> Команда способных IT-специалистов готова вам помочь!</h1>
|
<h1 className="half">Нужна помощь?<br/> Команда способных IT-специалистов готова вам помочь!</h1>
|
||||||
<ContactForm />
|
<ContactForm />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
.contact-us {
|
#contact-us {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
gap: 60px;
|
gap: 60px;
|
||||||
|
|
||||||
.half {
|
.half {
|
||||||
flex: 1 1 50%;
|
flex: 0 0 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-form {
|
||||||
|
max-width: 500px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,8 @@ import './Gallery.styles.scss';
|
|||||||
function Gallery() {
|
function Gallery() {
|
||||||
return (
|
return (
|
||||||
<div className="block gallery">
|
<div className="block gallery">
|
||||||
<h1>СКБ «КИТ» - реальные технологические проекты<br/>
|
<h1>СКБ «КИТ» - реальные технологические проекты<br />
|
||||||
под руководством наставников<br/>
|
под руководством наставников<br />
|
||||||
из университета и бизнеса.</h1>
|
из университета и бизнеса.</h1>
|
||||||
<Slider />
|
<Slider />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#page .content .gallery {
|
#page .content #gallery {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const mock = [
|
|||||||
|
|
||||||
function Labs({ labs = mock }) {
|
function Labs({ labs = mock }) {
|
||||||
return (
|
return (
|
||||||
<div className="block labs">
|
<div className="block" id="labs">
|
||||||
<BlockHeading heading="Наши лаборатории" />
|
<BlockHeading heading="Наши лаборатории" />
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{ labs.map( lab => <LabCard key={ lab.id } lab={ lab } />) }
|
{ labs.map( lab => <LabCard key={ lab.id } lab={ lab } />) }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@import "../../../../assets/styles/theme.scss";
|
@import "../../../../assets/styles/theme.scss";
|
||||||
|
|
||||||
.labs {
|
#labs {
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const mock = [
|
|||||||
function News({ news = mock }) {
|
function News({ news = mock }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="block news">
|
<div className="block" id="news">
|
||||||
<BlockHeading heading='Новости' linkText='Все новости' link='https://vk.com/skbkit' />
|
<BlockHeading heading='Новости' linkText='Все новости' link='https://vk.com/skbkit' />
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{ news.map(item => <NewsCard key={ item.id } news={ item } />) }
|
{ news.map(item => <NewsCard key={ item.id } news={ item } />) }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.news {
|
#news {
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const mock = [
|
|||||||
|
|
||||||
function Partners({ partners = mock }) {
|
function Partners({ partners = mock }) {
|
||||||
return (
|
return (
|
||||||
<div className="block partners">
|
<div className="block" id="partners">
|
||||||
<BlockHeading heading="Наши партнеры" />
|
<BlockHeading heading="Наши партнеры" />
|
||||||
<ScrollCarousel
|
<ScrollCarousel
|
||||||
autoplay
|
autoplay
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#page .content .partners {
|
#page .content #partners {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const mock = [
|
|||||||
|
|
||||||
function Projects({ projects = mock }) {
|
function Projects({ projects = mock }) {
|
||||||
return (
|
return (
|
||||||
<div className="block projects">
|
<div className="block" id="projects">
|
||||||
<BlockHeading heading="Наши проекты" linkText="Все проекты" link="/projects" />
|
<BlockHeading heading="Наши проекты" linkText="Все проекты" link="/projects" />
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{projects.map(item => <ProjectCard key={ item.id } project={item} />)}
|
{projects.map(item => <ProjectCard key={ item.id } project={item} />)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@import "../../../../assets/styles/theme.scss";
|
@import "../../../../assets/styles/theme.scss";
|
||||||
|
|
||||||
.projects {
|
#projects {
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
+28
-8
@@ -1,25 +1,45 @@
|
|||||||
import { Outlet, useLoaderData } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
|
import { createContext, useEffect } from 'react';
|
||||||
|
|
||||||
import { getContacts } from "../../api";
|
import { getMedia } from "../../api";
|
||||||
|
import useElementOnScreen from '../../lib/useElementOnScreen';
|
||||||
import Navbar from '../../components/Navbar';
|
import Navbar from '../../components/Navbar';
|
||||||
import Footer from "../../components/Footer";
|
import Footer from '../../components/Footer';
|
||||||
import './Root.styles.scss';
|
import './Root.styles.scss';
|
||||||
|
|
||||||
|
export const RootContext = createContext();
|
||||||
|
|
||||||
async function loader() {
|
async function loader() {
|
||||||
const contacts = await getContacts();
|
const media = getMedia();
|
||||||
return { contacts };
|
return { media };
|
||||||
}
|
}
|
||||||
|
|
||||||
function Root() {
|
function Root() {
|
||||||
const { contacts } = useLoaderData();
|
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 (
|
return (
|
||||||
<>
|
<RootContext.Provider
|
||||||
|
value={{ setRef }}
|
||||||
|
>
|
||||||
<Navbar />
|
<Navbar />
|
||||||
<div id="page">
|
<div id="page">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
</>
|
</RootContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,7 @@
|
|||||||
@import "../../assets/styles/theme.scss";
|
@import "../../assets/styles/theme.scss";
|
||||||
|
|
||||||
#page {
|
#page {
|
||||||
|
margin-top: calc($navbar-height + 3 * $navbar-padding-tb);
|
||||||
.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
background: $bg-primary;
|
background: $bg-primary;
|
||||||
@@ -65,12 +36,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.block .heading a,
|
.block .heading a,
|
||||||
.navbar .nav-link {
|
#navbar .nav-link {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block .heading a::after,
|
.block .heading a::after,
|
||||||
.navbar .nav-link::after {
|
#navbar .nav-link::after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
content: '';
|
content: '';
|
||||||
left: 50%;
|
left: 50%;
|
||||||
@@ -87,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.block .heading a:hover:after,
|
.block .heading a:hover:after,
|
||||||
.navbar .nav-link:hover:after,
|
#navbar .nav-link:hover:after,
|
||||||
.navbar .nav-link.active:after {
|
#navbar .nav-link.active:after {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
export { default as Root, loader } from './Root';
|
export { default as Root, RootContext, loader } from './Root';
|
||||||
Reference in new issue
Block a user