Skip to content

Commit 2086dee

Browse files
authored
Merge pull request #13 from xchux/fix/bugs
Fix/bugs
2 parents 0b39ea7 + 6619ded commit 2086dee

File tree

10 files changed

+42
-17
lines changed

10 files changed

+42
-17
lines changed

components/navbar.tsx

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
1-
import { useState } from "react";
1+
import { useState, useEffect, useRef } from "react";
22

33
import Link from "next/link";
44

55
import { translatoinSchemaType } from "@/types/page";
66

7+
const scrollToSection = (id: string, offset: number = 64) => {
8+
const target = document.querySelector(id);
9+
if (target) {
10+
const top = target.getBoundingClientRect().top + window.scrollY - offset;
11+
window.scrollTo({ top, behavior: "smooth" });
12+
}
13+
};
14+
715
const Navbar = (transation: translatoinSchemaType) => {
816
const [isOpen, setIsOpen] = useState(false);
917
const [isLangOpen, setIsLangOpen] = useState(false);
18+
const langDropdownRef = useRef<HTMLDivElement>(null);
19+
20+
useEffect(() => {
21+
const handleClickOutside = (event: MouseEvent) => {
22+
if (langDropdownRef.current && !langDropdownRef.current.contains(event.target as Node)) {
23+
setIsLangOpen(false);
24+
}
25+
};
26+
27+
document.addEventListener("mousedown", handleClickOutside);
28+
return () => {
29+
document.removeEventListener("mousedown", handleClickOutside);
30+
};
31+
}, []);
1032

1133
return (
1234
<div className="sticky top-0 inset-x-0 flex flex-wrap md:justify-start md:flex-nowrap z-50 w-full text-sm">
@@ -35,10 +57,19 @@ const Navbar = (transation: translatoinSchemaType) => {
3557
<div id="hs-navbar-header-floating" className={`${isOpen ? "block" : "hidden"} md:block transition-all duration-300 basis-full grow md:block`} aria-labelledby="hs-navbar-header-floating-collapse">
3658
<div className="flex flex-col md:flex-row md:items-center md:justify-end gap-2 md:gap-3 mt-3 md:mt-0 py-2 md:py-0 md:ps-7">
3759
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-gray-800 font-medium text-gray-800 focus:outline-none dark:border-neutral-200 dark:text-neutral-200" href="#" aria-current="page">{transation.data.profile.title}</Link>
38-
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200" href="#work-experience">{transation.data.workExperience.title}</Link>
39-
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200" href="#education">{transation.data.education.title}</Link>
40-
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200" href="#skills">{transation.data.skills.title}</Link>
41-
<div className="relative">
60+
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200" onClick={(e) => {
61+
e.preventDefault();
62+
scrollToSection("#work-experience");
63+
}} href="#work-experience">{transation.data.workExperience.title}</Link>
64+
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200" onClick={(e) => {
65+
e.preventDefault();
66+
scrollToSection("#education");
67+
}} href="#education">{transation.data.education.title}</Link>
68+
<Link className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200" onClick={(e) => {
69+
e.preventDefault();
70+
scrollToSection("#skills");
71+
}} href="#skills">{transation.data.skills.title}</Link>
72+
<div className="relative" ref={langDropdownRef}>
4273
<button className="py-0.5 md:py-3 px-4 md:px-1 border-s-2 md:border-s-0 md:border-b-2 border-transparent text-gray-500 hover:text-gray-800 focus:outline-none dark:text-neutral-400 dark:hover:text-neutral-200 flex items-center" onClick={() => setIsLangOpen(!isLangOpen)}>
4374
{transation.data.language.title}
4475
<svg className={`ml-1 w-4 h-4 transition-transform ${isLangOpen ? 'rotate-180' : ''}`} xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">

out/404.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

out/_next/static/RDmMesCcPBPrJUKfMKMXz/_buildManifest.js renamed to out/_next/static/FWzZfU6hJOkkguPPIqVtX/_buildManifest.js

File renamed without changes.

out/_next/static/RDmMesCcPBPrJUKfMKMXz/_ssgManifest.js renamed to out/_next/static/FWzZfU6hJOkkguPPIqVtX/_ssgManifest.js

File renamed without changes.

out/_next/static/chunks/pages/_app-04cd97bba0cd9067.js renamed to out/_next/static/chunks/pages/_app-2c713f80da9c1b8b.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out/en.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

out/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

out/zh-TW.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

styles/globals.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ body {
1919
background: var(--background);
2020
font-family: Arial, Helvetica, sans-serif;
2121
}
22-
23-
h2 {
24-
position: relative;
25-
padding-top: 5rem; /* Adjust this value to match the height of your navbar */
26-
margin-top: -5rem; /* Same value as padding-top */
27-
}

0 commit comments

Comments
 (0)