F
Filament3mo ago
ericmp

How to store user theme preference

id like to know if my users use dark/light mode, so i've added a field into the users table - uses_dark_mode now i just need to fill it ^^ is there an easy workaround for this? i was thinking of some sort listener for the theme switch, and execute an update query
No description
5 Replies
ericmp
ericmp3mo ago
bump
toeknee
toeknee3mo ago
https://filamentphp.com/docs/2.x/admin/appearance#dark-mode When the user toggles between dark or light mode, a browser event called dark-mode-toggled is dispatched So listen for dark-mode-toggle event and then sent a browser request to update the users table with the change?
ericmp
ericmp3mo ago
i was on v3 docs page. ill checkout if is the same for v3, i guess yeah. thanks not sure how to call some sort of fn in there but ill figure it out
toeknee
toeknee3mo ago
Dammit my google again! Sorry, I would expect it to still be partially valid. But just listen for a click essentially on the dark mode, get the value and send a basic request which will be authed by the current user and update their table on this user.
ericmp
ericmp3mo ago
haha dont worry, happens to me all the time, im on v3 docs and somehow i end up at v2 docs okay ill try that out i think it happens using the algolia search thing it should filter only v3 docs if im on v3 pages i guess but shows v2 & v3 results i think maybe not but i think xd