Composant de changement de thème

[déprécié]

Bonjour à la communauté Discourse,

suite à de nombreuses demandes, je partage un composant de changement de thème, encapsulé à partir de mon thème Alien Night.
Pour l’instant, une fois le bouton appuyé, il bascule votre thème vers un mode sombre.

Plus tard, je pourrai peut-être implémenter une page de paramètres où vous pourrez définir votre propre classe CSS globale dans laquelle votre thème devrait basculer.
Ou simplement basculer entre les deux premiers thèmes que vous avez autorisés pour les utilisateurs…

Installation et téléchargement

Aperçu

Si vous avez des retours ou des questions, faites-le-moi savoir :slight_smile:

23 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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

2 « J'aime »

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

1 « J'aime »

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 « J'aime »

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

3 « J'aime »

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 « J'aime »

C’est maintenant un wiki, vous devriez pouvoir le mettre à jour à présent :hugs:

5 « J'aime »

Lorsque vous utilisez le mode sombre avec le thème minimaliste de Sam, cela donne ceci :

Y a-t-il également une solution de contournement pour ajouter un logo alternatif ? Mon logo actuel n’est pas lisible sur un fond sombre, c’est pourquoi je souhaite en ajouter un inversé pour le mode sombre.

Mon thème contient de nombreuses couleurs en dur et ne fonctionne correctement qu’avec un schéma de couleurs clair. Je suis ouvert à la correction de ce problème, mais pour l’instant, il ne fonctionne pas correctement en mode sombre.

2 « J'aime »

Qu’en pensez-vous de réduire la taille du bas ? Lors de l’utilisation d’un composant supplémentaire, cela prend beaucoup de place dans l’en-tête. Par exemple, j’aime le bouton du mode sombre dans ce thème Ghost en haut à droite : https://liebling.eduardogomez.io/

Puis-je également l’utiliser pour le thème Material Design ?

Y a-t-il un moyen de déplacer le plugin de l’en-tête vers le menu déroulant de l’utilisateur ?

Pas de façon simple, vous auriez besoin d’un nouveau composant.

1 « J'aime »