diff --git a/main.ts b/main.ts index a00745a..90bf228 100644 --- a/main.ts +++ b/main.ts @@ -1,28 +1,28 @@ type TPSSearchParams = { - display?: "house-only" | "full" + display?: 'house-only' | 'full' } const params = new URL(document.location.href).searchParams -const display = params.get("display") +const display = params.get('display') -if (display === "house-only") { - document.querySelector("header")?.remove() +if (display === 'house-only') { + document.querySelector('header')?.remove() } -const size = params.get("size") +const size = params.get('size') -if (size === "small") { - const body = document.querySelector("body") +if (size === 'small') { + const body = document.querySelector('body') if (body) { - body.style.fontSize = "15px" + body.style.fontSize = '15px' } } -const focusElements = params.getAll("focus") +const focusElements = params.getAll('focus') if (focusElements.length > 0) { - const focusables = document.querySelectorAll(".focusable") + const focusables = document.querySelectorAll('.focusable') focusables.forEach((focusable) => { const elementToFocus = focusElements.some((element) => @@ -30,20 +30,35 @@ if (focusElements.length > 0) { ) if (!elementToFocus) { - focusable.classList.add("no-focus") + focusable.classList.add('no-focus') } }) } -const textHide = params.get("text") +const textHide = params.get('text') -if (textHide === "hide") { - const focusables = document.querySelectorAll(".focusable") - focusables.forEach((focusable) => focusable.classList.add("text-hide")) +if (textHide === 'hide') { + const focusables = document.querySelectorAll('.focusable') + focusables.forEach((focusable) => focusable.classList.add('text-hide')) } -const scrollParam = params.get("scroll") +const scrollParam = params.get('scroll') -if (scrollParam === "end") { - window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" }) +if (scrollParam === 'end') { + window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }) +} + +const primaryColorParam = params.get('primary') + +if (primaryColorParam) { + document.documentElement.style.setProperty( + '--primary-color', + `#${primaryColorParam}` + ) +} + +const colorParam = params.get('color') + +if (colorParam) { + document.documentElement.style.setProperty('--color', `#${colorParam}`) }