Merge pull request #36 from ifraimka1/refactoring-fsd

Refactoring fsd
This commit is contained in:
Ifraim Solomonov authored and GitHub committed 2025-04-15 15:42:19 +03:00
commit ca27f407e1
267 files changed
+12497 -17680

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
VITE_URL_BACK = "localhost:8000"
VITE_URL_CAMERA = "http://192.168.1.250:5000/hls/stream.m3u8"
+18
View File
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
+2
View File
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
+21 -22
View File
@@ -1,26 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # Logs
logs
# dependencies *.log
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
#copies node_modules
*.copy dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
src/shared/api/wp-client.ts
+27
View File
@@ -0,0 +1,27 @@
# Используем официальный образ Node.js
FROM node:18-alpine
# Создаём рабочую директорию внутри контейнера
WORKDIR /app
# Копируем package.json и lock-файл
COPY package*.json ./
# Устанавливаем зависимости
RUN npm install
# Копируем остальной код проекта
COPY . .
# Если нужно, конвертируем строки в bin-скриптах из CRLF в LF
RUN dos2unix node_modules/.bin/* || true
# Делаем все скрипты в node_modules/.bin исполняемыми (включая tsc и vite)
RUN chmod +x node_modules/.bin/* || true
# Собираем проект
RUN npm run build
# Открываем порт, на котором будет слушать сервер Vite (по умолчанию 4173 для preview)
EXPOSE 4173
# Запускаем встроенный сервер Vite для предварительного просмотра сборки
CMD ["npm", "run", "preview"]
+1 -18
View File
@@ -1,19 +1,2 @@
React-приложение "Сайт СКБ КИТ" для использования с WordPress. # react-typeScriot-scss-tamplate
Для работы приложения требуются:
- Wordpress с установленным плагином ReactPress
- Node.js
Создано с помощью create-react-app
Используемые библиотеки:
- react
- react-router-dom
- reactpress
- sass
- wpapi
Для запуска приложения необходимо:
- поместить папку проекта в директорию /*wordpress-dir*/wp-content/reactpress/apps
- перейти в папку проекта
- установить необходимые библиотеки (npm install)
- запустить dev-build (npm start) или собрать приложение (npm run build) и открыть страницу в wordpress
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
plugins: [
[
'module-resolver',
{
alias: {
'@': './src',
},
},
],
],
};
+13
View File
@@ -0,0 +1,13 @@
version: '3'
services:
frontend:
build:
context: .
dockerfile: Dockerfile
# Пробрасываем порт 4173, если вы используете 'npm run preview'
ports:
- '4173:4173'
container_name: smart_lab_front
# Опционально, если хотите зафиксировать переменную окружения
environment:
NODE_ENV: production
+22
View File
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Завод</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/main.tsx"></script>
</body>
</html>
+10
View File
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": "../TypeScriptSKB/src",
"paths": {
"@/*": ["*"]
}
},
"include": ["../TypeScriptSKB/src"],
"exclude": ["node_modules"]
}
+6307 -15887
View File
File diff suppressed because it is too large. Load diff
+68 -39
View File
@@ -1,46 +1,75 @@
{ {
"name": "skb", "name": "pishufu",
"version": "0.1.0",
"private": true, "private": true,
"dependencies": { "version": "0.0.0",
"@testing-library/jest-dom": "^5.17.0", "type": "module",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"lodash": "^4.17.21",
"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"
},
"scripts": { "scripts": {
"start": "react-scripts start", "dev": "vite --host",
"build": "set PUBLIC_URL=/wp-content/reactpress/apps/skb/build&&react-scripts build", "build": "tsc -b && vite build",
"test": "react-scripts test", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"eject": "react-scripts eject" "preview": "vite preview"
}, },
"eslintConfig": { "dependencies": {
"extends": [ "@emotion/react": "^11.14.0",
"react-app", "@emotion/styled": "^11.14.0",
"react-app/jest" "@hookform/resolvers": "^4.1.3",
] "@mui/material": "^6.4.1",
"@pbe/react-yandex-maps": "^1.2.5",
"@popperjs/core": "^2.11.8",
"@tanstack/query-core": "^5.62.9",
"@tanstack/react-query": "^5.62.10",
"@yandex/smart-captcha": "^2.7.0",
"axios": "^1.7.2",
"bootstrap": "^5.3.3",
"chart.js": "^4.4.4",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"hls.js": "^1.5.20",
"html-react-parser": "^5.2.2",
"immer": "^10.1.1",
"jsonwebtoken": "^9.0.2",
"jwt-decode": "^4.0.0",
"lodash": "^4.17.21",
"lodash.debounce": "^4.0.8",
"lucide-react": "^0.445.0",
"persist": "^0.2.7",
"pg": "^8.13.0",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.3.1",
"react-fast-marquee": "^1.6.5",
"react-hook-form": "^7.54.2",
"react-modal": "^3.16.3",
"react-router": "^7.1.1",
"react-router-dom": "^6.28.1",
"react-router-hash-link": "^2.4.3",
"sass": "^1.85.1",
"swiper": "^11.2.5",
"wpapi": "^1.2.2",
"xlsx": "^0.18.5",
"zod": "^3.24.2",
"zustand": "^5.0.0"
}, },
"browserslist": { "devDependencies": {
"production": [ "@types/jsonwebtoken": "^9.0.7",
">0.2%", "@types/jwt-decode": "^3.1.0",
"not dead", "@types/lodash": "^4.17.16",
"not op_mini all" "@types/react": "^18.3.6",
], "@types/react-dom": "^18.3.0",
"development": [ "@types/react-modal": "^3.16.3",
"last 1 chrome version", "@types/react-router-hash-link": "^2.4.9",
"last 1 firefox version", "@types/sass-loader": "^8.0.8",
"last 1 safari version" "@types/wpapi": "^1.1.4",
] "@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react-refresh": "^1.3.6",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"i": "^0.3.7",
"npm": "^11.2.0",
"typescript": "^5.5.3",
"vite": "^5.3.1"
} }
} }
+8 -2
View File
@@ -1,9 +1,14 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ru-RU"> <html lang="ru-RU">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11" /> <link rel="profile" href="https://gmpg.org/xfn/11" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
if (window.location.pathname === '/' && window.location.hash === '') {
window.location.replace('/#/');
}
</script>
<title>main &#8212; skb-site</title> <title>main &#8212; skb-site</title>
</head> </head>
@@ -59,5 +64,6 @@
<script> <script>
var reactPress = {"api":{"nonce":"078e5a02b1","rest_url":"http:\/\/skb-site.local\/wp-json\/","graphql_url":"http:\/\/skb-site.local\/graphql"},"post":{"ID":6,"post_author":"1","post_date":"2024-02-13 10:11:05","post_date_gmt":"2024-02-13 07:11:05","post_content":"<!-- wp:html -->\n<!-- Please don't change. Block is needed for React app. -->\n<noscript>You need to enable JavaScript to run this app.<\/noscript>\n<div id=\"root\"><\/div>\n<!-- \/wp:html -->","post_title":"main","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"main","to_ping":"","pinged":"","post_modified":"2024-02-13 12:19:19","post_modified_gmt":"2024-02-13 09:19:19","post_content_filtered":"","post_parent":0,"guid":"http:\/\/skb-site.local\/main\/","menu_order":0,"post_type":"page","post_mime_type":"","comment_count":"0","filter":"raw"},"user":{"data":{},"ID":0,"caps":[],"cap_key":null,"roles":[],"allcaps":[],"filter":null},"usermeta":""}; var reactPress = {"api":{"nonce":"078e5a02b1","rest_url":"http:\/\/skb-site.local\/wp-json\/","graphql_url":"http:\/\/skb-site.local\/graphql"},"post":{"ID":6,"post_author":"1","post_date":"2024-02-13 10:11:05","post_date_gmt":"2024-02-13 07:11:05","post_content":"<!-- wp:html -->\n<!-- Please don't change. Block is needed for React app. -->\n<noscript>You need to enable JavaScript to run this app.<\/noscript>\n<div id=\"root\"><\/div>\n<!-- \/wp:html -->","post_title":"main","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"main","to_ping":"","pinged":"","post_modified":"2024-02-13 12:19:19","post_modified_gmt":"2024-02-13 09:19:19","post_content_filtered":"","post_parent":0,"guid":"http:\/\/skb-site.local\/main\/","menu_order":0,"post_type":"page","post_mime_type":"","comment_count":"0","filter":"raw"},"user":{"data":{},"ID":0,"caps":[],"cap_key":null,"roles":[],"allcaps":[],"filter":null},"usermeta":""};
</script> </script>
<script id="rp-react-app-asset-0-0" type="module" src="http://skb-site.local/wp-content/reactpress/apps/skb/build/static/js/main.ced20d2f.js?ver=1"></script></body> <script id="rp-react-app-asset-0-0" type="module" src="http://skb-site.local/wp-content/reactpress/apps/skb/build/static/js/main.ced20d2f.js?ver=1"></script>
</body>
</html> </html>
-83
View File
@@ -1,83 +0,0 @@
import * as WPAPI from 'wpapi';
import { flatten } from 'lodash';
import reactPress from './reactPress';
const wp = new WPAPI(
process.env.NODE_ENV === 'development'
? {
endpoint: reactPress.api.rest_url,
username: 'admin',
password: 'admin',
}
: { endpoint: reactPress.api.rest_url, nonce: reactPress.api.nonce }
);
async function getAllMedia(request) {
return request.then(function (response) {
if (!response._paging || !response._paging.next) {
return response;
}
// Запрос к следующей странице и возврат ответов одной коллекцией
return Promise.all([
response,
getAllMedia(response._paging.next)
]).then(function (responses) {
return flatten(responses);
});
});
}
// Функция загрузки медабиблиотеки и сортировки по категориям
async function loadMedia() {
const response = await getAllMedia(wp.media());
// Нам потребуется id, категория и url
const result = {};
for (let { id, alt_text, source_url: image } of response) {
const [category, name] = alt_text.split('_');
// Создаем ключ с пустым массивом, если еще нет
if (!result[category]) {
result[category] = [];
}
// Добавляем медиа в массив нужной категории
result[category].push({ id, name, image });
}
return result;
}
const mediaLibrary = await loadMedia();
console.log(mediaLibrary);
export async function getPosts(q = '') {
try {
const posts = await wp.posts().search(q);
return posts;
} catch (error) {
console.error(error);
return [];
}
}
export async function getMedia(category, target = false) {
try {
if (target) {
for (let media of mediaLibrary[category]) {
target[media.name].image = media.image;
target[media.name].id = media.id;
console.log(target[media.name].id);
}
return target;
}
return mediaLibrary[category];
} catch (error) {
console.log(error);
return [];
}
}
+29
View File
@@ -0,0 +1,29 @@
import "./styles/App.scss";
import { Suspense } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { classNames } from "@/shared/lib/classNames/classNames";
import { RouterProvider } from "react-router-dom";
import { appRouter } from "@/app/providers/router";
function App() {
// Создаём экземпляр QueryClient
const queryClient = new QueryClient();
return (
<>
<div className={classNames("app", {}, [])}>
<Suspense fallback="loading">
<div className="content-page">
<QueryClientProvider client={queryClient}>
<RouterProvider router={appRouter} />
</QueryClientProvider>
</div>
</Suspense>
</div>
</>
);
}
export default App;
+161
View File
@@ -0,0 +1,161 @@
// Общий стиль
#root {
position: relative; // Убедитесь, что #root имеет relative
background-repeat: no-repeat;
background-position: center bottom;
background-image: url("/assets/images/backround/bg_footer_02.svg");
background-size: 100% auto;
z-index: 0; // Задний план
opacity: 0; // Сделаем #root видимым сразу
min-height: 100vh; // Устанавливаем минимальную высоту для #root
// Псевдоэлемент для фона в верхней части страницы
&::before {
content: "";
position: absolute;
top: 160px;
left: 0; // Слева
width: 100%; // На всю ширину
height: 364px; // Ограничиваем максимальную высоту
background-image: url("../../assets/images/backround/bg_news_block.svg"); // Картинка
background-repeat: no-repeat;
background-position: left center;
background-size: contain;
z-index: -1; // Картинка на заднем плане, за остальными элементами
@media (max-width: 768px) {
display: none; // Прячем картинку на мобильных устройствах
}
}
}
// Для главной страницы
#root:has(> #react-page #mainpageheader) {
background-image: url("/assets/images/backround/bg_footer.svg");
&::before {
background-image: none;
}
}
#react-page:has(> #mainpageheader) {
margin-top: 0;
}
.page-loaded #root {
opacity: 1;
visibility: visible;
}
#react-page {
margin-top: calc($navbar-height + 5 * $navbar-padding-tb);
.header,
.content {
margin-left: 10%;
margin-right: 10%;
@media (max-width: 768px) {
margin-left: 5%;
margin-right: 5%;
}
}
.content {
background: $bg-primary;
//padding: 0 1em;
border-radius: 8px;
display: flex;
flex-direction: column;
//box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.1);
}
}
.block .heading a,
#navbar .nav-link {
position: relative;
}
.block .heading a::after,
#navbar .nav-link::after {
position: absolute;
content: "";
left: 50%;
transform: translateX(-50%);
bottom: 0;
display: block;
width: 0;
height: 1px;
transition: 0.3s;
}
.block .heading a::after {
background: $text-primary;
}
.block .heading a:hover:after,
#navbar .nav-link:hover:after,
#navbar .nav-link.active:after {
width: 100%;
}
.scroll-to-top {
position: fixed;
right: 2vw; // Используем vw для адаптивности
bottom: 7.5vh; // Используем vh для адаптивности
background-color: white;
border-radius: 50%;
width: 61px;
height: 61px;
z-index: 10;
border: none;
cursor: pointer;
opacity: 0;
transform: scale(0);
transition: opacity 0.3s ease, transform 0.3s ease;
animation: scaleIn 0.5s forwards; /* Анимация появления */
box-shadow: 5px 6px 15px rgba(0, 0, 0, 0.05);
&.visible {
opacity: 1;
transform: scale(1);
box-shadow: 5px 6px 15px rgba(0, 0, 0, 0.1);
}
&.hidden {
opacity: 0;
transform: scale(0);
animation: scaleOut 0.5s forwards; /* Анимация исчезновения */
}
img {
height: auto;
}
}
/* Анимация для появления кнопки */
@keyframes scaleIn {
0% {
opacity: 0;
transform: scale(0);
}
100% {
opacity: 1;
transform: scale(1);
}
}
/* Анимация для исчезновения кнопки */
@keyframes scaleOut {
0% {
opacity: 1;
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(0);
}
}
@media (max-width: 768px) {
.scroll-to-top {
display: none; // Скрыть кнопку на мобильных устройствах
}
}
+96
View File
@@ -0,0 +1,96 @@
import { Outlet, useLocation } from "react-router-dom";
import { createContext, useEffect, useState } from "react";
import "./Root.styles.scss";
import up from "@/shared/assets/images/up.svg";
import useElementOnScreen from "@/shared/lib/ElementOnScreen/ElementOnScreen";
import Navbar from "@/widgets/Navbar";
import Footer from "@/widgets/Footer";
// Тип для контекста
interface RootContextType {
setRef: (element: HTMLElement | null) => void;
}
// Создаем контекст с типом
export const RootContext = createContext<RootContextType>({ setRef: () => {} });
function Root() {
const location = useLocation(); // Хук для получения текущего пути
const [setRef, isTargetVisible] = useElementOnScreen({
root: null,
rootMargin: "0px",
threshold: 0.9,
});
const [isOnTopVisible, setIsOnTopVisible] = useState<boolean>(false); // Состояние для видимости кнопки
const [hasScrolled, setHasScrolled] = useState<boolean>(false); // Флаг для отслеживания прокрутки
// Для навбара
useEffect(() => {
const navbar = document.getElementById("navbar");
if (navbar) {
if (isTargetVisible) {
navbar.classList.add("transparent");
} else {
navbar.classList.remove("transparent");
}
}
}, [isTargetVisible]);
// Для кнопки OnTop
useEffect(() => {
setTimeout(() => {
document.body.classList.add("page-loaded");
}, 100); // Небольшая задержка, чтобы избежать мерцания
const handleScroll = () => {
const headerHeight =
document.getElementById("mainpageheader")?.offsetHeight || 0;
if (window.scrollY > headerHeight && !hasScrolled) {
setHasScrolled(true);
}
setIsOnTopVisible(window.scrollY > headerHeight); // Показываем кнопку
};
window.addEventListener("scroll", handleScroll);
return () => {
window.removeEventListener("scroll", handleScroll);
};
}, [hasScrolled]);
// Ускоренный плавный скролл вверх
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};
// Определяем, находимся ли мы на главной странице
const isHomePage = location.pathname === "/";
return (
<RootContext.Provider value={{ setRef }}>
<Navbar />
<div
id="react-page"
style={{ marginTop: isHomePage ? "0px" : "" }} // Устанавливаем margin-top
>
<Outlet />
</div>
<Footer />
{hasScrolled && (
<button
className={`scroll-to-top ${isOnTopVisible ? "visible" : "hidden"}`}
onClick={scrollToTop}
>
<img src={up} alt="Scroll to top" />
</button>
)}
</RootContext.Provider>
);
}
export default Root;
+3
View File
@@ -0,0 +1,3 @@
import { appRouter } from "./ui/AppRouter";
export { appRouter };
+14
View File
@@ -0,0 +1,14 @@
import Root from "@/app/Layout/Root";
import { routeConfig } from "@/shared/config/routeConfig/routeConfig";
import { createBrowserRouter } from "react-router-dom";
export const appRouter = createBrowserRouter([
{
element: <Root />,
children: Object.values(routeConfig).map((route) => ({
path: route.path,
element: route.element,
})),
},
]);
+86
View File
@@ -0,0 +1,86 @@
@import "bootstrap/scss/bootstrap";
@import "global";
@import "variables/variables";
@import "reset";
@font-face {
font-family: "Montserrat";
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("../fonts/Montserrat/Montserrat-VariableFont_wght.ttf")
format("truetype");
}
.app {
min-height: 100%;
}
#page {
> #header,
> hr,
> #footer {
display: none;
}
}
.mainContainer {
margin: 0 10%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
margin-bottom: 30px;
@include mediaMax($mobile-xs-width) {
margin: 0 5%;
margin-bottom: 30px;
}
}
.loader {
width: 336px; /* 48px * 7 */
height: 280px; /* 40px * 7 */
margin-top: 210px; /* 30px * 7 */
display: inline-block;
position: relative;
background: #6ebeff;
border-radius: 15% 15% 35% 35%;
}
.loader::after {
content: "";
box-sizing: border-box;
position: absolute;
left: 315px; /* 45px * 7 */
top: 56px; /* 8px * 7 */
border: 28px solid #6ebeff; /* 4px * 7 */
width: 112px; /* 16px * 7 */
height: 140px; /* 20px * 7 */
border-radius: 0 28px 28px 0; /* 4px * 7 */
}
.loader::before {
content: "";
position: absolute;
width: 7px; /* 1px * 7 */
height: 70px; /* 10px * 7 */
color: #6ebeff;
top: -105px; /* -15px * 7 */
left: 77px; /* 11px * 7 */
box-sizing: border-box;
animation: animloader 1s ease infinite;
}
@keyframes animloader {
0% {
box-shadow: 14px 0px rgba(51, 122, 183, 0),
/* 2px * 7 */ 84px 0px rgba(51, 122, 183, 0.3),
/* 12px * 7 */ 140px 0px rgba(51, 122, 183, 0); /* 20px * 7 */
}
50% {
box-shadow: 14px -35px rgba(51, 122, 183, 0.5),
/* 2px * 7, -5px * 7 */ 84px -21px rgba(51, 122, 183, 0.5),
/* 12px * 7, -3px * 7 */ 140px -14px rgba(51, 122, 183, 0.6); /* 20px * 7, -2px * 7 */
}
100% {
box-shadow: 14px -56px rgba(51, 122, 183, 0),
/* 2px * 7, -8px * 7 */ 84px -35px rgba(51, 122, 183, 0),
/* 12px * 7, -5px * 7 */ 140px -35px rgba(51, 122, 183, 0); /* 20px * 7, -5px * 7 */
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+120
View File
@@ -0,0 +1,120 @@
input {
border: none;
}
.hopeui_style-breadcrumb {
display: none !important;
}
body {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body,
input,
textarea,
button {
font-family: Montserrat;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
a {
text-decoration: none;
}
.btn {
display: block;
width: fit-content;
padding: 16px 24px;
margin: 0 auto;
border-radius: 8px;
border: none;
font-size: $main-font-size;
font-weight: 600;
line-height: 24px;
color: $btn-primary-text;
background: $btn-primary-bg;
background-size: 200%;
transition: 0.5s;
cursor: pointer;
}
.btn:hover {
background-position: 100%;
}
.btn[disabled] {
background: gray;
}
.list {
margin-top: 0.5em;
}
.image {
max-width: 100%;
border-radius: 8px;
}
p,
ul,
ol {
// TODO: заменить переменной
@media (max-width: 768px) {
font-size: 16px;
}
font-size: $main-font-size;
font-weight: $main-font-weight;
line-height: $main-line-height;
}
ul,
ol {
margin-top: -0.75em;
}
header h1 {
font-size: 36px;
font-weight: 600;
line-height: 44px;
margin-top: 24px;
@media (max-width: 768px) {
margin-top: 0;
font-size: 24px;
}
}
#root {
display: flex;
min-height: 100vh;
flex-direction: column;
justify-content: flex-start;
#react-page {
margin-bottom: 2em;
}
#footer {
margin-top: auto;
}
}
dl,
ol,
ul {
margin-bottom: 1rem;
margin-top: 0;
}
ol,
ul {
padding-left: 2rem;
}
+16
View File
@@ -0,0 +1,16 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
input,
button,
textarea,
select {
margin: 0;
font: inherit;
}
body {
font-family: "Montserrat", sans-serif;
}
+58
View File
@@ -0,0 +1,58 @@
//Цвета
$bg-primary: white;
$bg-secondary: #343434;
$bg-footer: #222222;
$bg-form: #f5f5f7;
$bg-card-lab: black;
$bg-image: rgba(0, 0, 0, 0.75);
$text-primary: black;
$text-secondary: white;
$text-card-project: white;
$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);
// Размеры
$navbar-height: 60px;
$navbar-height-mini: 30px;
$navbar-padding-tb: 10px;
$navbar-logo-height: 247px;
$navbar-logo-mini-height: 165px;
$row-gap: 26px;
$main-font-size: 20px;
$main-font-weight: 400;
$main-line-height: 30px;
//Разрешения
$desktop-4k-width: 2560px;
$maxDesktopWidth: 2800px;
$desktop-hd: 1920px;
$desktop-bootstrap: 100000px;
$desktop-max-width: 1441.98px;
$desktop-max-width-sec: 1400.98px;
$desktop-small-width: 1200.98px;
$small-tablet-max-width: 993.98px;
// $small-tablet-max-width-exception: 992px;
$tablet-max-width: 767.98px;
$tablet-max-width-exception: 767.98px;
$mobile-max-widthGosBlock: 531.98px;
$mobile-max-width: 500.98px;
$mobile-max-width-small: 425.98px;
$mobile-max-width-superSmall: 390.98px;
$mobile-extra-small-width: 375.98px;
$img-mobile-max-width: 580.98px;
$mobile-xs-width: 576.98px;
$mobile-xs-exception-absolute: 572px;
+97
View File
@@ -0,0 +1,97 @@
@mixin list-reset() {
list-style: none;
padding: 0;
margin: 0;
}
@mixin margin-padding-reset() {
padding: 0;
margin: 0;
}
@mixin button-reset() {
background-color: transparent;
border: 0;
padding: 0;
}
@mixin scrollbar() {
scrollbar-width: thin;
scrollbar-color: #e4e5e8;
&::-webkit-scrollbar {
width: rem(3);
height: rem(3);
}
&::-webkit-scrollbar-thumb {
background: transparent;
}
&::-webkit-scrollbar-track {
background-color: #e4e5e8;
}
}
@mixin flexbox($direction, $justify, $align) {
display: flex;
flex-direction: $direction;
justify-content: $justify;
align-items: $align;
}
@mixin scrollBar(
$color-track,
$color-thumb,
$width: rem(10),
$height: rem(10)
) {
// firefox
scrollbar-width: thin; /* "auto" или "thin" */
scrollbar-color: $color-track $color-thumb;
&::-webkit-scrollbar {
width: $width; /* ширина scrollbar */
height: $height;
}
&::-webkit-scrollbar-track {
background: $color-track; /* цвет дорожки */
}
&::-webkit-scrollbar-thumb {
background-color: $color-thumb; /* цвет плашки */
border: 0 solid #fff; /* padding вокруг плашки */
}
}
@mixin mediaMax($mediaWidth) {
@media only screen and (max-width: $mediaWidth - 1) {
@content;
}
}
@mixin mediaMin($mediaWidth) {
@media only screen and (min-width: $mediaWidth) {
@content;
}
}
@mixin mediaDistance($mediaWidthMin, $mediaWidthMax) {
@media only screen and (min-width: $mediaWidthMin) and (max-width: ($mediaWidthMax - 1)) {
@content;
}
}
@mixin isLoading(
$duration: 0s,
$bgc: #dedede,
$gradientFirst: #f1f1f1,
$gradientSecond: #d5d5d5
) {
background: $bgc;
background: linear-gradient(
110deg,
$gradientSecond 8%,
$gradientFirst 18%,
$gradientSecond 33%
);
background-size: 200% 100%;
animation: 1.5s shine $duration linear infinite;
}
View File
Whitespace-only changes.
-6
View File
@@ -1,6 +0,0 @@
export { default as car } from './car.jpeg';
export { default as newsMock } from './newsMock.png';
export { default as scb } from './scb.svg';
export { default as fileUpload } from './fileUpload.svg';
export { default as arrow } from './arrow.svg';
export { default as labMock } from './labMock.jpeg';
-49
View File
@@ -1,49 +0,0 @@
@import "./theme.scss";
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');
input {
border: none;
}
.hopeui_style-breadcrumb {
display: none !important;
}
body {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body, input, textarea {
font-family: Montserrat;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
a {
text-decoration: none;
}
.btn {
display: block;
width: fit-content;
padding: 16px 24px;
border-radius: 8px;
font-size: 20px;
font-weight: 600;
line-height: 24px;
color: $btn-primary-text;
background: $btn-primary-bg;
background-size: 200%;
transition: .5s;
}
.btn:hover {
background-position: 100%;
}
-22
View File
@@ -1,22 +0,0 @@
//Цвета
$bg-primary: white;
$bg-secondary: #343434;
$bg-footer: #222222;
$bg-form: #EDEDED;
$bg-card-lab: black;
$bg-image: rgba(0, 0, 0, .75);
$text-primary: black;
$text-secondary: white;
$text-card-project: #767676;
$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);
// Размеры
$navbar-height: 60px;
$navbar-height-mini: 30px;
$navbar-padding-tb: 10px;
@@ -1,59 +0,0 @@
import { Form } from "react-router-dom";
import Field from "../Field";
import "./ContactForm.styles.scss";
import { fileUpload } from "../../assets/images";
const mock = [
{
id: 1,
type: "text",
name: "name",
placeholder: "Имя",
},
{
id: 2,
type: "email",
name: "email",
placeholder: "E-mail",
},
{
id: 3,
type: "textarea",
name: "text",
placeholder: "Опишите в этом поле свой проект и, по возможности, прикрепите файл с ТЗ",
},
{
id: 4,
type: "file",
name: "file",
icon: fileUpload,
},
{
id: 5,
type: "submit",
}
];
function ContactForm({ fields = mock }) {
return (
<Form method="post" className="half contact-form">
<h2>Свяжитесь с нами!</h2>
<div className="inputs">
{fields.map(item =>
<Field
key={item.id}
type={item.type}
name={item.name}
placeholder={item.placeholder}
icon={item.icon}
/>
)}
</div>
</Form>
);
}
export default ContactForm;
@@ -1,31 +0,0 @@
@import "../../assets/styles/theme.scss";
.contact-form {
padding: 20px 22px;
border-radius: 16px;
background-color: $bg-form;
h2 {
margin-top: 0;
font-size: 26px;
font-weight: 500;
line-height: 30px;
}
.inputs {
display: flex;
flex-direction: column;
gap: 14px;
.submit {
width: 100%;
cursor: pointer;
padding: 12px;
font-size: 18px;
line-height: normal;
}
}
}
-36
View File
@@ -1,36 +0,0 @@
import "./Field.styles.scss";
function Field({ type, name, placeholder, icon }) {
const className = type === "submit" ? "submit btn"
: type === "textarea" ? "field big"
: "field";
return (
<>
{type === "textarea" ? (
<textarea
className={className}
name={name}
placeholder={placeholder}
/>
) : type === "file" ? (
<label className="file-input">
<input type="file" name="file" />
<div className="upload-file-btn">
<img src={icon} alt="" className="icon" />
<span>Прикрепить файл</span>
</div>
</label>
) : (
<input
className={className}
type={type}
name={name}
placeholder={placeholder}
/>
)}
</>
);
}
export default Field;
-47
View File
@@ -1,47 +0,0 @@
.field {
padding: 12px 16px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 400;
}
.field.big {
height: 200px;
line-height: 30px;
resize: none;
}
.file-input {
position: relative;
width: fit-content;
input {
position: absolute;
z-index: -1;
opacity: 0;
display: block;
width: 0;
height: 0;
}
.upload-file-btn {
display: flex;
cursor: pointer;
.icon {
margin-right: 6px;
height: 22px;
}
span {
display: inline-block;
font-size: 18px;
}
}
}
.file-input input:focus + .upload-file-btn {
outline: -webkit-focus-ring-color auto 1px;
}
-56
View File
@@ -1,56 +0,0 @@
import { useState, useEffect } from 'react';
import FooterLink from './FooterLink';
import FooterContacts from './FooterContacts';
import { getMedia } from '../../api';
import { scb as logo } from '../../assets/images';
import { iconIctis, iconSfedu, iconVK } from '../../assets/images/footer';
import './Footer.styles.scss';
const mockLinks = {
ictis: {
image: iconIctis,
to: "https://ictis.sfedu.ru",
},
sfedu: {
image: iconSfedu,
to: "https://sfedu.ru",
},
vk: {
image: iconVK,
to: "https://vk.com/skbkit",
},
};
const mockContacts = {
email: "skb@sfedu.ru",
address: "г. Таганрог, пер. Тургеневский, 44",
phone: "+7 (911) 8888-88-88",
};
function Footer({ links = mockLinks, contacts = mockContacts }) {
const [mediaList, setMediaList] = useState(links);
useEffect(() => {
const loadData = async () => {
const newMediaList = await getMedia('footer', mediaList);
setMediaList(newMediaList);
};
loadData();
}, []);
return (
<footer className="footer">
<div className="logo-container">
<img className="logo" alt="logo" src={ logo } />
</div>
<FooterContacts contacts={ contacts } />
<div className="links">
{ Object.keys(mediaList).map(link => <FooterLink link={ mediaList[link] } key={ mediaList[link].id } />) }
</div>
</footer>
);
}
export default Footer;
-60
View File
@@ -1,60 +0,0 @@
@import "../../assets/styles/theme.scss";
.footer {
display: flex;
justify-content: space-between;
align-items: center;
height: 100px;
padding: 0 10%;
margin: 0;
background: $bg-footer;
.logo-container {
height: 70%;
max-width: 30%;
.logo {
height: 100%;
width: 100%;
}
}
.contacts {
display: flex;
flex-direction: column;
justify-content: space-between;
max-height: 70%;
height: 70%;
color: $text-secondary;
font-size: 16px;
font-weight: 400;
p {
margin: 0;
}
}
.links {
display: flex;
gap: 20px;
.link {
display: flex;
justify-content: center;
align-items: center;
width: 60px;
aspect-ratio: 1;
border-radius: 100%;
background-color: $bg-primary;
.icon {
width: 80%;
height: 80%;
object-fit: contain;
}
}
}
}
-11
View File
@@ -1,11 +0,0 @@
function FooterContacts({ contacts }) {
return (
<div className="contacts">
<p>{ contacts.email }</p>
<p>{ contacts.address }</p>
<p>{ contacts.phone }</p>
</div>
);
}
export default FooterContacts;
-11
View File
@@ -1,11 +0,0 @@
import { Link } from "react-router-dom";
function FooterLink({ link }) {
return (
<Link to={ link.to } className="link" target="_blank">
<img src={ link.image } alt='icon' className='icon'/>
</Link>
);
}
export default FooterLink;
-47
View File
@@ -1,47 +0,0 @@
import NavbarLink from './NavbarLink';
import { scb as logo } from '../../assets/images';
import './Navbar.styles.scss';
const mock = [
{
text: "НОВОСТИ",
to: "/news",
},
{
text: "О НАС",
to: "/aboutus",
},
{
text: "ЛАБОРАТОРИИ",
to: "/labs",
},
{
text: "ПРОЕКТЫ",
to: "/projects",
},
{
text: "КОНТАКТЫ",
to: "/contact",
},
{
text: "ИКТИБ",
to: "https://ictis.sfedu.ru",
newTab: true,
},
];
function Navbar({ links = mock }) {
return (
<div id="navbar">
<NavbarLink className="logo-container" link={{ to: "/" }} >
<img src={logo} className="logo" alt="SCB logo" />
</NavbarLink>
<div className="bar">
{links.map((link, index) => <NavbarLink link={link} key={index} />)}
</div>
</div>
);
}
export default Navbar;
-50
View File
@@ -1,50 +0,0 @@
@import "../../assets/styles/theme.scss";
#navbar {
position: fixed;
top: 0;
width: 80%;
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;
.nav-link:has(> .logo) {
height: 100%;
.logo {
width: 100%;
height: 100%;
}
}
.bar {
display: flex;
align-items: center;
.nav-link {
font-size: 16px;
font-weight: 500;
line-height: 20px;
letter-spacing: 0em;
padding: .25em;
margin-left: 40px;
color: $text-secondary;
text-decoration: none;
text-wrap: nowrap;
}
.nav-link::after {
background: $text-secondary;
}
}
}
#navbar.transparent{
background-color: transparent;
}
-24
View File
@@ -1,24 +0,0 @@
import { NavLink } from "react-router-dom";
import { Children } from "react";
function NavbarLink({ link, children }) {
return (
<NavLink
className={({ isActive, isPending }) =>
`nav-link ${isActive ? 'active' : isPending ? 'disabled' : ''
}`
}
to={link.to}
target={link.newTab && '_blank'}
>
{link.text}
{Children.map(children, (child) => (
<>
{child}
</>
))}
</NavLink >
);
}
export default NavbarLink;
-70
View File
@@ -1,70 +0,0 @@
import { useEffect, useState, createContext } from 'react';
import Arrows from './components/Arrows';
import SlidesList from './components/SlidesList';
import Dots from './components/Dots';
import { getMedia } from '../../api';
import './Slider.styles.scss';
export const SliderContext = createContext();
function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
const [mediaList, setMediaList] = useState([]);
const [slide, setSlide] = useState(0);
useEffect(() => {
const loadData = async () => {
const newMediaList = await getMedia('gallery');
setMediaList(newMediaList);
};
loadData();
}, []);
const changeSlide = (direction = 1) => {
let slideNumber = 0;
if (slide + direction < 0) {
slideNumber = mediaList.length - 1;
} else {
slideNumber = (slide + direction) % mediaList.length;
}
setSlide(slideNumber);
};
const goToSlide = (number) => {
setSlide(number % mediaList.length);
}
useEffect(() => {
if (!autoPlay) return;
const interval = setInterval(() => {
changeSlide(1);
}, autoPlayTime);
return () => {
clearInterval(interval);
};
}, [mediaList.length, slide]);
return (
<div className="slider">
<SliderContext.Provider
value={{
goToSlide,
changeSlide,
slidesCount: mediaList.length,
slideNumber: slide,
mediaList
}}
>
<Arrows />
<SlidesList />
{/* <Dots /> */}
</SliderContext.Provider>
</div>
);
}
export default Slider;
-28
View File
@@ -1,28 +0,0 @@
.slider {
overflow: hidden;
position: relative;
& .slide-list {
display: flex;
align-items: center;
width: 100%;
height: 100%;
transition: transform 0.5s ease-in-out;
margin: 0 auto;
& .slide {
flex: 1 0 100%;
position: relative;
& .slide-image {
display: flex;
max-height: 60vh;
max-width: calc(100% - 2 * (15% + 30px));
margin: 0 auto;
border-radius: 8px;
}
}
}
}
-25
View File
@@ -1,25 +0,0 @@
import { Link } from "react-router-dom";
function UsersWP({ contacts }) {
return (
<div id="UsersWP">
{contacts.length ? (
<ul className="nav nav-pills nav-fill flex-column">
{contacts.map(contact => (
<li key={contact.id} className="nav-item text-start">
<Link className="nav-link" to={`contacts/${contact.id}`}>
{contact.name ? <>{contact.name}</> : <i>No Name</i>}{' '}
</Link>
</li>
))}
</ul>
) : (
<p>
<i>No contacts</i>
</p>
)}
</div>
);
}
export default UsersWP;
-1
View File
@@ -1 +0,0 @@
export { default } from './UsersWP';
-21
View File
@@ -1,21 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { createHashRouter, RouterProvider } from 'react-router-dom';
import routes from './routes';
import reportWebVitals from './reportWebVitals';
import './assets/styles/global.scss';
const router = createHashRouter(routes);
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
-30
View File
@@ -1,30 +0,0 @@
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;
+9
View File
@@ -0,0 +1,9 @@
import App from "@/app/App";
import React from "react";
import ReactDOM from "react-dom/client";
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
+11
View File
@@ -0,0 +1,11 @@
import { skbEndpoint } from "@/shared/api/wp-client";
export const submitContactForm = async (formData: FormData) => {
const response = await fetch(`${skbEndpoint}skbkit/v1/sendcontactform`, {
method: "POST",
body: formData,
});
if (!response.ok) throw new Error("Form submission failed");
return response;
};
@@ -0,0 +1,10 @@
import { useMutation } from "@tanstack/react-query";
import { submitContactForm } from "../api/post";
export const useContactForm = () => {
return useMutation({
mutationFn: submitContactForm,
onSuccess: () => console.log("Форма успешно отправлена"),
onError: (error: Error) => console.error("Ошибка отправки:", error),
});
};
+4
View File
@@ -0,0 +1,4 @@
export { useMedia } from "./media/hooks/useMedia";
export { usePostById } from "./posts/hooks/usePostById";
export { useNews } from "./news/hooks/useNews";
export { useContactForm } from "./contact/hooks/useContactForm";
+49
View File
@@ -0,0 +1,49 @@
import { wp } from "@/shared/api/wp-client";
import { WPv2 } from "@/shared/types/app";
export interface MediaItem {
id: number;
src: string;
category: string;
name: string;
}
/**
* Функция для получения всех медиафайлов с учетом пагинации
*/
export const fetchMedia = async (): Promise<MediaItem[]> => {
let page = 1;
let allMedia: MediaItem[] = [];
let hasMore = true;
while (hasMore) {
try {
// Запрашиваем медиа с указанной страницы
const media = (await wp.media().page(page)) as WPv2.Media[];
console.log('media', media);
// Преобразуем данные и добавляем в общий массив
const transformedMedia = media.map(({ id, source_url, alt_text }) => {
const [category = "uncategorized", name = "unknown"] =
alt_text?.split("_") || [];
return { id, src: source_url, category, name };
});
allMedia = [...allMedia, ...transformedMedia];
// Если это последняя страница
if (media._paging.totalPages === page) {
hasMore = false;
break;
}
page++; // Переходим на следующую страницу
} catch (error) {
// Если произошла ошибка (например, страница не найдена), завершаем цикл
hasMore = false;
console.error("Ошибка при загрузке медиа:", error);
}
}
return allMedia;
};
+10
View File
@@ -0,0 +1,10 @@
import { fetchMedia } from "@/modules/media/api/get";
import { useQuery } from "@tanstack/react-query";
export const useMedia = () => {
return useQuery({
queryKey: ["media"],
queryFn: fetchMedia,
staleTime: 1000 * 60 * 5, // 5 минут
});
};
+27
View File
@@ -0,0 +1,27 @@
import { skbEndpoint } from "@/shared/api/wp-client";
import { SKBKit } from "@/shared/types/app";
export const fetchNews = async <T = SKBKit.News[]>(params?: {
count?: number;
offset?: number;
}): Promise<SKBKit.ApiResponse<T>> => {
const url = new URL(`${skbEndpoint}skbkit/v1/getnews`);
if (params) {
if (params.count) url.searchParams.set("count", params.count.toString());
if (params.offset) url.searchParams.set("offset", params.offset.toString());
}
const response = await fetch(url.toString());
const data: T = await response.json();
return {
data,
headers: {
"x-wp-total": response.headers.get("x-wp-total") || "0",
"x-wp-totalpages": response.headers.get("x-wp-totalpages") || "0",
},
status: response.status,
statusText: response.statusText,
};
};
+11
View File
@@ -0,0 +1,11 @@
import { fetchNews } from "@/modules/news/api/get";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
export const useNews = (params?: { count?: number; offset?: number }) => {
return useQuery({
queryKey: ["news", params],
queryFn: () => fetchNews(params),
select: (news) => news.data,
placeholderData: keepPreviousData,
});
};
+17
View File
@@ -0,0 +1,17 @@
import { useQuery } from "@tanstack/react-query";
import { skbEndpoint } from "@/shared/api/wp-client";
import { SKBKit } from "@/shared/types/app";
export const fetchNewsById = async (id: string): Promise<SKBKit.News> => {
const response = await fetch(`${skbEndpoint}skbkit/v1/getnewsbyid?id=${id}`);
if (!response.ok) throw new Error("Ошибка при загрузке новости");
const data = await response.json();
return data;
};
export const useNewsById = (id: string) => {
return useQuery<SKBKit.News>({
queryKey: ["news", id],
queryFn: () => fetchNewsById(id),
enabled: !!id,
});
};
@@ -0,0 +1,29 @@
// posts/api/get.ts
import { wp } from "@/shared/api/wp-client";
import { parseContent } from "@/shared/api/parseContent";
import { App, WPv2 } from "@/shared/types/app";
export const fetchPostById = async (id: number): Promise<App.WpPostPage> => {
const [post, categories] = await Promise.all([
wp.posts().id(id).get() as Promise<WPv2.Post>,
wp.categories().get() as Promise<WPv2.Category[]>
]);
const categoryMap = new Map<number, string>(
categories.map((c) => [c.id, c.name])
);
const postCategories = post.categories.map(
(id) => categoryMap.get(id) || ""
);
const result: App.WpPostPage = {
id: post.id,
title: post.title.rendered,
content: parseContent(post.content.rendered),
categories: postCategories,
tag: post.tags[0],
};
return result;
};
@@ -0,0 +1,41 @@
// posts/api/get/getPostProjects.ts
import { wp } from "@/shared/api/wp-client";
import { fetchMedia } from "@/modules/media/api/get";
import { App, WPv2 } from "@/shared/types/app";
export const fetchPostProjects = async (tag: number): Promise<App.Card[]> => {
const categories = await wp.categories().get() as WPv2.Category[];
const catId = categories.find(item => item.name === "projects")?.id || -1;
const postsRequest = wp.posts();
if (tag !== -1) {
postsRequest.tags(tag);
}
const [posts, mediaLibrary] = await Promise.all([
postsRequest.get() as Promise<WPv2.Post[]>,
fetchMedia(),
]);
const labIndex = posts.findIndex((post) => {
return !post.categories.includes(catId);
});
posts.splice(labIndex, 1);
const result: App.Card[] = [];
for (const post of posts) {
const image = mediaLibrary.find((item) => item.id === post.featured_media);
const newPost: App.Card = {
id: post.id,
title: post.title.rendered,
//tag: post.tags[0] || -1,
preview: image?.src || null,
};
result.push(newPost);
}
return result;
};
+63
View File
@@ -0,0 +1,63 @@
// posts/api/get.ts
import { wp } from "@/shared/api/wp-client";
import { fetchMedia } from "@/modules/media/api/get";
import { App, WPv2 } from "@/shared/types/app";
import Parse from "html-react-parser";
import { parseContent } from "@/shared/api/parseContent";
export const fetchPosts = async (): Promise<App.PostsResult> => {
const [posts, categories, mediaLibrary] = await Promise.all([
wp.posts().param("per_page", 100).get() as Promise<WPv2.Post[]>,
wp.categories().get() as Promise<WPv2.Category[]>,
fetchMedia(),
]);
const categoryMap = new Map<number, string>(
categories.map((c) => [c.id, c.name])
);
const result: App.PostsResult = {
projects: {},
labs: {},
other: [],
};
for (const post of posts) {
const image = mediaLibrary.find((item) => item.id === post.featured_media);
const postCategories = post.categories.map(
(id) => categoryMap.get(id) || ""
);
const newPost: App.WpPost = {
id: post.id,
title: post.title.rendered,
categories: postCategories,
};
if (postCategories.includes("projects")) {
const newProject: App.Card = {
...newPost,
preview: image?.src || null,
};
result.projects[post.id] = newProject;
} else if (postCategories.includes("labs")) {
//@ts-ignore
const excerptElement = Parse(post.excerpt.rendered)[0];
const newLab: App.LabCard = {
...newPost,
preview: image?.src || null,
previewText: (excerptElement as any)?.props?.children || "",
};
result.labs[post.id] = newLab;
} else {
const newWpPostPage: App.WpPostPage = {
...newPost,
content: parseContent(post.content.rendered),
tag: post.tags[0],
};
result.other.push(newWpPostPage);
}
}
return result;
};
+12
View File
@@ -0,0 +1,12 @@
// posts/api/usePostById.ts
import { fetchPostById } from "@/modules/posts/api/get/fetchPostById";
import { useQuery } from "@tanstack/react-query";
import { App } from "@/shared/types/app";
export const usePostById = (id: number) => {
return useQuery<App.WpPostPage>({
queryKey: ["post", id],
queryFn: () => fetchPostById(id),
enabled: !!id,
});
};
@@ -0,0 +1,12 @@
// posts/api/useProjects.ts
import { fetchPostProjects } from "@/modules/posts/api/get/fetchPostProjects";
import { useQuery } from "@tanstack/react-query";
import { App } from "@/shared/types/app";
export const usePostProjects = (tag: number) => {
return useQuery<App.Card[]>({
queryKey: ["projects", tag],
queryFn: () => fetchPostProjects(tag),
enabled: !!tag,
});
};
+12
View File
@@ -0,0 +1,12 @@
// posts/api/usePosts.ts
import { fetchPosts } from "@/modules/posts/api/get/fetchPosts";
import { App } from "@/shared/types/app";
import { useQuery } from "@tanstack/react-query";
export const usePosts = () => {
return useQuery<App.PostsResult>({
queryKey: ["posts"],
queryFn: fetchPosts,
staleTime: 1000 * 60 * 5,
});
};
-16
View File
@@ -1,16 +0,0 @@
import { PageContent, PageHeader } from "../components";
function AboutUs() {
return (
<>
<PageHeader>
<h1>About us</h1>
</PageHeader>
<PageContent>
</PageContent>
</>
);
}
export default AboutUs;
+5
View File
@@ -0,0 +1,5 @@
import { CategoryPage } from "@/widgets/CategoryPage/CategoryPage";
export default function AboutUs() {
return <CategoryPage category="aboutus" />;
}
View File
File renamed without changes.
+190
View File
@@ -0,0 +1,190 @@
export namespace WPv2 {
export interface Title {
raw: string;
rendered: string;
}
export interface Content {
raw: string;
rendered: string;
block_version?: number;
protected?: boolean;
}
export interface Excerpt {
raw: string;
rendered: string;
protected?: boolean;
}
export interface Meta {
inline_featured_image?: boolean;
footnotes?: string;
[key: string]: any;
}
export interface Links {
self: Link[];
collection: Link[];
about?: Link[];
author?: EmbeddedLink[];
replies?: EmbeddedLink[];
"version-history"?: VersionHistoryLink[];
"predecessor-version"?: VersionLink[];
"wp:featuredmedia"?: EmbeddedLink[];
"wp:attachment"?: Link[];
"wp:term"?: TermLink[];
curies?: Cury[];
}
export interface Link {
href: string;
targetHints?: {
allow: ("GET" | "POST" | "PUT" | "PATCH" | "DELETE")[];
};
}
export interface EmbeddedLink extends Link {
embeddable: boolean;
}
export interface VersionHistoryLink {
count: number;
href: string;
}
export interface VersionLink {
id: number;
href: string;
}
export interface TermLink {
taxonomy: string;
embeddable: boolean;
href: string;
}
export interface Cury {
name: "wp";
href: string;
templated: true;
}
export interface Post {
id: number;
date: string;
date_gmt: string;
guid: { rendered: string };
modified: string;
modified_gmt: string;
slug: string;
status: "publish" | "draft" | "inherit" | string;
type: "post" | "page" | "attachment" | string;
link: string;
title: Title;
content: Content;
excerpt: Excerpt;
author: number;
featured_media?: number;
comment_status: "open" | "closed";
ping_status: "open" | "closed";
sticky: boolean;
template: string;
format: "standard" | string;
meta: Meta;
categories: number[];
tags: number[];
class_list: string[];
_links: Links;
}
export interface GetPostsParams {
context?: "view" | "embed" | "edit";
page?: number;
per_page?: number;
search?: string;
after?: string;
before?: string;
author?: number[];
author_exclude?: number[];
exclude?: number[];
include?: number[];
offset?: number;
order?: "asc" | "desc";
orderby?:
| "author"
| "date"
| "id"
| "include"
| "modified"
| "parent"
| "relevance"
| "slug"
| "title";
slug?: string[];
status?: string[];
}
export interface CreatePostParams extends Partial<Post> {}
}
export namespace SKBKit {
export interface News {
id: number;
title: string;
content: string;
date: string;
author: string;
categories: string[];
tags: string[];
image_url?: string;
excerpt?: string;
}
export interface GetNewsResponse {
news: News[];
}
export interface GetNewsByIdParams {
id: number;
}
export interface SendContactFormParams {
name: string;
email: string;
message: string;
subject?: string;
phone?: string;
company?: string;
position?: string;
}
export interface Event {
id: number;
title: string;
date: string;
location: string;
description: string;
organizer?: string;
participants?: number;
image_url?: string;
}
export interface GetEventsResponse {
events: Event[];
}
export interface VKCallbackParams {
type: string;
object: any;
group_id: number;
event_id?: string;
}
export interface ApiResponse<T> {
data: T;
headers: Record<string, string>;
status: number;
statusText: string;
}
}
-27
View File
@@ -1,27 +0,0 @@
import { PageContent, PageHeader } from "../components";
function Contact() {
return (
<>
<PageHeader>
<h1>Студенческое конструкторское бюро<br />
"Компьютерное инновационное творчество"</h1>
</PageHeader>
<PageContent>
<div className="contact">
<p>Контактное лицо: Кутковой Владимир Сергеевич</p>
</div>
<form className="form">
<label htmlFor="topic-input">Тема</label>
<input type="text" name="topic" id="topic-input" />
<label htmlFor="email">Почта</label>
<input type="text" name="email-input" id="email-input" />
<label htmlFor="message">Сообщение</label>
<input type="text" name="message-input" id="message-input" />
</form>
</PageContent>
</>
);
}
export default Contact;
+51
View File
@@ -0,0 +1,51 @@
@import "../../widgets/ContactForm/ContactForm.styles.scss";
#page-contact {
.top-block {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
flex: 1 1 50%;
margin-bottom: 2em;
margin-top: 48px;
@media (max-width: 768px) {
margin-top: 0;
}
h1 {
margin-top: 0;
}
div:has(> ymaps) {
ymaps[class*="inner-panes"] {
border-radius: 8px;
}
}
// div:has(> ymaps)
div:has(> ymaps) > * {
width: auto !important;
height: 100% !important;
aspect-ratio: 1;
}
}
.contact-form {
.row {
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
.submit-container {
margin: 0;
max-width: 35%;
}
}
.row > * {
flex: 1 1 calc(50% - ($gap / 2));
}
}
}
+45
View File
@@ -0,0 +1,45 @@
import { YMaps, Map, Placemark } from "@pbe/react-yandex-maps";
import "./Contact.styles.scss";
import ContactForm from "@/widgets/ContactForm";
function Contact() {
return (
<div id="page-contact" className="mainContainer">
<div className="top-block">
<div>
<h1>Контакты</h1>
<div className="contact">
<p>
Контактное лицо:
<br />
Кутковой Владимир Сергеевич
<br />
Руководитель СКБ «КИТ»
<br />
Email: skb@sfedu.ru
<br />
Адрес: г. Таганрог, пер. Тургеневский, 44, ауд. 208
</p>
</div>
</div>
<YMaps>
<Map
defaultState={{
center: [47.20669, 38.929113],
zoom: 13,
controls: ["zoomControl", "fullscreenControl"],
}}
modules={["control.ZoomControl", "control.FullscreenControl"]}
>
<Placemark defaultGeometry={[47.20669, 38.929113]} />
</Map>
</YMaps>
</div>
<ContactForm />
</div>
);
}
export default Contact;
View File
File renamed without changes.
-19
View File
@@ -1,19 +0,0 @@
import { useRouteError } from 'react-router-dom'
export default function ErrorPage() {
const error = useRouteError()
console.error(error)
return (
<div
className="align-items-center bg-white d-flex flex-column flex-grow-1 justify-content-center"
id="error-page"
>
<h1 className="mt-0">Oops!</h1>
<p>Sorry, an unexpected error has occurred.</p>
<p>
<i>{error.statusText || error.message}</i>
</p>
</div>
)
}
-1
View File
@@ -1 +0,0 @@
export { default } from './ErrorPage';
-11
View File
@@ -1,11 +0,0 @@
import { PageHeader } from "../components";
function Labs() {
return (
<PageHeader>
</PageHeader>
);
}
export default Labs;
-1
View File
@@ -1 +0,0 @@
export { default } from './Labs';
-44
View File
@@ -1,44 +0,0 @@
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 { PageContent, PageHeader } from '../components';
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 (
<>
<PageHeader id="mainpageheader" ref={element => setRef(element)}>
<div className="container">
<h1>Думай иначе, будь креативным!</h1>
<h2>Студенческое конструкторское бюро<br />
"Компьютерное инновационное творчество"</h2>
<HashLink smooth to="#contact-us" className="btn">Связаться с нами</HashLink>
</div>
</PageHeader>
<PageContent>
<News />
<Projects />
<Labs />
<Partners />
<Gallery />
<ContactUs />
</PageContent>
</>
);
}
export default Main;
-40
View File
@@ -1,40 +0,0 @@
@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;
}
}
}
}
@@ -1,14 +0,0 @@
import { Link } from 'react-router-dom';
function BlockHeading({ heading, link, linkText }) {
return (
<div className="heading">
<h1>{heading}</h1>
{link && linkText &&
<Link to={link} target="_blank">{linkText} &rarr;</Link>
}
</div>
);
}
export default BlockHeading;
@@ -1 +0,0 @@
export { default } from './BlockHeading';
@@ -1,14 +0,0 @@
import ContactForm from "../../../../components/ContactForm"
import './ContactUs.styles.scss';
function ContactUs() {
return (
<div className="block" id="contact-us">
<h1 className="half">Нужна помощь?<br/> Команда способных IT-специалистов готова вам помочь!</h1>
<ContactForm />
</div>
);
}
export default ContactUs;
@@ -1,14 +0,0 @@
#contact-us {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 60px;
.half {
flex: 0 0 50%;
}
.contact-form {
max-width: 500px;
}
}
Loaded 100 of 267 files, more files were not shown because too many files have changed in this diff. Show more