Sottomenu dell'intestazione

:discourse2: Riepilogo I Sottomenu dell’intestazione ti permetteranno di creare un menu nell’intestazione, con sottomenu, utilizzando semplice testo!
:eyeglasses: Anteprima Anteprima su Discourse Theme Creator
:hammer_and_wrench: Link al repository https://github.com/discourse/discourse-header-submenus
:open_book: Nuovo a Discourse Themes? Guida per principianti all’uso di Discourse Themes

Installa questo componente del tema

Funzionalità

Desktop

Mobile

Impostazioni

Nome Descrizione
Elementi del menu Aggiungi elementi al menu. Un elemento per riga in questo ordine: Testo, icona, titolo, visualizzazione.
Elementi del sottomenu Aggiungi elementi al sottomenu. Un elemento per riga in questo ordine: Genitore, testo, icona, URL, target, titolo.
Icone SVG Includi le classi di icone FontAwesome per ogni icona utilizzata nelle liste sopra.
Modalità fissa Forza la visibilità del menu nella parte superiore dello schermo indipendentemente dalla posizione di scorrimento - Solo desktop
Mostra freccia Mostra le icone a forma di freccia accanto agli elementi del menu
Inverti posizione Visualizza gli elementi del menu sul lato opposto dello schermo
Sfondo menu Colore di sfondo per il menu. (esadecimale, rgb, rgba o nome colore CSS)
Colore elemento menu Colore per gli elementi del menu. (esadecimale, rgb, rgba o nome colore CSS)
Sfondo elemento menu attivo Colore di sfondo per gli elementi del menu quando sono attivi. (esadecimale, rgb, rgba o nome colore CSS)
Colore elemento menu attivo Colore per gli elementi del menu quando sono attivi. (esadecimale, rgb, rgba o nome colore CSS)
Sfondo sottomenu Colore di sfondo per i sottomenu. (esadecimale, rgb, rgba o nome colore CSS)
Colore elemento sottomenu Colore per gli elementi del sottomenu. (esadecimale, rgb, rgba o nome colore CSS)
Sfondo elemento sottomenu al passaggio del mouse Colore di sfondo per gli elementi del sottomenu quando ci passi sopra con il mouse. (esadecimale, rgb, rgba o nome colore CSS)
Colore elemento sottomenu al passaggio del mouse Colore per gli elementi del sottomenu quando ci passi sopra con il mouse. (esadecimale, rgb, rgba o nome colore CSS)
Colore divisore Colore per le linee di divisione nei sottomenu. (esadecimale, rgb, rgba o nome colore CSS)

Ci sono quattro gruppi di impostazioni

  1. Elementi del menu

    Inserisci gli elementi che vuoi far apparire nel menu. Un elemento separato da virgole per riga in questo ordine

    Testo, icona, titolo, visualizzazione

    Testo: ciò che appare nel menu.
    Icona: l’icona visualizzata accanto all’elemento. Se non vuoi usare un’icona, usa none.
    Titolo: il testo che appare quando ci passi sopra con il mouse sull’elemento.
    Visualizzazione: scegli su quali dispositivi l’elemento deve apparire.

    vdm appare sia su desktop che su mobile
    vdo appare solo su desktop,
    vmo appare solo su mobile.

    A causa della mancanza di spazio, non è consigliabile aggiungere più di 3-4 elementi su mobile.

  2. Elementi del sottomenu

    Inserisci un elenco degli elementi del sottomenu che vuoi aggiungere al tuo menu. Un elemento separato da virgole per riga in questo ordine

    Genitore, testo, icona, URL, target, titolo

    Genitore: il nome dell’elemento del menu genitore sotto cui deve apparire questo elemento del sottomenu. Usa il valore testo dalla lista sopra.
    Testo: il testo che appare per questo elemento del sottomenu.
    Icona: l’icona per questo elemento del sottomenu; usa none se non è necessaria un’icona.
    URL: il percorso a cui punta questo elemento del menu. Puoi usare anche percorsi relativi.
    Target: scegli se questo elemento si aprirà in una nuova scheda o nella stessa scheda. Usa blank per aprire il link in una nuova scheda, o self per aprirlo nella stessa scheda.
    Titolo: il testo che appare quando ci passi sopra con il mouse sull’elemento.
    Divisori: puoi anche aggiungere divisori tra gli elementi del sottomenu. Per aggiungere un divisore usa genitore, divider.

Ecco un esempio rapido per coprire i punti 1 e 2 sopra:

Immagina di voler aggiungere un elemento del menu chiamato Design e di aggiungere alcuni elementi al suo sottomenu come mostrato qui sotto

