simple nav
This commit is contained in:
parent
9caab461a0
commit
26f742d870
2 changed files with 46 additions and 3 deletions
|
@ -1,7 +1,28 @@
|
||||||
<script>
|
<script>
|
||||||
export let segment
|
import NavItem from "./NavItem.svelte";
|
||||||
|
export let segment;
|
||||||
|
|
||||||
|
const titlesMap = {
|
||||||
|
undefined: "home",
|
||||||
|
"free-open-source": "free & open source",
|
||||||
|
"about-contact": "about & contact",
|
||||||
|
faq: "faq",
|
||||||
|
"global-open-infrastructure": "global open infrastructure",
|
||||||
|
"privacy-by-design": "privacy by design",
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<NavItem {segment} href="." matchingSegment={undefined} humanName="home" />
|
||||||
|
|
||||||
|
<NavItem
|
||||||
|
{segment}
|
||||||
|
href="./about-contact"
|
||||||
|
matchingSegment="about-contact"
|
||||||
|
humanName="about & contact"
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
nav {
|
nav {
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
|
@ -14,5 +35,3 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<nav>{segment}</nav>
|
|
||||||
|
|
24
src/components/NavItem.svelte
Normal file
24
src/components/NavItem.svelte
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<script>
|
||||||
|
export let segment;
|
||||||
|
export let humanName;
|
||||||
|
export let href;
|
||||||
|
export let matchingSegment;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="navItem"
|
||||||
|
aria-current={segment === matchingSegment ? "page" : undefined}
|
||||||
|
>
|
||||||
|
<a rel="prefetch" {href}>{humanName}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.navItem {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding-left: 0.5em;
|
||||||
|
padding-right: 0.5em;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in a new issue