DEV Community

Discussion on: Let's implement a Theme Switch 🎨 like the Angular Material Site

Collapse
 
alexandrutanasescu profile image
Alex

Hi! And what an awesome article! I wish i could've reached it before starting to implement the theme changer from the angular material docs site on my own. This really breaks it down to the core of what the mechanism actually is and makes it easier to understand.

One mention: setting resolveJsonModule and and esModuleInterop to true in the compilerOptions, in
tsconfig.app.json/tsconfig.json does not seem to be all there is to this trick. i am using node 10.15 and npm 6.9.0 with angular 9.1.1 and it still can't import the json as a module. However, this is not an issue due to the fact that you can just declare the options as a static map/list and import it where needed.

I am really curious how you would go about implementing the theme change for custom components -> as in getting access to the $primary and/or $accent in custom component css.

Collapse
 
siddajmera profile image
Siddharth Ajmera 🇮🇳

Hi Alex,

Thank you soo much for your kind words. 🙂

Regarding implementing the theme change for custom components, I'm afraid I haven't tried it so far.

Whenever I get a chance to do it, I'll probably write another article about it, and update you here. 🙂

Thanks,
Siddharth