Get the current theme

My plugin embeds a third party iframe and I need to pass it some css style declarations so it renders properly in the current theme. On the dark theme, it renders black text on a dark background.

What is the best way for me to access the current theme in my component or the current route?

1 Like

We use this before action on every request:

https://github.com/discourse/discourse/blob/aaafbd1ae5d5e071d0fcd25ee323533eb294bf5f/app/controllers/application_controller.rb#L46-L46

It sets theme_ids on the controller.

But once you have the id I am not sure what you can do, there is nothing that says if it is dark or light… all you have is the theme css.

3 Likes

Cheers!

I got jQuery to tell me the colors and merged into the css of the iframe. It sort of works…

3 Likes