Remade navigation bar

This commit is contained in:
Kristofers Solo 2023-01-17 23:22:07 +02:00
parent 4feb2383bd
commit 16f7dbd235
9 changed files with 361 additions and 116 deletions

View File

@ -1,13 +1,14 @@
main { main {
border: 1px solid #30363d; border: var(--border);
border-radius: var(--border-radius);
max-width: 700px; max-width: 700px;
color: #f0f6fc; color: var(--text-color);
padding: 50px; padding: 50px;
margin: 100px auto 100px auto; margin: 100px auto 100px auto;
} }
hr { hr {
color: #30363d; color: var(--hr-color);
} }
h1 { h1 {
@ -30,7 +31,7 @@ p {
a { a {
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
color: #58a6ff; color: var(--link-text-color);
} }
a:hover { a:hover {
@ -39,14 +40,14 @@ a:hover {
code { code {
font-family: Consolas, "courier new"; font-family: Consolas, "courier new";
color: #f0f6fc; color: var(--text-color);
background-color: #393f48; background-color: var(--code-bg-color);
border-radius: 8px; border-radius: var(--border-radius);
padding: 3px; padding: 3px;
} }
pre code { pre code {
background-color: #161b22; background-color: var(--bg);
display: block; display: block;
padding: 20px; padding: 20px;
} }

View File

@ -1,25 +1,25 @@
p { /* h1, */
color: #f0f6fc; /* p { */
font-size: 20px; /* color: var(--text-color); */
text-align: center; /* font-size: 20px; */
margin-top: 10px; /* text-align: center; */
} /* margin-top: 10px; */
/* } */
a { /**/
text-decoration: none; /* a { */
font-weight: bold; /* text-decoration: none; */
color: #58a6ff; /* color: var(--link-text-color); */
} /* } */
/**/
a:hover { /* a:hover { */
text-decoration: underline; /* text-decoration: underline; */
} /* } */
/**/
.center { /* .center { */
margin: 0; /* margin: 0; */
position: absolute; /* position: absolute; */
top: 50%; /* top: 50%; */
left: 50%; /* left: 50%; */
-ms-transform: translate(-50%, -50%); /* -ms-transform: translate(-50%, -50%); */
transform: translate(-50%, -50%); /* transform: translate(-50%, -50%); */
} /* } */

View File

@ -1,68 +1,158 @@
:root {
--bg: #0d1117;
--bg-accent: #1a1e25;
--border-radius: 8px;
--border: 1px solid #30363d;
--hover-text-color: #b9bbbd;
--hr-color: #30363d;
--link-text-color: #58a6ff;
--nav-size: 60px;
--speed: 500ms;
--text-color: #f0f6fc;
--code-bg-color: #393f48;
--ff-sans-normal: "Roboto", sans-serif;
--fs-16: 16px;
--fs-20: 20px;
}
html, html,
body { body {
font-family: "Roboto", sans-serif; font-family: var(--ff-sans-normal);
background: #0d1117; color: var(--text-color);
background-color: var(--bg);
line-height: 1.5;
min-height: 100vh;
min-width: 300px;
display: grid;
grid-template-rows: min-content 1fr;
overflow-x: hidden;
} }
main { main {
min-height: 100%; min-height: 100%;
} }
/* HEADER */ /* Utility classes */
.flex {
header ul {
width: 100%;
list-style-type: none;
overflow: hidden;
background-color: #161b22;
position: sticky;
top: 0;
}
header li {
text-align: center;
font-weight: bold;
font-size: 24px;
float: left;
width: calc(100% / 2);
}
header li a {
display: inline-block;
color: #f0f6fc;
padding: 14px 16px;
text-decoration: none;
}
header li a:hover {
text-decoration: none;
color: #b9bbbd;
}
/* FOOTER */
.page-container {
position: relative;
min-height: 100vh;
}
.content-wrap {
padding-bottom: 2.5rem;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
height: auto;
background-color: #161b22;
color: #f0f6fc;
flex-wrap: wrap;
display: flex; display: flex;
justify-content: space-around; gap: var(--gap, 1rem);
} }
footer p { .uppercase {
font-size: 16px; text-transform: uppercase;
margin: 10px 0; }
.bold {
font-weight: 700;
}
.sr-only {
border: 0 !important;
clip: rect(1px, 1px, 1px, 1px) !important; /* 1 */
-webkit-clip-path: inset(50%) !important;
clip-path: inset(50%) !important; /* 2 */
height: 1px !important;
margin: -1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
white-space: nowrap !important; /* 3 */
}
/* Navigation bar */
.logo {
margin: 2rem;
width: 2rem;
aspect-ratio: 1;
}
.primary-header {
align-items: center;
justify-content: space-between;
}
.mobile-nav-toggle {
display: none;
}
.primary-navigation {
background: #161b22e6;
}
@supports (backdrop-filter: blur(2rem)) {
.primary-navigation {
background: #161b2280;
backdrop-filter: blur(2rem);
}
}
.primary-navigation a {
color: var(--text-color);
text-decoration: none;
}
.primary-navigation a:hover {
color: var(--hover-text-color);
}
.primary-navigation a > [aria-hidden="true"] {
font-weight: 700;
margin-inline-end: 0.75rem;
}
@media (max-width: 35em) {
.primary-navigation {
--gap: 3rem;
position: fixed;
z-index: 1000;
inset: 0 0 0 10%;
flex-direction: column;
padding: min(30vh, 10rem) 2rem;
transform: translateX(100%);
transition: transform 350ms ease-out;
}
.primary-navigation[data-visible="true"] {
transform: translateX(0%);
}
.mobile-nav-toggle {
display: block;
position: absolute;
z-index: 9999;
background-color: transparent;
background-image: url("../img/icons/icon-hamburger-menu.svg");
background-repeat: no-repeat;
width: 3rem;
border: 0;
aspect-ratio: 1;
top: 2rem;
right: 2rem;
}
.mobile-nav-toggle[aria-expanded="true"] {
background-color: transparent;
background-image: url("../img/icons/icon-close.svg");
background-repeat: no-repeat;
}
}
@media (min-width: 35em) and (max-width: 55em) {
.primary-navigation a > [aria-hidden="true"] {
display: none;
}
}
@media (min-width: 35em) {
.primary-navigation {
--gap: clamp(1.5rem, 5vw, 3rem);
padding-block: 16px;
padding-inline: clamp(3rem, 8vw, 10rem);
}
} }

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="30"
height="30"
viewBox="0 0 7.9374998 7.9375"
version="1.1"
id="svg1771"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="icon-close.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1773"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="12.400673"
inkscape:cx="-0.36288353"
inkscape:cy="17.539371"
inkscape:window-width="1916"
inkscape:window-height="1055"
inkscape:window-x="1920"
inkscape:window-y="21"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1768" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g1966"
transform="matrix(0.75757574,0.75757576,-0.75757574,0.75757576,3.96875,-2.0445077)">
<rect
style="fill:#f0f6fc;fill-opacity:1;stroke-width:0.289836;stroke-miterlimit:10000;paint-order:markers stroke fill"
id="rect234"
width="7.9375"
height="0.79374999"
x="-1.7763568e-15"
y="3.5718751"
ry="0" />
<rect
style="fill:#f0f6fc;fill-opacity:1;stroke-width:0.289836;stroke-miterlimit:10000;paint-order:markers stroke fill"
id="rect234-3"
width="0.79374999"
height="7.9375"
x="3.5718751"
y="-8.8817842e-16"
ry="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="30"
height="30"
viewBox="0 0 7.9374998 7.9375"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="icon-hamburger-menu.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="6.2003367"
inkscape:cx="-20.966603"
inkscape:cy="5.0803693"
inkscape:window-width="1916"
inkscape:window-height="1055"
inkscape:window-x="1920"
inkscape:window-y="21"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#f0f6fc;fill-opacity:1;stroke-width:0.289836;stroke-miterlimit:10000;paint-order:markers stroke fill"
id="rect234"
width="7.9375"
height="0.79374999"
x="-1.110223e-15"
y="1.3229166"
ry="0" />
<rect
style="fill:#f0f6fc;fill-opacity:1;stroke-width:0.289836;stroke-miterlimit:10000;paint-order:markers stroke fill"
id="rect234-3"
width="7.9375"
height="0.79374999"
x="-1.110223e-15"
y="3.5718751"
ry="0" />
<rect
style="fill:#f0f6fc;fill-opacity:1;stroke-width:0.289836;stroke-miterlimit:10000;paint-order:markers stroke fill"
id="rect234-6"
width="7.9375"
height="0.79374999"
x="-1.110223e-15"
y="5.8208332"
ry="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,13 @@
const PRIMARY_NAV = document.querySelector(".primary-navigation")
const NAV_TOGGLE = document.querySelector(".mobile-nav-toggle")
NAV_TOGGLE.addEventListener("click", () => {
const visibility = PRIMARY_NAV.getAttribute("data-visible") === "false"
if (visibility) {
PRIMARY_NAV.setAttribute("data-visible", true)
NAV_TOGGLE.setAttribute("aria-expanded", true)
} else {
PRIMARY_NAV.setAttribute("data-visible", false)
NAV_TOGGLE.setAttribute("aria-expanded", false)
}
})

View File

@ -3,9 +3,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" <link rel="icon" href="{% static 'main/img/icons/logo.svg' %}" />
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<link rel="icon" href="{% static 'main/img/logo.svg' %}" />
<title> <title>
{% block title %}{% endblock %} {% block title %}{% endblock %}
</title> </title>
@ -16,26 +14,35 @@
type="text/css" type="text/css"
href="{% static 'main/css/layout.css' %}"/> href="{% static 'main/css/layout.css' %}"/>
{% block meta %}{% endblock %} {% block meta %}{% endblock %}
<script src="{% static 'main/js/navigation.js' %}" defer></script>
</head> </head>
<body> <body>
<div class="page-container"> <header class="primary-header flex">
<div class="content-wrap"> <div>
<header> <a href="{% url 'home' %}">
<div> <img src="{% static 'main/img/icons/logo.svg' %}" alt="logo" class="logo">
<ul> </a>
<li>
<a href="{% url 'home' %}">Home</a>
</li>
<li>
<a href="{% url 'instructions' %}">Karbs</a>
</li>
</ul>
</div>
</header>
<main>
{% block content %}{% endblock %}
</main>
</div> </div>
</div> <button class="mobile-nav-toggle"
aria-controls="primary-navigation"
aria-expanded="false">
<span class="sr-only">Menu</span>
</button>
<nav>
<ul id="primary-navigation"
class="primary-navigation flex"
data-visible="false">
<li>
<a href="{% url 'home' %}" class="bold">Home</a>
</li>
<li>
<a href="{% url 'instructions' %}" class="bold">Projects</a>
</li>
</ul>
</nav>
</header>
<main>
{% block content %}{% endblock %}
</main>
</body> </body>
</html> </html>

View File

@ -7,10 +7,14 @@
href="{% static 'main/css/index.css' %}"/> href="{% static 'main/css/index.css' %}"/>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="center"> <!-- <div class="center"> -->
<p>At the moment this website is under construction.</p> <!-- <img src="https://media.giphy.com/media/xTiIzJSKB4l7xTouE8/giphy.gif" -->
<p> <!-- alt="Hello there."> -->
For now you can check out <a href="{% url 'instructions' %}">KARBS</a>. <!-- <h1> -->
</p> <!-- I&#39;m <span class="highlight">Kristofers Solo</span> -->
</div> <!-- </h1> -->
<!-- <h1> -->
<!-- <span id="text-rotate">Jedi</span> -->
<!-- </h1> -->
<!-- </div> -->
{% endblock %} {% endblock %}