Skip to content

Commit 5b5fe21

Browse files
committed
💄 chore: better styling in navigation bar and footer
1 parent 8f131ac commit 5b5fe21

File tree

4 files changed

+46
-36
lines changed

4 files changed

+46
-36
lines changed

src/components/Footer.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
---
2+
import { FaHeart } from "react-icons/fa6";
23
import { useTranslations } from "../i18n/utils";
4+
import LinkButton from "./LinkButton.astro";
35
46
const lang = (Astro.params.lang || "en") as never;
57
const tr = useTranslations(lang);
68
---
79

810
<footer class="footer">
9-
{ tr("footer.txt1") } <i class="nf nf-fa-heart"></i> { tr("footer.txt2") }
10-
· <a href="https://github.com/retrozinndev/retrozinn.dev">{ tr("footer.txt3") }</a>
11+
{ tr("footer.txt1") } <FaHeart size={10} /> { tr("footer.txt2") }
12+
· <LinkButton external={true} spacing={false} href="https://github.com/retrozinndev/retrozinn.dev">
13+
{ tr("footer.txt3") }
14+
</a>
1115
</footer>
1216

1317
<style lang="scss">

src/components/LinkButton.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ const { href, external, title, showIcon = true, spacing = true } = Astro.props;
2929

3030
a {
3131
display: inline-flex;
32-
font-size: 1.04em;
3332
font-weight: 600;
34-
color: inherit;
3533

3634
box-shadow: inset 0 0 0 1px colors.$accent-color-dark;
3735
border-radius: 12px;
3836
text-decoration: none;
37+
text-underline-offset: 2px;
3938
transition: 150ms linear;
4039

4140
&.space {

src/components/Navigation.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import "../styles/components/Navigation.scss";
22

33
import { useEffect, useState, type ReactElement } from "react";
4-
54
import { useTranslations } from "../i18n/utils";
65
import { defaultLang } from "../i18n/ui";
6+
77
import ToggleThemeButton from "./ToggleThemeButton";
88
import LanguageSelector from "./LanguageSelector";
9-
import { AstroJSX } from "astro/jsx-runtime";
9+
1010

1111
interface Props {
1212
lang?: string;
@@ -63,6 +63,7 @@ export default function(props: Props): ReactElement {
6363
window.addEventListener("scroll", handleScroll);
6464
});
6565

66+
6667
return <div className="navigation-bar">
6768
<nav className={`navigation ${scrolled ? "scrolled" : ""}`} id="navbar"
6869
aria-label="Navigation Bar" onScroll={() => {
@@ -75,25 +76,34 @@ export default function(props: Props): ReactElement {
7576
}}>
7677

7778
<div className="left-side"> {
78-
showProfilePic ?
79-
<a rel="author" href="https://github.com/retrozinndev">
80-
<img className="profile-pic"
81-
src="https://1.gravatar.com/avatar/093b64d2016ab8acce8a2fe73cb719f527790d4ecec7f5837db8d46519b38bf8?size=80"
82-
width={32} height={32} alt={ tr("nav.home") } loading="lazy" />
83-
</a>
84-
: null
79+
showProfilePic ? <a rel="author" href="https://github.com/retrozinndev">
80+
<img className="profile-pic"
81+
src="https://1.gravatar.com/avatar/093b64d2016ab8acce8a2fe73cb719f527790d4ecec7f5837db8d46519b38bf8?size=80"
82+
width={32} height={32} alt={ tr("nav.home") } loading="lazy"
83+
/>
84+
</a> : null
8585
} </div>
8686

8787
<div className="items" > {
88-
pages.map((page, i) => (
89-
<div className="item" key={i}>
90-
<a href={`${page.hasI18n ? `/${lang}` : ""}${page.href}`}
91-
target="_self" title={ tr(`nav.${page.name}_tooltip`) }>{
92-
88+
pages.map((page, i) =>
89+
<div className={`item`} key={i} onLoadStart={e => {
90+
const currentPage = (page.hasI18n ?
91+
window.location.pathname.replace(/^\/.*(\/)/, "/")
92+
: window.location.pathname).trimEnd().replace(/\/$/, "").concat(
93+
window.location.hash.startsWith('#') ?
94+
window.location.hash
95+
: window.location.hash.replace(/^./, "\#&")
96+
).trim();
97+
98+
if(currentPage === page.href.toString())
99+
(e.target as HTMLDivElement).classList.add("current");
100+
}}>
101+
<a href={`${page.hasI18n ? `/${lang}` : ""}${page.href}`} target="_self"
102+
title={ tr(`nav.${page.name}_tooltip`) }> {
93103
tr(`nav.${page.name}`)
94104
} </a>
95105
</div>
96-
))
106+
)
97107
}
98108

99109
<div className="item" key={pages.length}>

src/styles/components/Navigation.scss

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,24 @@ $padding-around: 2px;
4545
flex-wrap: wrap;
4646
justify-content: center;
4747

48-
& > .item {
48+
& > .item a {
49+
-webkit-tap-highlight-color: transparent;
50+
text-decoration: none;
4951
margin: 2px;
5052
padding: 6px 8px;
5153
border-radius: 12px;
5254
transition: 200ms ease-in-out;
53-
54-
&, & * {
55-
-webkit-tap-highlight-color: transparent;
56-
}
57-
58-
& *:is(a) {
59-
all: unset;
60-
-webkit-tap-highlight-color: unset;
61-
color: inherit;
62-
font-weight: 600;
63-
font-size: 1.05em;
64-
}
65-
66-
&:has(> a):hover,
67-
&:has(> a).current {
68-
background: colors.$accent-color-dark;
55+
color: inherit;
56+
font-weight: 600;
57+
font-size: 1.05em;
58+
text-decoration-line: underline;
59+
text-decoration-thickness: 2px;
60+
text-decoration-color: transparent;
61+
text-underline-offset: 3px;
62+
63+
&:hover,
64+
&.current {
65+
text-decoration-color: inherit;
6966
cursor: pointer;
7067
}
7168
}

0 commit comments

Comments
 (0)