diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro
index 4b4aa9b..9803f88 100644
--- a/src/components/Navbar.astro
+++ b/src/components/Navbar.astro
@@ -6,6 +6,7 @@ import I18nKey from "../i18n/i18nKey";
import {i18n} from "../i18n/translation";
import {LinkPreset, NavBarLink} from "../types/config";
import {navBarConfig, siteConfig} from "../config";
+import NavMenuPanel from "./widget/NavMenuPanel.astro";
const className = Astro.props.class;
function isI18nKey(key: string): key is I18nKey {
@@ -49,7 +50,7 @@ function getLinkPresetInfo(p: LinkPreset): NavBarLink {
{siteConfig.title}
-
+
@@ -91,7 +97,7 @@ function switchTheme() {
}
}
-function loadThemeSwitchScript() {
+function loadButtonScript() {
let switchBtn = document.getElementById("scheme-switch");
switchBtn.addEventListener("click", function () {
switchTheme()
@@ -102,12 +108,18 @@ function loadThemeSwitchScript() {
let settingPanel = document.getElementById("display-setting");
settingPanel.classList.toggle("closed");
});
+
+ let menuBtn = document.getElementById("nav-menu-switch");
+ menuBtn.addEventListener("click", function () {
+ let menuPanel = document.getElementById("nav-menu-panel");
+ menuPanel.classList.toggle("closed");
+ });
}
-loadThemeSwitchScript();
+loadButtonScript();
document.addEventListener('astro:after-swap', () => {
- loadThemeSwitchScript();
+ loadButtonScript();
}, { once: false });
diff --git a/src/components/widget/NavMenuPanel.astro b/src/components/widget/NavMenuPanel.astro
new file mode 100644
index 0000000..6f499e2
--- /dev/null
+++ b/src/components/widget/NavMenuPanel.astro
@@ -0,0 +1,52 @@
+---
+import {NavBarLink} from "../../types/config";
+import {siteConfig} from "../../config";
+import {Icon} from "astro-icon/components";
+
+interface Props {
+ links: NavBarLink[],
+}
+
+const links = Astro.props.links;
+
+const enableBanner = siteConfig.banner.enable;
+
+---
+
+
+
\ No newline at end of file
diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro
index ca91a30..d19ce51 100644
--- a/src/layouts/Layout.astro
+++ b/src/layouts/Layout.astro
@@ -198,7 +198,6 @@ function disableAnimation() {
}
}
-
function activateDisplaySettings() {
let output = document.getElementById("hueValue");
let slider = document.getElementById("colorSlider");
@@ -227,15 +226,19 @@ function activateDisplaySettings() {
setHue(hue);
}
- document.addEventListener("click", event => {
- var cDom = document.getElementById("display-setting");
- let settingBtn = document.getElementById("display-settings-switch");
- var tDom = event.target;
- if (cDom == tDom || cDom.contains(tDom) || settingBtn == tDom || settingBtn.contains(tDom)) {
- return;
- }
- cDom.classList.add("closed");
- });
+ function setClickOutsideToClose(panel, switchBtn) {
+ document.addEventListener("click", event => {
+ var cDom = document.getElementById(panel);
+ let settingBtn = document.getElementById(switchBtn);
+ var tDom = event.target;
+ if (cDom == tDom || cDom.contains(tDom) || settingBtn == tDom || settingBtn.contains(tDom)) {
+ return;
+ }
+ cDom.classList.add("closed");
+ });
+ }
+ setClickOutsideToClose("display-setting", "display-settings-switch")
+ setClickOutsideToClose("nav-menu-panel", "nav-menu-switch")
}
function loadTheme() {