chesslablab / website

Website intended to learn and play chess online.
https://chesslablab.github.io/website/
MIT License
22 stars 24 forks source link

Find out how to import CSS files into JavaScript #216

Open programarivm opened 6 months ago

programarivm commented 6 months ago

The dark and the light theme constants currently defined as strings in the assets/js/pages/apply_settings.js file need to be imported from separate files similar to how the translation files in the assets/js/translations folder can be imported throughout the codebase.

See https://github.com/chesslablab/website/issues/203

Happy coding!

Shaxowfall commented 6 months ago

if you setup a handler script like:

and you setup your module to post back the stored css like:

var stored_css="body {color:white;background:black}"; postmessage(stored_css);

then it will work no problem just make sure to validate the data that the handler receives is correct and not fraudulent

programarivm commented 6 months ago

@Shaxowfall, welcome to ChesslabLab.

Thank you for joining the community. Please make sure to read the Contributing Guidelines.

Also thank you for posting a comment on this issue! If I'm not very much mistaken, this should be done using CSS module scripts.

ArmSershant commented 5 months ago

We can just install a dark/light mode package and use localStorage to find out what mode is active for each user and in global css file we can define color styles for light and dark modes