fix(header): update style

This commit is contained in:
Jewgeni Lewash 2024-03-07 08:57:13 +01:00
parent 388c9f2e8b
commit 8d2285c735
2 changed files with 8 additions and 15 deletions

View File

@ -69,7 +69,7 @@ const navLinks = [
navLinks.map(({ href, label }) => ( navLinks.map(({ href, label }) => (
<HeaderLink <HeaderLink
href={href} href={href}
class="block w-full rounded-lg px-4 py-2 text-center font-sans text-sm font-medium leading-normal text-zinc-900 antialiased transition-all hover:bg-zinc-50 dark:text-zinc-100 dark:hover:bg-zinc-950 md:text-xl"> class="block w-full rounded-lg px-4 py-2 text-center font-sans text-sm leading-normal text-zinc-900 antialiased transition-all hover:bg-zinc-50 dark:text-zinc-100 dark:hover:bg-zinc-950 md:text-xl">
{label} {label}
</HeaderLink> </HeaderLink>
)) ))

View File

@ -1,20 +1,13 @@
--- ---
const { pathname } = Astro.url; const { pathname } = Astro.url;
const { class: className, href, ...props } = Astro.props; const { class: className = '', href, ...props } = Astro.props;
const isActive = href === pathname || href === pathname.replace(/\/$/, ''); const isActive =
href === pathname || href === (pathname.endsWith('/') ? pathname.slice(0, -1) : pathname);
--- ---
<a href={href} class:list={[className, { active: isActive }]} {...props}> <a
href={href}
class={`inline-block ${className} ${isActive ? 'font-bold underline' : 'font-medium no-underline'}`}
{...props}>
<slot /> <slot />
</a> </a>
<style>
a {
display: inline-block;
text-decoration: none;
}
a.active {
font-weight: bolder;
text-decoration: underline;
}
</style>