Theme Switcher Component

[deprecated]

Hey Discourse Community,

after a lot of requests I share a Theme Switcher component, encapsulated from my Alien Night Theme.
For now, once pressed the button it will switch your theme into a dark mode theme.

Later on I can maybe implement a setting page, where you can define your own global CSS class your theme should switch into.
Or just toggle between the first two themes you allowed for users to choose from…

Installation & Download

Preview

If you have feedback or questions, just let me know :slight_smile:

23 лайка

You can let admins select which themes they want to use. We have two different themes and each theme has it own dark mode.

When we click the switch to change light to dark, this component below should have change the logo’s color to light as the opposite. Now it doesn’t work with this switch.

https://meta.discourse.org/t/alternative-logo-for-dark-themes/88502

1 лайк

Ok, I’m not advanced in Discourse modding but I try to implement it.
Help from professional guys are appreciated :smirk: @Johani

Hmm, good point. Not sure how I can make a cross-component-compatibility-mode.
I’ll think about it.
Thanks for the first feedback so far!

3 лайка

Defining the themes in the settings is possible, but will complicate things. The hamburger menu theme selector is a good working example of how you’d change the theme based on ID.

https://github.com/discourse/discourse-hamburger-theme-selector/blob/master/common/header.html

5 лайков

I had some time tonight, so I worked on modifying the hamburger theme selector to toggle between two themes: Header Theme Toggle. Thanks so much for inspiring this with your theme @B-iggy!

11 лайков

Good Morning @awesomerobot ,
oh wow, that was quick :smile:
Much better than I could have done anyways.

I think this topic here is obsolete/redundant then :thinking:

5 лайков

Not necessarily, there are some benefits of switching the CSS rather than switching the entire theme. Everything’s self contained and you don’t need to fully refresh for all the changes to take effect.

7 лайков

Your component might be better with some improvements. I hope you continue to develop :handshake:

2 лайка

Awesome plugin! How can i force it to be in the first place (next to the search bar)?

1 лайк

Good Morning @szergely
glad to hear you like it :slight_smile:

Instead of changing the code on your end I think it makes sense to have it next to the search icon per default.
So I pushed this change now. Let me know if it’s fine :slight_smile:

3 лайка

Yes now its there! Thank you for the fast support, i really like this light/dark button! :heart_eyes:

3 лайка

К сожалению, я не могу отредактировать свой пост вверху :roll_eyes:

Поэтому важное уведомление: ссылка на предпросмотр была обновлена:

Я выкатил новую версию, и обычная кнопка «Обновить до последней» перестала работать, поэтому я переустановил тему :roll_eyes:

2 лайка

Сделал это в вики, теперь вы должны иметь возможность обновлять её :hugs:

5 лайков

При использовании тёмной темы с минималистичной темой Сэма это выглядит так:

Также есть ли какое-либо обходное решение для добавления альтернативного логотипа? Мой текущий логотип не читается на темном фоне, поэтому я хочу добавить инвертированную версию для темной темы.

В моей теме много жестко заданных цветов, и она корректно работает только со светлой схемой. Я открыт к исправлению этого, но пока что в тёмном режиме она работает некорректно.

2 лайка

Есть ли мысли насчет того, чтобы сделать нижнюю часть меньше? При использовании дополнительного компонента он занимает много места в заголовке. Например, мне нравится кнопка тёмного режима в этой теме Ghost в правом верхнем углу:

Могу ли я использовать это также для темы Material Design?

Можно ли переместить плагин из заголовка в выпадающее меню пользователя?

Нет простого способа, вам понадобится новый компонент.

1 лайк