add the color setup
This commit is contained in:
51
main.ts
51
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}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user