diff --git a/SurveyFrontend/package-lock.json b/SurveyFrontend/package-lock.json index 38b21e5..24c315c 100644 --- a/SurveyFrontend/package-lock.json +++ b/SurveyFrontend/package-lock.json @@ -11,6 +11,7 @@ "@formkit/tempo": "^0.1.2", "react": "^19.0.0", "react-dom": "^19.0.0", + "react-router-dom": "^7.5.2", "uuid": "^11.1.0" }, "devDependencies": { @@ -1731,6 +1732,15 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/cookie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2626,6 +2636,45 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.5.2.tgz", + "integrity": "sha512-9Rw8r199klMnlGZ8VAsV/I8WrIF6IyJ90JQUdboupx1cdkgYqwnrYjH+I/nY/7cA1X5zia4mDJqH36npP7sxGQ==", + "license": "MIT", + "dependencies": { + "cookie": "^1.0.1", + "set-cookie-parser": "^2.6.0", + "turbo-stream": "2.4.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, + "node_modules/react-router-dom": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.5.2.tgz", + "integrity": "sha512-yk1XW8Fj7gK7flpYBXF3yzd2NbX6P7Kxjvs2b5nu1M04rb5pg/Zc4fGdBNTeT4eDYL2bvzWNyKaIMJX/RKHTTg==", + "license": "MIT", + "dependencies": { + "react-router": "7.5.2" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2720,6 +2769,12 @@ "semver": "bin/semver.js" } }, + "node_modules/set-cookie-parser": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz", + "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==", + "license": "MIT" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -2798,6 +2853,12 @@ "typescript": ">=4.8.4" } }, + "node_modules/turbo-stream": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/turbo-stream/-/turbo-stream-2.4.0.tgz", + "integrity": "sha512-FHncC10WpBd2eOmGwpmQsWLDoK4cqsA/UT/GqNoaKOQnT8uzhtCbg3EoUDMvqpOSAI0S26mr0rkjzbOO6S3v1g==", + "license": "ISC" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/SurveyFrontend/package.json b/SurveyFrontend/package.json index 150e7f9..632ec27 100644 --- a/SurveyFrontend/package.json +++ b/SurveyFrontend/package.json @@ -13,6 +13,7 @@ "@formkit/tempo": "^0.1.2", "react": "^19.0.0", "react-dom": "^19.0.0", + "react-router-dom": "^7.5.2", "uuid": "^11.1.0" }, "devDependencies": { diff --git a/SurveyFrontend/src/App.tsx b/SurveyFrontend/src/App.tsx index f5a93c5..0ea3b92 100644 --- a/SurveyFrontend/src/App.tsx +++ b/SurveyFrontend/src/App.tsx @@ -1,11 +1,22 @@ -import React from 'react'; import './App.css' -import Questions from './pages/Questions.tsx' +import {BrowserRouter, Navigate, Route, Routes} from "react-router-dom"; +import {SurveyEditingPage} from "./pages/SurveyEditingPage/SurveyEditingPage.tsx"; +import Survey from "./components/Survey/Survey.tsx"; +import SettingSurvey from "./components/SettingSurvey/SettingSurvey.tsx"; -const App: React.FC = () => { - return ( - - ) +const App = () => { + return( + + + } /> + + }> + } /> + } /> + + + + ); } diff --git a/SurveyFrontend/src/components/Header/Header.module.css b/SurveyFrontend/src/components/Header/Header.module.css index 2f4a225..b73ac84 100644 --- a/SurveyFrontend/src/components/Header/Header.module.css +++ b/SurveyFrontend/src/components/Header/Header.module.css @@ -5,4 +5,39 @@ padding: 0; width: 100%; display: flex; +} + +.pagesNav{ + display: flex; + gap: 60px; + list-style: none; + align-items: center; + margin-right: 40%; + +} + +.pageLink{ + font-size: 24px; + font-weight: 600; + color: #2A6DAE; + padding: 0; + border: none; + background-color: #ffffff; + white-space: nowrap; + text-decoration: none; +} + +.active{ + margin-bottom: -15px; + color: #000000; + text-decoration-color: #3881C8; +} + +.activeLine{ + display: block; + margin-top: 5px; + border: 1px solid #000000; + width: 50%; + padding: 0; + box-shadow: 0 1px 4px 0 #3881C8; } \ No newline at end of file diff --git a/SurveyFrontend/src/components/Header/Header.tsx b/SurveyFrontend/src/components/Header/Header.tsx index 84cbf0b..06ddfd2 100644 --- a/SurveyFrontend/src/components/Header/Header.tsx +++ b/SurveyFrontend/src/components/Header/Header.tsx @@ -1,27 +1,33 @@ -import React, {useState} from "react"; +import React from "react"; import Logo from "../Logo/Logo.tsx"; import Account from "../Account/Account.tsx"; import styles from './Header.module.css' -import SurveyPagesList from "../SurveyPagesList/SurveyPagesList.tsx"; +import {Link, useLocation} from "react-router-dom"; const Header: React.FC = () => { - const [activePage, setActivePage] = useState('Создать опрос'); - - const handlePageClick = (name: string)=> { - setActivePage(name); - } + const location = useLocation(); + const isCreateSurveyActive = location.pathname.includes('/survey/edit'); + const isMySurveyActive = location.pathname === '/my-surveys'; return (
- - + +
diff --git a/SurveyFrontend/src/components/Navigation/Navigation.tsx b/SurveyFrontend/src/components/Navigation/Navigation.tsx index 82eb3bb..d1261ee 100644 --- a/SurveyFrontend/src/components/Navigation/Navigation.tsx +++ b/SurveyFrontend/src/components/Navigation/Navigation.tsx @@ -1,15 +1,25 @@ import React from 'react' +import {useLocation, useNavigate} from 'react-router-dom' import styles from './Navigation.module.css' import NavigationItem from "../NavigationItem/NavigationItem.tsx"; import SaveButton from "../SaveButton/SaveButton.tsx"; -interface NavigationProps { - onNavigationClick: (title: string) => void; - activePage: string -} -const Navigation: React.FC = ({onNavigationClick, activePage}) => { - const items: string[] = ['Вопросы', 'Настройки', 'Результаты'] +const Navigation: React.FC = () => { + const location = useLocation(); + const navigate = useNavigate(); + + const activePage = location.pathname.split('/').pop() || 'questions' + + const items = [ + {id: 'questions', title: 'Вопросы'}, + {id: 'settings', title: 'Настройки'}, + {id: 'results', title: 'Результаты'} + ] + + const handleNavigationClick = (padeId: string) => { + navigate(`${padeId}`); + } return (
@@ -17,10 +27,10 @@ const Navigation: React.FC = ({onNavigationClick, activePage})
    {items.map(item => ( onNavigationClick(item)} + key={item.id} + title={item.title} + isActive={activePage === item.id} + onClick={() => handleNavigationClick(item.id)} /> ))}
diff --git a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css index 40b5a44..f2a4fe1 100644 --- a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css +++ b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css @@ -1,8 +1,7 @@ /*SettingSurvey.module.css*/ .settingSurvey{ - width: 65%; - margin-left: 8.9%; + width: 85%; } .startEndTime{ diff --git a/SurveyFrontend/src/components/Survey/Survey.module.css b/SurveyFrontend/src/components/Survey/Survey.module.css index 1b26be4..6281504 100644 --- a/SurveyFrontend/src/components/Survey/Survey.module.css +++ b/SurveyFrontend/src/components/Survey/Survey.module.css @@ -1,6 +1,5 @@ /*Survey.module.css*/ .survey{ - width: 65%; - margin-left: 8.9%; + width: 85%; } \ No newline at end of file diff --git a/SurveyFrontend/src/pages/SurveyEditingPage/SurveyEditingPage.module.css b/SurveyFrontend/src/pages/SurveyEditingPage/SurveyEditingPage.module.css new file mode 100644 index 0000000..ce16b39 --- /dev/null +++ b/SurveyFrontend/src/pages/SurveyEditingPage/SurveyEditingPage.module.css @@ -0,0 +1,17 @@ +/*SurveyEditingPage.module.css*/ + +.layout{ + width: 100%; +} + +.main{ + width: 100%; + min-height: 85vh; + display: flex; + background-color: #F6F6F6; +} + +.content{ + width: 100%; + margin-left: 8.9%; +} \ No newline at end of file diff --git a/SurveyFrontend/src/pages/SurveyEditingPage/SurveyEditingPage.tsx b/SurveyFrontend/src/pages/SurveyEditingPage/SurveyEditingPage.tsx new file mode 100644 index 0000000..e2b19cf --- /dev/null +++ b/SurveyFrontend/src/pages/SurveyEditingPage/SurveyEditingPage.tsx @@ -0,0 +1,18 @@ +import Header from "../../components/Header/Header.tsx"; +import Navigation from "../../components/Navigation/Navigation.tsx"; +import styles from './SurveyEditingPage.module.css' +import { Outlet } from "react-router-dom"; + +export const SurveyEditingPage = () => { + return ( +
+
+
+ +
+ +
+
+
+ ); +}; \ No newline at end of file