Restructure layout and add widget

This commit is contained in:
Dreamgineer
2025-11-12 20:52:50 -05:00 Unverified
parent b831e2f2a1
commit f2551e5d51
51 changed files with 181 additions and 121 deletions
+8 -4
View File
@@ -80,10 +80,14 @@ export default function CommsProvider({
export const comms = {
var(name: keyof WebsiteComms) {
const comms = use(CommsContext);
if(!comms.active) {
console.warn("Inter-component communication used outside of provider. Using local state instead.");
if (!comms.active) {
console.warn(
"Inter-component communication used outside of provider. Using local state instead.",
);
}
const [state, setState] = useState(comms.active?comms.get(name): undefined);
const [state, setState] = useState(
comms.active ? comms.get(name) : undefined,
);
useEffect(() => {
function listener(value: WebsiteComms[typeof name]) {
setState(value);
@@ -97,7 +101,7 @@ export const comms = {
| ((prev: WebsiteComms[typeof name]) => WebsiteComms[typeof name]),
) {
const v = typeof value === "function" ? value(comms.get(name)) : value;
if(comms.active) comms.set(name, v);
if (comms.active) comms.set(name, v);
else setState(v);
}