aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Header.astro
blob: 3e3f97eede994e45045c37618975c26bca080d21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---

---
<header>
    <nav>
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/about">About</a></li>
        <li><a href="/contact">Contact</a></li>
      </ul>
    </nav>
</header>
<style>

    header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 2rem;
    }

    nav ul {
        display: flex;
        flex-direction: row;
        list-style: none;
        padding: 0;
        margin: 0;
    }

    nav li {
        margin-right: 1.5rem;
        position: relative;
    }

    nav li:last-child {
        margin-right: 0;
    }

    nav a {
        color: #fff;
        text-decoration: none;
        font-weight: 500;
        padding: 5px 10px;
        border-radius: 5px;
        transition: all 0.3s ease; /* Adding transition */
    }

    nav a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    /* Active link state example (you may need to adjust this based on your routing) */
    nav a.active {
        background: linear-gradient(to right, #4CAF50, #8BC34A);
        color: #000;
    }
</style>
<script>
const currentPage = window.location.pathname;
const homeLink = document.querySelector("#home-link");
const aboutLink = document.querySelector("#about-link");
const contactLink = document.querySelector("#contact-link");

if (currentPage === "/") {
  homeLink.classList.add("active");
} else if (currentPage === "/about") {
  aboutLink.classList.add("active");
} else if (currentPage === "/contact") {
  contactLink.classList.add("active");
}
</script>
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage