-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): add style for hamburger menu and its components
functionality is still a WIP
- Loading branch information
Showing
9 changed files
with
219 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
.hamburger-container { | ||
grid-row: 2 / 3; | ||
grid-column: 2; | ||
margin-top: 2em; | ||
|
||
height: 22px; | ||
width: 20px; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-evenly; | ||
|
||
border: none; | ||
cursor: pointer; | ||
background-color: transparent; | ||
z-index: 10; | ||
} | ||
|
||
.hamburger-line { | ||
min-width: 100%; | ||
height: 1px; | ||
|
||
border: 1px solid var(--text-primary); | ||
} | ||
|
||
.menu { | ||
position: absolute; | ||
top: 4em; | ||
left: -320px; | ||
z-index: 9; | ||
|
||
width: 300px; | ||
height: 400px; | ||
padding-top: 1em; | ||
|
||
display: grid; | ||
justify-items: center; | ||
align-items: center; | ||
|
||
border: 2px solid var(--text-primary); | ||
border-radius: 0 15px 15px 0; | ||
border-left: none; | ||
|
||
background-color: var(--bg-secondary); | ||
transition: left 0.35s linear; | ||
} | ||
|
||
.menu.open { | ||
left: 0; | ||
box-shadow: 5px 5px 5px black; | ||
} | ||
|
||
/* .toggles-container { */ | ||
/* display: flex; */ | ||
/* flex-direction: column; */ | ||
/* align-items: center; */ | ||
/* justify-content: space-evenly; */ | ||
/* } */ | ||
|
||
.unit-toggle { | ||
position: relative; | ||
display: block; | ||
} | ||
|
||
.unit-toggle:first-of-type { | ||
margin-bottom: 2em; | ||
} | ||
|
||
.unit-toggle > label { | ||
display: block; | ||
position: relative; | ||
text-align: center; | ||
cursor: pointer; | ||
} | ||
|
||
.unit-toggle input { | ||
position: absolute; | ||
left: 0; | ||
opacity: 0; | ||
} | ||
|
||
.unit-toggle > label > span { | ||
position: relative; | ||
overflow: hidden; | ||
display: block; | ||
min-height: 2em; | ||
text-align: left; | ||
line-height: 2em; | ||
|
||
color: var(--bg-main); | ||
font-weight: bold; | ||
background-color: var(--text-primary); | ||
border-radius: 15px; | ||
} | ||
|
||
.unit-toggle span span { | ||
position: relative; | ||
display: block; | ||
float: left; | ||
width: 50%; | ||
text-align: center; | ||
} | ||
|
||
.unit-toggle > label > span > span:last-child { | ||
border-radius: 3px; | ||
background-color: var(--bg-main); | ||
position: absolute; | ||
right: 50%; | ||
top: 0; | ||
display: block; | ||
width: 50%; | ||
height: 100%; | ||
transition: all 0.2s ease-out; | ||
} | ||
|
||
.unit-toggle > label input:checked ~ span > span:last-child { | ||
right: 0; | ||
} | ||
|
||
.search-box-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 0.125em; | ||
} | ||
|
||
.search-box { | ||
min-width: 200px; | ||
height: 2.5em; | ||
background-color: white; | ||
border-radius: 15px; | ||
padding: 0.5em; | ||
font-size: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { MouseEvent, ReactElement, useRef } from "react"; | ||
import "./HamburgerMenu.css"; | ||
|
||
function HamburgerMenu(): ReactElement { | ||
const menuElement = useRef<HTMLDivElement>(null); | ||
|
||
function clickHandler( | ||
e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent> | ||
) { | ||
menuElement.current?.classList.toggle("open"); | ||
e.currentTarget.classList.toggle("toggled"); | ||
} | ||
|
||
return ( | ||
<> | ||
<button className="hamburger-container" onClick={(e) => clickHandler(e)}> | ||
<span className="hamburger-line"></span> | ||
<span className="hamburger-line"></span> | ||
<span className="hamburger-line"></span> | ||
</button> | ||
<div className="menu" ref={menuElement}> | ||
<ul className="toggles-container"> | ||
<li className="unit-toggle"> | ||
<label htmlFor="speed-units"> | ||
<input id="speed-units" type="checkbox" /> | ||
<strong>Speed units</strong> | ||
<span> | ||
<span>km/h</span> | ||
<span>mph</span> | ||
<span></span> | ||
</span> | ||
</label> | ||
</li> | ||
<li className="unit-toggle"> | ||
<label htmlFor="temp-units"> | ||
<input id="temp-units" type="checkbox" /> | ||
<strong>Temperature and units</strong> | ||
<span> | ||
<span>°C</span> | ||
<span>°F</span> | ||
<span></span> | ||
</span> | ||
</label> | ||
</li> | ||
</ul> | ||
<div className="search-box-container"> | ||
<label htmlFor="search-box">Search by city</label> | ||
<input | ||
id="search-box" | ||
className="search-box" | ||
type="search" | ||
placeholder="London" | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export { HamburgerMenu }; |
10 changes: 1 addition & 9 deletions
10
client/src/components/NavBar/NavBar.css → client/src/components/Header/Header.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
client/src/components/NavBar/HamburgerMenu/HamburgerMenu.css
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
client/src/components/NavBar/HamburgerMenu/HamburgerMenu.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { Loader } from "./Loader/Loader"; | ||
import { Conditions } from "./Conditions/Conditions"; | ||
import { NavBar } from "./NavBar/NavBar"; | ||
import { Header } from "./Header/Header"; | ||
import { HamburgerMenu } from "./HamburgerMenu/HamburgerMenu"; | ||
import { CurrentWeather } from "./CurrentWeather/CurrentWeather"; | ||
|
||
export { Loader, Conditions, NavBar, CurrentWeather }; | ||
export { Loader, Conditions, Header, HamburgerMenu, CurrentWeather }; |