vercel 2 the vercelening

This commit is contained in:
MeowcaTheoRange 2023-11-12 15:32:40 -06:00
parent 67b7d61d02
commit 670f3af31d

View file

@ -1,27 +1,32 @@
"use client"; "use client";
import { useEffect } from "react"; import { useEffect, useRef } from "react";
import Floaty from "../Floaty/Floaty"; import Floaty from "../Floaty/Floaty";
export default function AccessibilityBox() { export default function AccessibilityBox() {
const checkbox = useRef<HTMLInputElement>(null);
useEffect(() => { useEffect(() => {
if (window.localStorage.getItem("a11y")) if (window == null) return;
if (window?.localStorage.getItem("a11y")) {
document.body.parentElement?.classList.add("a11y"); document.body.parentElement?.classList.add("a11y");
if (checkbox.current != null) checkbox.current.checked = true;
}
}, []); }, []);
return ( return (
<Floaty top> <Floaty top>
<input <input
id="accessibility" id="accessibility"
type="checkbox" type="checkbox"
ref={checkbox}
onClick={function (x) { onClick={function (x) {
if (window == null) return;
if ((x.target as HTMLInputElement).checked) { if ((x.target as HTMLInputElement).checked) {
document.body.parentElement?.classList.add("a11y"); document.body.parentElement?.classList.add("a11y");
window.localStorage.setItem("a11y", "a11y"); window?.localStorage.setItem("a11y", "a11y");
} else { } else {
document.body.parentElement?.classList.remove("a11y"); document.body.parentElement?.classList.remove("a11y");
window.localStorage.setItem("a11y", ""); window?.localStorage.setItem("a11y", "");
} }
}} }}
defaultChecked={window.localStorage.getItem("a11y") == "a11y"}
/> />
<label htmlFor="accessibility">Accessibility</label> <label htmlFor="accessibility">Accessibility</label>
</Floaty> </Floaty>