Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find out how to import CSS files into JavaScript #216

Open
programarivm opened this issue Apr 17, 2024 · 3 comments
Open

Find out how to import CSS files into JavaScript #216

programarivm opened this issue Apr 17, 2024 · 3 comments

Comments

@programarivm
Copy link
Member

programarivm commented Apr 17, 2024

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 #203

Happy coding!

@programarivm programarivm pinned this issue Apr 17, 2024
@Shaxowfall
Copy link

if you setup a handler script like:

<script> { let worker=new Worker("/path/to/module.js","options"||undefined); worker.onmessage=function(d){document.head.insertAdjacentHTML("beforeend","<style>"+d.data+"</style>")}

}
</script>

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
Copy link
Member Author

@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.

@programarivm programarivm unpinned this issue May 2, 2024
@ArmSershant
Copy link

ArmSershant commented May 22, 2024

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

@chesslablab chesslablab deleted a comment Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants