feat: ✨ add responsiveness to navigation
This commit is contained in:
parent
22a12666c2
commit
cbc41e74ba
3 changed files with 106 additions and 20 deletions
|
@ -310,6 +310,18 @@
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
webc:elseif="icon === 'bars'"
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 448 512"
|
||||||
|
>
|
||||||
|
<!-- !Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. -->
|
||||||
|
<path
|
||||||
|
d="M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
svg {
|
svg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1,6 +1,11 @@
|
||||||
<nav
|
<nav :aria-label="label">
|
||||||
:aria-label="label"
|
<label for="nav-toggle">
|
||||||
@html="eleventyNavigationToHtml(eleventyNavigation($data.collections[collection]), {
|
<icon icon="bars" webc:nokeep></icon>
|
||||||
|
</label>
|
||||||
|
<input type="checkbox" id="nav-toggle" />
|
||||||
|
<template
|
||||||
|
webc:nokeep
|
||||||
|
@html="eleventyNavigationToHtml(eleventyNavigation($data.collections[collection]), {
|
||||||
listClass: 'list',
|
listClass: 'list',
|
||||||
listItemClass: 'item',
|
listItemClass: 'item',
|
||||||
listItemHasChildrenClass: 'hasChildren',
|
listItemHasChildrenClass: 'hasChildren',
|
||||||
|
@ -13,42 +18,109 @@
|
||||||
|
|
||||||
showExcerpt: false
|
showExcerpt: false
|
||||||
})"
|
})"
|
||||||
></nav>
|
></template>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
nav {
|
nav {
|
||||||
--nav-spacing: 1em;
|
--nav-spacing: 1em;
|
||||||
display: flex;
|
--nav-background-color: var(--clr-nav-background);
|
||||||
flex-flow: row nowrap;
|
--nav-border: var(--border-thin) solid var(--clr-box-border);
|
||||||
justify-content: end;
|
|
||||||
font-size: 0.75em;
|
|
||||||
|
|
||||||
@media (min-width: 30em) {
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
justify-items: end;
|
||||||
|
|
||||||
|
background-color: var(--nav-background-color);
|
||||||
|
|
||||||
|
border-block-end: var(--nav-border);
|
||||||
|
|
||||||
|
z-index: 2;
|
||||||
|
|
||||||
|
@media (min-width: 35em) {
|
||||||
--nav-spacing: 1.5em;
|
--nav-spacing: 1.5em;
|
||||||
font-size: 0.875em;
|
--nav-background-color: transparent;
|
||||||
|
--nav-border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 64em) {
|
@media (min-width: 64em) {
|
||||||
--nav-spacing: 2em;
|
--nav-spacing: 2em;
|
||||||
font-size: 1em;
|
}
|
||||||
|
|
||||||
|
&:has(input:checked) {
|
||||||
|
& ul {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
& li {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& label {
|
||||||
|
width: 1.5em;
|
||||||
|
height: 1.5em;
|
||||||
|
margin-block: 0.75em;
|
||||||
|
margin-inline: 1em;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 35em) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& input {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
& ul {
|
& ul {
|
||||||
flex: 0 0 0;
|
--nav-items-position: absolute;
|
||||||
|
--nav-items-orientation: column nowrap;
|
||||||
|
|
||||||
|
position: var(--nav-items-position);
|
||||||
|
top: 3em;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: row nowrap;
|
flex-flow: var(--nav-items-orientation);
|
||||||
gap: var(--nav-spacing);
|
|
||||||
|
|
||||||
width: fit-content;
|
text-align: end;
|
||||||
|
|
||||||
background-color: var(--clr-nav-background);
|
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
||||||
|
background-color: var(--clr-nav-background);
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border-inline-start: var(--border-thin) solid var(--clr-box-border);
|
border: var(--border-thin) solid var(--clr-box-border);
|
||||||
border-block-end: var(--border-thin) solid var(--clr-box-border);
|
border-block-start: none;
|
||||||
border-radius: 0 0.75em;
|
border-inline-end: none;
|
||||||
|
border-end-start-radius: 0.75em;
|
||||||
padding-inline: var(--nav-spacing);
|
padding-inline: var(--nav-spacing);
|
||||||
|
|
||||||
|
z-index: 3;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.4s ease-in-out;
|
||||||
|
|
||||||
|
@media (min-width: 35em) {
|
||||||
|
--nav-items-position: static;
|
||||||
|
--nav-items-orientation: row nowrap;
|
||||||
|
align-items: start;
|
||||||
|
gap: 1em;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& li {
|
||||||
|
overflow: hidden;
|
||||||
|
height: 0;
|
||||||
|
transition: height 0.4s ease-in-out;
|
||||||
|
|
||||||
|
@media (min-width:35em) {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& .link {
|
& .link {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
border: var(--border-thin) solid var(--clr-box-border);
|
border: var(--border-thin) solid var(--clr-box-border);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
|
|
||||||
|
overflow: clip;
|
||||||
|
|
||||||
& :where(h1, h2, h3, h4, h5, h6) {
|
& :where(h1, h2, h3, h4, h5, h6) {
|
||||||
--heading-spacing: 0.25em;
|
--heading-spacing: 0.25em;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue