主题切换组件

[deprecated]

大家好 Discourse 社区,

应许多用户的要求,我分享了一个主题切换组件,该组件封装自我的 Alien Night 主题。目前,按下按钮后,它会将您的主题切换为深色模式主题。

未来,我可能会实现一个设置页面,您可以在其中定义自己的全局 CSS 类,让主题切换至该类。或者,只需在您允许用户选择的两个主题之间进行切换……

安装与下载

预览

如果您有任何反馈或疑问,请随时告诉我 :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 个赞

Unfortunately I can’t edit my own post at the top :roll_eyes:

Hence the important notice that the preview link got updated:

I pushed a new version and the regular “Update to Latest” was broken, so I reinstalled it :roll_eyes:

2 个赞

已设置为维基,你现在应该可以更新它了 :hugs:

5 个赞

使用 Sam 的极简主题并启用深色模式时,效果如下:

另外,有没有什么变通方法可以添加一个替代徽标?我当前的徽标在深色背景下不可读,因此我想为深色模式添加一个反色版本。

我的主题包含大量硬编码的颜色,仅在浅色模式下能正常工作。我乐意修复这个问题,但目前它在深色模式下无法正常运行。

2 个赞

关于把底部做小一点有什么想法吗?使用额外组件时,它在标题栏中占用了很多空间。例如,我喜欢这个 Ghost 主题右上角的深色模式按钮:

这个也能用于 Material Design 主题吗?

有没有办法将插件从标题栏移动到下拉用户面板中?

没有简单的方法,您需要一个新组件。

1 个赞