diff --git a/src/App.css b/src/App.css index 74b5e05..8f26f4c 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,14 @@ -.App { - text-align: center; -} +/* src/App.module.css */ -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; +.app { display: flex; flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; + min-height: 100vh; /* Минимальная высота страницы равна высоте экрана */ } -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} +.main { + flex: 1; /* Основной контент занимает все доступное пространство */ + padding: 16px; + background-color: #282828; /* Средний темный фон */ + color: #ffffff; /* Белый текст */ +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index f0df069..f92b53c 100644 --- a/src/App.js +++ b/src/App.js @@ -1,24 +1,34 @@ // src/App.js -import React from 'react'; -import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; +import React, { useState } from 'react'; +import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom'; import Header from './components/Header'; import Footer from './components/Footer'; import Register from './components/Register'; -import Login from './components/Login'; // Предполагаем, что у вас будет компонент Login +import Login from './components/Login'; +import Profile from './components/Profile'; import styles from './App.module.css'; -/*sadsad;lkjasd;lksaj*/ - const App = () => { + const [isAuthenticated, setIsAuthenticated] = useState(false); + + const handleLogin = () => { + setIsAuthenticated(true); + }; + + const handleLogout = () => { + setIsAuthenticated(false); + }; + return (
-
+
} /> - } /> {/* Предполагаем, что у вас будет компонент Login */} + : } /> + : } /> } /> {/* Главная страница */}
diff --git a/src/components/Header.js b/src/components/Header.js index 9802745..088d338 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -4,7 +4,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import styles from './Header.module.css'; -const Header = () => { +const Header = ({ isAuthenticated, onLogout }) => { return (
@@ -13,8 +13,10 @@ const Header = () => {
Profile
- Зарегистрироваться - + {!isAuthenticated && Зарегистрироваться} + {isAuthenticated && ( + + )}
); }; diff --git a/src/components/Header.module.css b/src/components/Header.module.css index 2d81347..fcad573 100644 --- a/src/components/Header.module.css +++ b/src/components/Header.module.css @@ -37,6 +37,7 @@ padding: 8px 16px; cursor: pointer; border-radius: 4px; + margin-left: 16px; /* Отступ слева для кнопки "Выход" */ } .logoutButton:hover { diff --git a/src/components/Login.js b/src/components/Login.js index bf81f7e..1f60467 100644 --- a/src/components/Login.js +++ b/src/components/Login.js @@ -1,20 +1,46 @@ // src/components/Login.js -import React from 'react'; +import React, { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import styles from './Login.module.css'; -const Login = () => { +const Login = ({ onLogin }) => { + const [formData, setFormData] = useState({ + login: '', + password: '' + }); + + const navigate = useNavigate(); + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData({ + ...formData, + [name]: value + }); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + // Здесь можно обработать отправку данных, но сейчас они просто уходят "в никуда" + console.log('Login data:', formData); + // Вызываем функцию для входа + onLogin(); + // Переходим на страницу профиля после входа + navigate('/profile'); + }; + return (
-
+

Вход

- +
- +
diff --git a/src/components/Login.module.css b/src/components/Login.module.css index aa91a40..0648f8c 100644 --- a/src/components/Login.module.css +++ b/src/components/Login.module.css @@ -6,6 +6,7 @@ align-items: center; height: 100vh; background-color: #1a1a1a; /* Темный фон */ + padding: 16px; /* Добавляем отступы */ } .loginForm { diff --git a/src/components/Profile.js b/src/components/Profile.js new file mode 100644 index 0000000..465bb7d --- /dev/null +++ b/src/components/Profile.js @@ -0,0 +1,15 @@ +// src/components/Profile.js + +import React from 'react'; +import styles from './Profile.module.css'; + +const Profile = () => { + return ( +
+

Профиль

+

Добро пожаловать в ваш профиль!

+
+ ); +}; + +export default Profile; \ No newline at end of file diff --git a/src/components/Profile.module.css b/src/components/Profile.module.css new file mode 100644 index 0000000..49f17b8 --- /dev/null +++ b/src/components/Profile.module.css @@ -0,0 +1,20 @@ +/* src/components/Profile.module.css */ + +.profileContainer { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + background-color: #1a1a1a; /* Темный фон */ + color: #ffffff; /* Белый текст */ + padding: 16px; /* Добавляем отступы */ +} + +.profileContainer h2 { + margin-bottom: 16px; +} + +.profileContainer p { + font-size: 18px; +} \ No newline at end of file diff --git a/src/components/Register.js b/src/components/Register.js index e007a01..dbc239a 100644 --- a/src/components/Register.js +++ b/src/components/Register.js @@ -25,8 +25,8 @@ const Register = () => { e.preventDefault(); // Здесь можно обработать отправку данных, но сейчас они просто уходят "в никуда" console.log('Registration data:', formData); - // Переходим на страницу входа после регистрации - navigate('/login'); + // Переходим на страницу профиля после регистрации + navigate('/profile'); }; return ( diff --git a/src/components/Register.module.css b/src/components/Register.module.css index ab030f5..48add2f 100644 --- a/src/components/Register.module.css +++ b/src/components/Register.module.css @@ -6,6 +6,7 @@ align-items: center; height: 100vh; background-color: #1a1a1a; /* Темный фон */ + padding: 16px; /* Добавляем отступы */ } .registerForm {