From cdab7b77db5394b4f5e9afb6d723d7612fe4ba73 Mon Sep 17 00:00:00 2001 From: Zvonimir Rudinski Date: Sun, 7 Jul 2024 07:12:58 +0200 Subject: [PATCH] fix section saving --- src/components/Section.astro | 15 +++++++++++---- src/pages/index.astro | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/Section.astro b/src/components/Section.astro index 4137e78..8e01590 100644 --- a/src/components/Section.astro +++ b/src/components/Section.astro @@ -2,13 +2,14 @@ import { slugify } from "../utils"; interface Props { title: string; + isMain?: boolean; hasBorder?: boolean; } -const { title, hasBorder } = Astro.props; +const { title, hasBorder, isMain } = Astro.props; --- - +

class Section extends HTMLElement { container: HTMLElement; + isMain: boolean; constructor() { super(); @@ -39,6 +41,7 @@ const { title, hasBorder } = Astro.props; } this.container = container; + this.isMain = this.dataset.hasOwnProperty("ismain"); const trigger = this.querySelector("h2"); @@ -71,13 +74,17 @@ const { title, hasBorder } = Astro.props; extend(section: Element, container: HTMLElement) { container.style.maxHeight = "1000vh"; section.classList.add("open"); - sessionStorage.setItem("openSection", this.id); + if (this.isMain) { + sessionStorage.setItem("openSection", this.id); + } } collapse(section: Element, container: HTMLElement) { container.style.maxHeight = "0"; section.classList.remove("open"); - sessionStorage.removeItem("openSection"); + if (this.isMain) { + sessionStorage.removeItem("openSection"); + } } } diff --git a/src/pages/index.astro b/src/pages/index.astro index 133b823..6bdcff5 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -25,7 +25,7 @@ import { projects } from "../projects"; $ Zvonimir Rudinski / Home

-
+

Looking for a fully commited developer who can digitalize your business?

@@ -48,7 +48,7 @@ import { projects } from "../projects";

-
+

Here are some of the projects I have worked on. You can find more information about a project by clicking on its name. @@ -75,7 +75,7 @@ import { projects } from "../projects"; >blog -

+