Christiano
11/23/2023, 9:27 PMcolorMode = colorMode.opposite
. Exactly the same way the actual Kobweb site does it.
Besides that I also have a function that measures the height of grid items to make them span across the correct amount of rows. The recalculation is done when the window resize
event is triggered.
Changing the colorMode
makes the page reload but of course does not trigger the window resize
event. Is there another event that gets triggered when changing the colorMode that I can use? 🤔David Herman
11/23/2023, 9:31 PMLaunchedEffect(colorMode) {...}
David Herman
11/23/2023, 9:32 PMChristiano
11/23/2023, 9:35 PMdispatchEvent
So this triggers the event after updating the colorMode
colorMode = colorMode.opposite
window.dispatchEvent(Event("storage"))
I will also try to use your suggestion and see what suits the project more! Thank you again for the quick response!David Herman
11/23/2023, 9:37 PMChristiano
11/23/2023, 9:44 PMonClick = {
// Toggle the color mode
colorMode = colorMode.opposite
window.dispatchEvent(Event("update-color-mode"))
},
and in another file I can listen to this event
window.addEventListener("update-color-mode", {
recalculateGridItems()
})
David Herman
11/23/2023, 9:49 PM