2023-03-04 19:11:52 +01:00
|
|
|
---
|
|
|
|
export interface Props {
|
2023-03-09 11:44:18 +01:00
|
|
|
currentPage?: string
|
2024-01-01 20:10:57 +01:00
|
|
|
navtype: "mobile" | "desktop"
|
2023-03-09 11:44:18 +01:00
|
|
|
link: string
|
|
|
|
text: string
|
2023-12-29 22:57:30 +01:00
|
|
|
icon: ImageMetadata
|
2023-03-04 19:11:52 +01:00
|
|
|
}
|
|
|
|
|
2024-01-01 20:10:57 +01:00
|
|
|
const { icon, text, link, navtype, currentPage } = Astro.props
|
2023-03-04 19:11:52 +01:00
|
|
|
|
2023-03-09 11:44:18 +01:00
|
|
|
let currPage = ''
|
|
|
|
const slug = link.replace(new RegExp('/', 'g'), '')
|
2023-03-04 19:11:52 +01:00
|
|
|
|
2023-03-04 22:35:49 +01:00
|
|
|
if (currentPage === slug) {
|
2023-03-09 11:44:18 +01:00
|
|
|
currPage = 'current'
|
|
|
|
} else if (currentPage === 'home' && link === '/') {
|
|
|
|
currPage = 'current'
|
2023-03-04 19:11:52 +01:00
|
|
|
}
|
2023-03-04 22:35:49 +01:00
|
|
|
|
2023-12-29 22:57:30 +01:00
|
|
|
const icon_src_url = `url("${icon.src}")`;
|
2023-03-09 11:44:18 +01:00
|
|
|
const fulllink = `/${slug}`
|
2024-01-01 19:41:46 +01:00
|
|
|
|
2024-01-01 20:10:57 +01:00
|
|
|
let extraattributes = navtype === "mobile" ? { tabindex: "0"} : {}
|
2023-03-04 19:11:52 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
<li>
|
2023-03-09 11:44:18 +01:00
|
|
|
<a
|
|
|
|
href={fulllink}
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
aria-label={text}
|
|
|
|
class={currPage}
|
2024-01-01 20:54:14 +01:00
|
|
|
role="navigation"
|
2024-01-01 20:10:57 +01:00
|
|
|
{...extraattributes}
|
2023-03-09 11:44:18 +01:00
|
|
|
>
|
2023-12-29 22:57:30 +01:00
|
|
|
<div class="icon"></div>
|
2023-03-09 11:44:18 +01:00
|
|
|
{text}
|
|
|
|
</a>
|
2023-03-04 19:11:52 +01:00
|
|
|
</li>
|
|
|
|
|
2023-12-29 22:57:30 +01:00
|
|
|
<style define:vars={{ icon_src_url }}>
|
2023-03-09 11:44:18 +01:00
|
|
|
li {
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
text-align: left;
|
|
|
|
display: flex;
|
|
|
|
width: 200px;
|
|
|
|
}
|
2023-12-29 22:57:30 +01:00
|
|
|
|
2023-03-09 11:44:18 +01:00
|
|
|
li > a {
|
2023-12-20 23:48:28 +01:00
|
|
|
display: inline-flex;
|
2023-03-09 11:44:18 +01:00
|
|
|
color: white;
|
|
|
|
text-decoration: none;
|
|
|
|
justify-content: center;
|
2023-12-21 11:39:45 +01:00
|
|
|
align-items: center;
|
2023-03-09 11:44:18 +01:00
|
|
|
font-size: 1.4em;
|
|
|
|
height: 100%;
|
|
|
|
font-weight: bold;
|
2023-12-20 23:48:28 +01:00
|
|
|
gap: 0.2em;
|
2023-03-09 11:44:18 +01:00
|
|
|
}
|
2023-12-29 22:57:30 +01:00
|
|
|
|
2023-03-09 11:44:18 +01:00
|
|
|
li > a:hover {
|
|
|
|
color: var(--c-purplepink);
|
|
|
|
}
|
2023-12-29 22:57:30 +01:00
|
|
|
|
|
|
|
li > a:hover > .icon {
|
|
|
|
background-color: var(--c-purplepink);
|
|
|
|
}
|
|
|
|
|
2023-03-09 11:44:18 +01:00
|
|
|
.current {
|
2023-12-20 23:48:28 +01:00
|
|
|
color: var(--c-darkpurple) !important;
|
2023-03-09 11:44:18 +01:00
|
|
|
}
|
2023-12-29 22:57:30 +01:00
|
|
|
|
|
|
|
.current > .icon {
|
|
|
|
background-color: var(--c-darkpurple) !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
mask: var(--icon_src_url) no-repeat center;
|
|
|
|
background-color: white;
|
|
|
|
width: 1.4em;
|
|
|
|
height: 1.4em;
|
|
|
|
}
|
2023-03-09 11:44:18 +01:00
|
|
|
</style>
|