routing
This commit is contained in:
parent
eda38247ba
commit
28882e7038
10 changed files with 190 additions and 33 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<div className={styles.header}>
|
||||
<Logo href='' />
|
||||
<SurveyPagesList
|
||||
activePage={activePage}
|
||||
onPageClick = {handlePageClick}
|
||||
/>
|
||||
<Logo href='/' />
|
||||
<nav className={styles.pagesNav}>
|
||||
<Link to='/survey/edit/questions'
|
||||
className={`${styles.pageLink} ${isCreateSurveyActive ? styles.active : ''}`}>
|
||||
Создать опрос
|
||||
{isCreateSurveyActive && <hr className={styles.activeLine}/>}
|
||||
</Link>
|
||||
<Link to='/my-surveys'
|
||||
className={`${styles.pageLink} ${isMySurveyActive ? styles.active : ''}`}>
|
||||
Мои опросы
|
||||
{isMySurveyActive && <hr className={styles.activeLine}/>}
|
||||
</Link>
|
||||
</nav>
|
||||
<Account
|
||||
href=''
|
||||
href='/profile'
|
||||
user='Иванов Иван'
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue