Componente per il cambio tema

[deprecated]

Ciao comunità Discourse,

dopo molte richieste, condivido un componente per il cambio tema, isolato dal mio Tema Alien Night.
Per ora, una volta premuto il pulsante, il tuo tema verrà commutato in un tema a modalità scura.

In futuro potrei implementare una pagina delle impostazioni dove potrai definire la tua classe CSS globale a cui il tema dovrebbe commutarsi.
Oppure semplicemente alternare tra i primi due temi che hai consentito agli utenti di scegliere…

Installazione e Download

Anteprima

Se hai feedback o domande, fammi sapere :slight_smile:

23 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

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

2 Mi Piace

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

1 Mi Piace

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 Mi Piace

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

3 Mi Piace

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 Mi Piace

Made it wiki, you should be able to update it now :hugs:

5 Mi Piace

Quando si utilizza la modalità scura con il tema minimale di Sam, l’aspetto è il seguente:

Inoltre, esiste qualche soluzione per aggiungere un logo alternativo? Quello attuale non è leggibile su sfondo scuro, quindi vorrei aggiungerne uno invertito per la modalità scura.

Il mio tema ha molti colori hardcoded e funziona correttamente solo con un tema chiaro. Sono disponibile a risolvere il problema, ma per ora non funziona bene in modalità scura.

2 Mi Piace

Hai qualche idea per rendere la parte inferiore più piccola? Quando si utilizza un componente aggiuntivo, occupa molto spazio nell’intestazione. Ad esempio, mi piace il pulsante per la modalità scura in questo tema Ghost in alto a destra:

Posso usare questo anche per il tema Material Design?

C’è un modo per spostare il plugin dall’intestazione al pannello utente a tendina?

Non esiste un modo banale: è necessario un nuovo componente.

1 Mi Piace