Inizieresti inserendo questo come menu_item

Design, magic, Get inspired!, vdm

E poi inseriresti questi come elementi sub_menu

Design, Galleries, th, #, blank, Cool galleries for you to look at.
Design, Design process, lightbulb-o, #, blank, Learn the basics.
Design, Blog design, columns, #, blank, What makes for a great blog?
Design, divider
Design, Freebies, gift, #, blank, Everyone likes freebies!
Design, Photoshop tutorials, book, #, blank, Photoshop for beginners.
Design, Design trends, bar-chart, #, blank, Stay on top of the current trends!

È tutto!

Il tema include di default un menu segnaposto, quindi dacci un’occhiata e chiedi se hai domande.

  1. Opzioni di layout.

    Queste sono piuttosto autoesplicative

  2. Opzioni di colore

    Queste sono vuote di default, ma se aggiungi un colore qui, sovrascriverà i valori predefiniti del componente, che si basano sulla combinazione di colori corrente.


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

90 Mi Piace

I just pushed an update to this component.

https://github.com/discourse/discourse-header-submenus/commit/cbb1c280f031024335cf3b103b0e2c242c5862b1
There are no visual changes and if you’ve added custom CSS to your theme, it should still work because the component still has the same classes.

I dropped the external library that the component previously used and jQuery by extension. I went through the issues reported here, fixed the one I could reproduce and then deleted the replies to keep everything tidy. If your problem still persists after the update, please feel free to post it.

Beyond that, the update only adds one new feature. The submenus will now show on hover on desktop instead of requiring a click.

14 Mi Piace

Nice update Joe, I’ve only run into two problems on mobile.

  1. You can no longer scroll side to side if you have a lot of menu items.
  2. When you tap an item in the dropdown, the dropdown stays open
2 Mi Piace

This should still work, but it’s only on the mobile view. So, if you just test it the browser fake mobile view without changing the user agent, it won’t work. Can you please confirm that you’re testing this on an actual phone. If so, can you let me know what device / browser you’re using?

I see this too. The reason is that all the dropdown (opening / closing) behaviour is now handled with CSS instead of JavaScript. I don’t think CSS has a way to handle auto closing the dropdown after you click it. So, we have to fallback to JS for that particular issue. I’ll do it after you confirm the scroll issue on mobile.

2 Mi Piace

This is on an iPhone 8 with the Discourse app, same in Safari. Thanks Joe!

2 Mi Piace

Any update on this Joe? Thanks!

Over at the Sponge community site they have a nice integration of this in the main header instead of an extra layer at the top:


How can this be achieved? Would love it for our site.
4 Mi Piace

Can submenus be possible to header links? This theme component adds a new menu above the header, but some people don’t want a new navigation menu. They just want ability to hover over the current header links and have submenus.

5 Mi Piace

That is nice. I wonder how they did it.

1 Mi Piace

is someone having this issue? the social networks icons are not working (they were) and even using a different fa it won’t show.

Captura de pantalla 2020-07-23 a les 13.42.16

1 Mi Piace

Have you tried the prefix of fab, since these are brands they need to have this prefix.

1 Mi Piace

thansk for you reply @davidkingham I added the prefix fab, but the logo doesn’t appear.

1 Mi Piace

Don’t forget to edit the icons in the list of links also, you must include fab- prefix in these

4 Mi Piace

Bingo! that was it :slight_smile: thanks a lot!

2 Mi Piace

Hi, I’m not sure why but the setting “Menu-item-active-background” doesn’t seem to be working right. I believe it should just change the background color of the menu when I hover, however the selected color is completely covering up the text. See here…

Menu-item-active-background

Also, the setting below it " Menu-item-active-color" doesn’t seem to do anything. I’ve tried different color codes and nothing changes when I go to test it.

Any ideas?

2 Mi Piace

I would like to place the submenus below the site header instead of top. Could you please tell me how to do this? A code snippet would help :pray:

1 Mi Piace

@Johani @davidkingham Did you find a solution for this problem “When you tap an item in the dropdown, the dropdown stays open” ?

Thank you

1 Mi Piace

No it’s still behaving this way, one potential solution is to show only icons on mobile with no text, thoughts?

1 Mi Piace

How showing just icons on mobile solves the problem? "When you tap an item in the dropdown, the dropdown stays open”

1 Mi Piace

@ElForoViajero Your submenus seem to work okay on both desktop and mobile. As soon as you click the item in the menu, the screen refreshes and the menu closes automatically. Did you have to do something special?

1 Mi Piace