Botão de Cabeçalho do Novo Tópico

:discourse2: Resumo New Topic Header Button adiciona um conveniente botão ‘Novo Tópico’ ao cabeçalho de todas as páginas
:eyeglasses: Pré-visualização Pré-visualizar no Discourse Theme Creator
:hammer_and_wrench: Repositório https://github.com/discourse/discourse-new-topic-button-theme-component
:question: Guia de Instalação Como instalar um tema ou componente de tema
:open_book: Novo em Temas do Discourse? Guia para iniciantes sobre o uso de Temas do Discourse

Instale este componente de tema

Funcionalidades

Um componente de tema simples para adicionar o botão + Novo Tópico ao cabeçalho. O botão aparecerá em todas as páginas - mesmo dentro de tópicos.

Capturas de tela:

Desktop:

Mobile:

Configurações:

Nome Descrição
ícone do botão novo tópico Escolha um ícone para o botão. Você pode usar qualquer nome de ícone gratuito do FontAwesome 6, como music ou star.
texto do botão novo tópico Insira o texto que você deseja que o botão use. Você também pode deixar isso vazio se quiser usar apenas um ícone.
título do botão novo tópico Insira o título que você deseja que o botão use. Se isso for deixado vazio, o título será o mesmo que o texto do botão.
ocultar botão padrão Ocultar o botão padrão “Novo tópico” nas listas de tópicos
mostrar para anônimo Mostrar o botão para visitantes desconectados e redirecionar para login ao clicar

:discourse2: Hospedado por nós? Componentes de tema estão disponíveis para uso em nossos planos Standard, Business e Enterprise.

57 curtidas

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 curtidas

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 curtida

Use this code, changing the color obviously.

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

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 curtidas

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 curtidas

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 curtidas

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 curtidas

Thanks, sorry for the offtopicing :slight_smile:

1 curtida

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 curtida

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

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

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.

Obrigado por este componente @Joe.
Funciona perfeitamente, com uma pequena exceção :slight_smile:
No mobile, ainda tenho dois botões: o novo e o padrão + Novo Tópico.

Fiz o botão padrão desaparecer alterando a seguinte definição de estilo:


Agora funciona bem tanto em desktops quanto em dispositivos móveis, mas seria ótimo se seu componente cuidasse disso. Principalmente porque, por algum motivo, se algum administrador desativar seu componente, nenhum botão + Novo Tópico ficará visível.

4 curtidas

@Johani Fiz um pull request com a alteração mencionada acima.

Você poderia dar uma olhada?

2 curtidas

Obrigado pelo componente! Acredito que existam casos de uso válidos para sempre manter a opção de criar um novo tópico presente no cabeçalho. No entanto, estou com dificuldades em um detalhe da implementação e gostaria de saber como outros lidam com isso:

Atualmente, o componente reflete a categoria em que o usuário está e abre o editor com essa categoria pré-preenchida. Porém, ele não verifica se o usuário tem permissão de escrita naquela categoria específica. Assim, ele preenche o editor com essa categoria (embora o usuário não pudesse selecioná-la manualmente de outra forma) e resulta em um erro ao tentar salvar o tópico.

O botão padrão de “Novo tópico” resolve isso sendo desabilitado em categorias como essas. Mas acho que replicar esse comportamento não seria tão intuitivo, já que a ideia do botão no cabeçalho é oferecer um acesso global para criar novos tópicos. Nesse caso, seria estranho se ele às vezes não funcionasse.

Qual seria uma boa abordagem geral para isso? Ou como outros que utilizam o componente lidam com essa situação? Seria melhor simplesmente remover o pré-preenchimento completamente?

3 curtidas