59 lines
1.0 KiB
JavaScript
59 lines
1.0 KiB
JavaScript
import { html, css } from '../templater.js'
|
|
|
|
const body = (path) => html`
|
|
<nav>
|
|
<ul>
|
|
<li class="${path === '/' ? 'active' : ''}"><a href="/">Home</a></li>
|
|
<li class="${path === '/about' ? 'active' : ''} "><a href="/about">About</a></li>
|
|
</ul>
|
|
</nav>
|
|
`
|
|
|
|
const styles = css`
|
|
nav ul {
|
|
list-style: none;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
nav li {
|
|
padding: 1rem 2rem;
|
|
}
|
|
|
|
nav a {
|
|
display: block;
|
|
position: relative;
|
|
padding: .5rem 1rem;
|
|
color: var(--color-body);
|
|
text-decoration: none;
|
|
}
|
|
|
|
nav a:before {
|
|
content: ' ';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(255, 255, 255, 0.3);
|
|
border-radius: 1rem;
|
|
transition: transform 200ms;
|
|
transform: scale(0);
|
|
z-index: -1;
|
|
}
|
|
|
|
nav a:hover:before, nav .active a:before {
|
|
transform: scale(1);
|
|
}
|
|
|
|
nav .active a {
|
|
color: var(--color-headings);
|
|
}
|
|
`
|
|
|
|
export function NavBar (ctx, { path }) {
|
|
ctx.css.add(styles)
|
|
ctx.body = body(path)
|
|
return ctx
|
|
}
|