Dropdown change on mobile

This commit is contained in:
Firq 2024-10-30 20:28:45 +01:00
parent d2dddbeb2a
commit 99fe35aa23
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
6 changed files with 144 additions and 121 deletions
src/components/navbar

View file

@ -0,0 +1,70 @@
---
import hamburger from 'iconoir/icons/menu.svg'
const hamburger_src_url = `url("${hamburger.src}")`
---
<div class="dropdown">
<input type="checkbox" id="dropdown" />
<ul class="dropdown-content">
<slot />
</ul>
<label for="dropdown" class="dropdown-btn">
<div class="hamburger-menu" role="navigation"></div>
</label>
</div>
<style define:vars={{ hamburger_src_url }}>
input[type="checkbox"] {
opacity: 0;
position: absolute;
}
input[type="checkbox"]:checked ~ .dropdown-content {
display: flex;
height: auto;
}
.dropdown-content {
display: none;
flex-wrap: wrap;
flex-direction: row;
align-items: center;
background-color: var(--c-primary-background);
width: 100%;
height: 0px;
list-style-type: none;
line-height: 3em;
margin: 0.5rem 0px 0px;
padding: 0;
}
.dropdown-btn {
height: 64px;
display:flex;
align-items: center;
justify-content: center;
}
.dropdown {
display: flex;
justify-content: flex-end;
background-color: var(--c-primary-background);
border: 0px;
width: 100%;
}
.hamburger-menu {
mask: var(--hamburger_src_url) no-repeat center;
mask-size: cover;
background-color: var(--c-primary-text);
width: 2.25rem;
height: 2.25rem;
margin-right: 4px;
}
@media (min-width: 1140px) {
.dropdown {
display: none;
}
}
</style>