Pulsante Nuovo Intestazione Argomento

:discourse2: Riepilogo New Topic Header Button aggiunge un comodo pulsante ‘Nuovo Argomento’ all’intestazione di tutte le pagine
:eyeglasses: Anteprima Anteprima su Discourse Theme Creator
:hammer_and_wrench: Repository https://github.com/discourse/discourse-new-topic-button-theme-component
:question: Guida all’installazione Come installare un tema o un componente del tema
:open_book: Nuovo ai temi di Discourse? Guida per principianti all’uso dei temi di Discourse

Installa questo componente del tema

Funzionalità

Un semplice componente del tema per aggiungere il pulsante + Nuovo Argomento all’intestazione. Il pulsante verrà visualizzato su ogni pagina, anche all’interno degli argomenti.

Screenshot:

Desktop:

Mobile:

Impostazioni:

Nome Descrizione
icona pulsante nuovo argomento Scegli un’icona per il pulsante. Puoi utilizzare qualsiasi nome di icona gratuito di FontAwesome 6 come music o star.
testo pulsante nuovo argomento Inserisci il testo che desideri per il pulsante. Puoi anche lasciarlo vuoto se vuoi utilizzare solo un’icona.
titolo pulsante nuovo argomento Inserisci il titolo che desideri per il pulsante. Se lasciato vuoto, il titolo sarà uguale al testo del pulsante.
nascondi pulsante predefinito Nascondi il pulsante predefinito “Nuovo argomento” nelle liste degli argomenti
mostra agli anonimi Mostra il pulsante ai visitatori non registrati e reindirizza al login al clic

:discourse2: Ospitato da noi? I componenti del tema sono disponibili per l’uso nei nostri piani Standard, Business ed Enterprise.

57 Mi Piace

Pretty awesome. Now we’re talking!

FYI, we pushed the button yesterday and it was our 2nd biggest day in registrations for the past 30 days. Not sure if it was coincidence or not, but I have a feeling it’s a good way to onboard new users. Will keep an eye on the metrics

(Realizing now it must have been a coincidence, because the button only appears for users who have already logged in. Nonetheless, activity does seem to be higher)

5 Mi Piace

Hi,

Is it possible to change the color of the button, but not change the color of all buttons in the site?

If so, which is the css code for the button only?

thanks!

1 Mi Piace

Use this code, changing the color obviously.

#new-create-topic {
    background-color: red;
}
3 Mi Piace

Hm, how about showing the new topic button for everyone and make it act like the default Reply-to-topic button, i.e. as the user to login/sign up if they’re not logged in?

In fact, this might be something to consider for the default new topic button too, but I guess this feature would be most effective in this theme component…

4 Mi Piace

Inviting every random visitor to create a new topic… will end in tears :sob:

Nothing kills a site quicker than a page full of low-value or gibberish topics.

7 Mi Piace

Well, they can’t create that topic unless they sign up. And encouraging people to sign up is obviously a good thing (and is being done by default via the sign-up button and the reply-to-topic button). So I don’t really see why the new topic button should cause any problems.

6 Mi Piace

Is it possible to hide the button on mobile but show the floating button?

To hide the button on mobile add

.header-buttons #new-create-topic {
    display:none;
}

in your mobile > CSS tab

The floating button you are referring is the one used on the Material Design Theme component? If so you need to copy and paste the part of CSS relative to the floating button (New Topic Fab) from material-design-stock-theme/desktop/desktop.scss at main · discourse/material-design-stock-theme · GitHub to your mobile > CSS tab (deleting the lines that start with @include [...]).

However your requests are going off topic, it’s better if you open another topic.

4 Mi Piace

Thanks, sorry for the offtopicing :slight_smile:

1 Mi Piace

This is good, but it has two drawbacks from my point of view.
First is the location of the button in the top bar. We already have other stuff added to the top bar and this makes it a bit crowded.
Second is the fact it appears on every page, even where it is a bit illogical (eg on my profile page, or the groups list).
The primary use case from my point of view is to make it slightly easier for users not to make off-topic replies when viewing a thread. The place I find it is really needed and useful is when viewing a topic/thread and ideally I would like it to appear both at the top (in line with the topic title) and at the bottom next to the main blue Reply button.
A halfway house would be to show it in the current position but only on /t/xxx pages.
Is this possible?

I don’t want to display it on mobile, how do I do it?

I also want to show it to the unregistered user, clicking the button will ask you to login

Oh. Bummer. I don’t know what “wrong position” means (it seems OK on my test site), but did assume that the button would work, which I see now that it doesn’t. It looks like it’s not as simple as I thought. :frowning_face:

1 Mi Piace

Create a new theme component and add this in the Mobile > CSS tab

.mobile-view #new-create-topic {
    display:none
}
4 Mi Piace

good idea - you did it ?

Can someone help me know what CSS to target to get this + New Topic button to look/function exactly as the colorful “Reply” button on my site? (i.e. the standard state, as well as the hover and clicked-on state - active?)

Here’s a visual explanation of what I’d like to do…

change its class to btn-primary ?
(not sure if you can have two btn-primary items on a page)
If you want to have a pure css solution then inspect the styling of the blue primary button (in all its states) and replicate that.

Grazie per questo componente @Joe.
Funziona perfettamente, con una piccola eccezione :slight_smile:
Su mobile ho ancora due pulsanti: quello nuovo e quello predefinito + New Topic.

Ho fatto scomparire quello predefinito modificando la seguente definizione di stile:


Ora funziona bene sia su desktop che su mobile, ma sarebbe bello se il tuo componente si occupasse di questo. Soprattutto perché, per qualche motivo, se un amministratore disattiva il tuo componente, nessun pulsante + New Topic sarà visibile.

4 Mi Piace

@Johani Ho creato una pull request con la modifica menzionata sopra.

Potresti darci un’occhiata?

2 Mi Piace

Grazie per il componente! Credo che ci siano casi d’uso validi per avere sempre presente l’opzione di creare un nuovo topic nell’intestazione. Tuttavia, sto incontrando difficoltà con un dettaglio dell’implementazione e mi chiedo come altri affrontino la questione:

Attualmente, il componente riflette la categoria in cui si trova l’utente e apre il compositore con questa categoria già precompilata. Tuttavia, non tiene conto del fatto che l’utente abbia o meno i diritti di scrittura per quella specifica categoria. Di conseguenza, precompila il compositore con quella categoria (anche se l’utente non potrebbe selezionarla manualmente) e genera un errore al momento di salvare il topic.

Il pulsante “Nuovo topic” predefinito risolve il problema disabilitandosi su tali categorie. Ma penso che replicare questo comportamento non sarebbe molto intuitivo, dato che l’idea del pulsante nell’intestazione è fornire un accesso globale alla creazione di nuovi topic. Sarebbe quindi strano se a volte non funzionasse.

Qual potrebbe essere un approccio generale valido per questo? O come lo affrontano gli altri che utilizzano il componente? Meglio eliminare completamente il precompilamento?

3 Mi Piace