Skip to content

Commit

Permalink
feat: add hiding sidebar nav
Browse files Browse the repository at this point in the history
  • Loading branch information
Menemi committed Sep 5, 2023
1 parent 5063127 commit 779fe58
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 84 deletions.
9 changes: 9 additions & 0 deletions react-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions react-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"boxicons": "^2.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.10.1",
"react-router-dom": "^6.15.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
Expand Down
97 changes: 43 additions & 54 deletions react-client/src/components/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,49 @@
import {NavLink} from "react-router-dom";
import React from "react";
import {activeBlur, nonActiveBlur} from "../utilities/Constants";
import React, {useState} from "react";

export default function Navigation() {
const Navigation = () => {
const [isOpen, setIsOpen] = useState(false);
const toggle = () => setIsOpen(!isOpen);
const menuItem = [
{
path: "/",
name: "Сегодня",
icon: <i className="bx bx-calendar bx-md nav-icon"></i>
},
{
path: "/stats",
name: "Архив данных",
icon: <i className="bx bx-data bx-md nav-icon"></i>
},
{
path: "/last-changes",
name: "Статистика",
icon: <i className="bx bx-stats bx-md nav-icon"></i>
},
{
path: "/doses",
name: "Дозы",
icon: <i className="bx bx-injection bx-md nav-icon"></i>
}
]
return (
<nav className="navigation">
<NavLink className="nav-head" to="/">
<i className="bx bx-book-heart bx-sm nav-icon"></i>
<h1>Дневник диабета</h1>
</NavLink>
<ul className="nav-list">
<li className="nav-item">
<NavLink className="nav-link" to="/"
style={({isActive}) => (
isActive
? activeBlur
: nonActiveBlur
)}>
<i className="bx bx-calendar bx-sm nav-icon"></i>
<h2>Сегодня</h2>
</NavLink>
</li>
<li className="nav-item">
<NavLink className="nav-link" to="/stats"
style={({isActive}) => (
isActive
? activeBlur
: nonActiveBlur
)}>
<i className="bx bx-data bx-sm nav-icon"></i>
<h2>Данные за период времени</h2>
</NavLink>
</li>
<li className="nav-item">
<NavLink className="nav-link" to="/last-changes"
style={({isActive}) => (
isActive
? activeBlur
: nonActiveBlur
)}>
<i className="bx bx-stats bx-sm nav-icon"></i>
<h2>Статистика</h2>
</NavLink>
</li>
<li className="nav-item">
<NavLink className="nav-link" to="/doses"
style={({isActive}) => (
isActive
? activeBlur
: nonActiveBlur
)}>
<i className="bx bx-injection bx-sm nav-icon"></i>
<h2>Дозы</h2>
<div style={{width: isOpen ? "250px" : "68px"}} className="navigation">
<div className="nav-head">
<h1 style={{display: isOpen ? "block" : "none"}}>Дневник диабета</h1>
<i className="bx bx-menu bx-md nav-icon nav-logo"
onClick={toggle}></i>
</div>

{
menuItem.map((item, index) => (
<NavLink to={item.path} key={index} className="nav-link">
{item.icon}
<h2 style={{display: isOpen ? "block" : "none"}} className="nav-item">{item.name}</h2>
</NavLink>
</li>
</ul>
</nav>
))
}
</div>
);
}

export default Navigation;
89 changes: 69 additions & 20 deletions react-client/src/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
* {
font-family: "Segoe UI", serif;
text-decoration: none;
margin: 0;
padding: 0;
}

html {
Expand All @@ -13,60 +15,77 @@ html {
#root {
margin: 0;
height: 100dvh;
display: block;
}

main {
display: flex;
width: 100%;
height: 100%;
}

.navigation {
position: fixed;
height: 100dvh;
width: 250px;
height: 100%;
top: 0;
left: 0;
padding: 2ex;
box-shadow: inset 0 0 0 3000px rgba(150, 150, 150, 0.292);
box-shadow: inset 0 0 0 3000px rgb(50, 50, 50);
color: white;
transition: all 0.35s;
z-index: 100;
}

.nav-head,
.nav-item a {
.nav-head {
display: flex;
align-items: center;
color: white;
padding: 1ex;
}

.nav-item a:hover {
background-color: rgba(255, 255, 255, 0.192);
backdrop-filter: blur(10px);
border-radius: 1ex;
padding: 2ex;
margin-bottom: 4ex;
justify-content: space-between;
align-items: center;
}

.nav-head h1 {
font-size: 18px;
}

.nav-item a h2 {
.nav-item {
font-size: 15px;
}

.navigation ul li {
.nav-link {
display: flex;
color: white;
padding: 2ex;
gap: 2ex;
margin-bottom: 1ex;
align-items: center;
}

.nav-logo:hover {
background-color: rgba(255, 255, 255, 0.192);
backdrop-filter: blur(10px);
border-radius: 0.5rem;
}

.nav-link:hover {
background-color: rgba(255, 255, 255, 0.192);
backdrop-filter: blur(10px);
border-radius: 1ex;
}

.nav-icon {
margin-right: 1ex;
.active {
background: rgba(165, 165, 165, 0.192);
backdrop-filter: blur(10px);
border-radius: 1ex
}

.board-view,
.board-view-centered {
position: relative;
left: 250px;
margin-top: 2ex;
width: calc(100% - 250px);
left: 68px;
width: calc(100% - 56.8px);
display: flex;
justify-content: space-evenly;
height: 100%;
Expand All @@ -79,7 +98,7 @@ main {
.input-stats-area {
position: fixed;
bottom: 25px;
left: 25px;
right: 25px;
height: 200px;
width: 200px;
color: white;
Expand All @@ -90,6 +109,7 @@ main {
display: flex;
flex-direction: column;
justify-content: center;
z-index: 100;
}

.button-stats-area {
Expand Down Expand Up @@ -126,6 +146,7 @@ main {
.column-head-stats {
display: flex;
align-items: center;
margin: 1ex 0;
}

.column-head {
Expand All @@ -148,6 +169,8 @@ main {
align-items: center;
justify-content: center;
height: 5ex;
padding: 0.5ex;
gap: 0.5ex;
border-radius: 1ex;
color: white;
}
Expand Down Expand Up @@ -298,3 +321,29 @@ ul {
padding: 0;
list-style-type: none;
}

@media screen and (max-width: 1180px) {
.board-view {
display: flex;
flex-direction: column;
justify-content: normal;
align-items: center;
gap: 2ex;
}
}

@media screen and (max-width: 820px) {
.input-stats-area {
display: none;
}
}

@media screen and (max-width: 700px) {
.board-view {
left: 0;
width: 100%;
align-items: flex-end;
margin-right: 2ex;
transition: all 0.5s;
}
}
10 changes: 0 additions & 10 deletions react-client/src/utilities/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,3 @@ const prod = {
const Constants = process.env.NODE_ENV === "development" ? dev : prod;

export default Constants;

export const activeBlur = {
background: "rgba(165, 165, 165, 0.192)",
backdropFilter: "blur(10px)",
borderRadius: "1ex"
}

export const nonActiveBlur = {
color: "white"
}

0 comments on commit 779fe58

Please sign in to comment.