feat(ui): add small screen support for header

This commit is contained in:
Julien Oculi 2024-02-14 13:04:23 +01:00
parent 35c2b4e422
commit 4e3b4f94e3
4 changed files with 126 additions and 23 deletions

View file

@ -15,7 +15,7 @@ header div {
gap: var(--_gap); gap: var(--_gap);
} }
header span { .components__header__brand {
text-wrap: nowrap; text-wrap: nowrap;
padding: var(--_gap); padding: var(--_gap);
font-size: large; font-size: large;
@ -23,6 +23,17 @@ header span {
& a { & a {
text-decoration: none; text-decoration: none;
color: currentColor;
}
@media (width < 800px) {
.components__header__brand__text {
display: none;
}
& img {
min-width: 1rem;
}
} }
} }
@ -38,16 +49,6 @@ header nav {
list-style: none; list-style: none;
transition: border var(--_transition-delay) ease; transition: border var(--_transition-delay) ease;
border: var(--_border-size) solid transparent; border: var(--_border-size) solid transparent;
& > a {
display: inline-block;
text-decoration: none;
outline: none;
}
& > * {
padding: var(--_gap-half) var(--_gap);
}
} }
& > li:hover, & > li:hover,
@ -56,10 +57,17 @@ header nav {
& > li:has(details[open]) { & > li:has(details[open]) {
border: var(--_border-size) solid currentColor; border: var(--_border-size) solid currentColor;
} }
@media (width < 800px) {
& {
justify-content: space-around;
}
}
} }
header details { header details {
cursor: pointer; cursor: pointer;
padding: var(--_gap-half);
& summary { & summary {
display: flex; display: flex;
@ -67,11 +75,35 @@ header details {
list-style: none; list-style: none;
outline: none; outline: none;
& i {
display: none;
}
&::after { &::after {
display: inline-block; display: inline-block;
content: '▽'; content: '▽';
transition: all var(--_transition-delay) ease; transition: all var(--_transition-delay) ease;
} }
@media (width < 800px) {
& {
display: grid;
gap: 0;
font-size: x-small;
justify-items: center;
align-items: center;
font-weight: normal;
}
& i {
display: inline;
font-size: 1rem;
}
&::after {
display: none;
}
}
} }
&[open] summary::after { &[open] summary::after {
@ -92,6 +124,13 @@ header details {
calc(-1 * var(--_gap) - 2px), calc(-1 * var(--_gap) - 2px),
calc(var(--_gap-half) + 2px) calc(var(--_gap-half) + 2px)
); );
@media (width < 800px) {
& {
border: var(--_border-size) solid currentColor;
transform: translate(-33%, var(--_gap));
}
}
} }
& li { & li {
@ -112,9 +151,52 @@ header details {
} }
} }
header input { .components__header__search {
padding: var(--_gap-half) var(--_gap); padding: var(--_gap-half) var(--_gap);
align-self: center; align-self: center;
border: none; border: var(--_border-size) solid transparent;
background-color: var(--_translucent); background-color: var(--_translucent);
min-width: fit-content;
outline: none;
&:focus-visible {
border: var(--_border-size) solid currentColor;
}
@media (width < 800px) {
& {
background-color: transparent;
}
& span {
display: none;
}
}
}
.components__header__nav_button {
color: var(--_font-color);
display: inline-block;
text-decoration: none;
outline: none;
padding: var(--_gap-half) var(--_gap);
& i {
display: none;
}
@media (width < 800px) {
& {
display: grid;
font-size: x-small;
justify-items: center;
align-items: center;
font-weight: normal;
}
& i {
display: inline;
font-size: 1rem;
}
}
} }

View file

@ -5,27 +5,38 @@ export function Header() {
return ( return (
<header> <header>
<div> <div>
<span> <span class='components__header__brand'>
<a href='/'> <a href='/'>
Coh<img <span class='components__header__brand__text'>Coh</span>
src={asset('/assets/bulb.svg')} <img src={asset('/assets/bulb.svg')} alt='a' />
alt='a' <span class='components__header__brand__text'>bit</span>
/>bit POC
</a> </a>
</span> </span>
<nav> <nav>
<li> <li>
<a href='/machines'>Machines</a> <a href='/machines' class='components__header__nav_button'>
<i class='ri-hammer-line'></i>
<span>Machines</span>
</a>
</li> </li>
<li> <li>
<a href='/projets'>Projets</a> <a href='/projets' class='components__header__nav_button'>
<i class='ri-organization-chart'></i>
<span>Projets</span>
</a>
</li> </li>
<li> <li>
<a href='/blog'>Blog</a> <a href='/blog' class='components__header__nav_button'>
<i class='ri-question-answer-line'></i>
<span>Blog</span>
</a>
</li> </li>
<li> <li>
<details> <details>
<summary>Fablab</summary> <summary>
<i class='ri-function-line'></i>
<span>Fablab</span>
</summary>
<ul> <ul>
<li> <li>
<a href='/membres'>Membres</a> <a href='/membres'>Membres</a>
@ -50,7 +61,10 @@ export function Header() {
</details> </details>
</li> </li>
</nav> </nav>
<input type='search' name='' id='' placeholder='Rechercher' /> <button class='components__header__search'>
<i class='ri-search-line'></i>
<span>&nbsp;Rechercher</span>
</button>
<ThemePicker /> <ThemePicker />
</div> </div>
</header> </header>

View file

@ -26,4 +26,10 @@
font-weight: normal; font-weight: normal;
line-height: normal; line-height: normal;
} }
@media (width < 800px) {
& select {
width: 0;
}
}
} }

View file

@ -13,6 +13,7 @@
--_gap: var(--size-3); --_gap: var(--size-3);
--_gap-half: calc(var(--_gap) / 2); --_gap-half: calc(var(--_gap) / 2);
--_wide-screen: 1400px; --_wide-screen: 1400px;
--_small-screen: 800px;
/* color */ /* color */
--_accent-color: var(--lime-6); --_accent-color: var(--lime-6);