Header Submenus

:discourse2: Summary Header Submenus will allow you to build a header menu - with submenus - using plain text!
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-header-submenus
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Features

Desktop

Mobile

Settings

Name Description
Menu items Add menu items. One item per line in this order: Text, icon, title, view.
Submenu items Add submenu items. One item per line in this order: Parent, text, icon, URL, target, title.
Svg icons Include FontAwesome icon classes for each icon used in the lists above.
Fixed mode Force the menu to be visible at the top of the screen regardless of scroll position - Desktop only
Show caret Show caret icons next to menu items
Invert position Display menu items on the opposite side of the screen
Menu background Background color for the menu. (hex, rgb, rgba or CSS color name)
Menu item color Color for menu items. (hex, rgb, rgba or CSS color name)
Menu-item-active-background Background color for menu items when active. (hex, rgb, rgba or CSS color name)
Menu-item-active-color Color for menu items when active. (hex, rgb, rgba or CSS color name)
Submenu background Background color for submenus. (hex, rgb, rgba or CSS color name)
Submenu item color Color for submenu items. (hex, rgb, rgba or CSS color name)
Submenu item hover background Background color for submenus items when hovered. (hex, rgb, rgba or CSS color name)
Submenu item hover color Color for submenus items when hovered. (hex, rgb, rgba or CSS color name)
Divider color Color for divider lines in submenus. (hex, rgb, rgba or CSS color name)

There are four groups of settings

  1. Menu items

    Enter the items you want to appear on the menu. One comma-delimited item per line in this order

    Text, icon, title, view

    Text: what appears on the menu.
    Icon: the icon displayed next to the item. If you do not want to use an icon, use none.
    Title: the text that appears when the item is hovered.
    View: Choose what devices the item appears on.

    ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ vdm appears on both desktop and mobile
    ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ vdo appears on desktops only,
    ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ ‏‏‎ vmo appears on mobiles only.

    Due to lack of space, it is not recommended to add more than 3-4 items on mobile.

  2. Submenu items

    Enter a list of the submenu items you want to add to your menu. One comma-delimited item per line in this order

    Parent, text, icon, URL, target, title

    Parent: the name of the parent menu item which this submenu item should show under. Use the text value from the list above.
    Text: the text that shows for this submenu item.
    Icon: the icon for this submenu item, use none if no icon is needed.
    URL: the path this menu item links to. You can use relative paths as well.
    Target: Choose whether this item will open in a new tab or in the same tab. Use blank to open the link in a new tab, or use self to open it in the same tab.
    Title: the text that shows when the item is hovered.
    Dividers: You can also add dividers between submenu items. To add a divider use parent, divider.

Here’s a quick example to cover points 1 and 2 above:

Let’s say I want to add a menu item called Design and add a few items to its submenu like so

I would first enter this as a menu_item

Design, magic, Get inspired!, vdm

And then enter these as sub_menu items

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!

That’s it!

The theme comes with a placeholder menu by default, so have a look at that and ask if you have questions.

  1. Layout options.

    these are pretty self-explanatory

  2. Color options

    These are empty by default, but if you add a color here, it will override the component’s defaults which are based on the current color scheme.


:discourse2: Hosted by us? Theme components are available to use on our Standard, Business, and Enterprise plans.

Last edited by @JammyDodger 2024-06-12T21:46:41Z

Check documentPerform check on document:
90개의 좋아요

이 컴포넌트에 업데이트를 적용했습니다.

시각적인 변경 사항은 없으며, 테마에 사용자 지정 CSS를 추가했다면 컴포넌트가 동일한 클래스를 유지하고 있기 때문에 계속 작동할 것입니다.

이전에 컴포넌트가 사용했던 외부 라이브러리, 그리고 그에 따라 사용되던 jQuery를 제거했습니다. 여기에 보고된 이슈들을 검토하여 재현할 수 있는 문제를 수정한 후, 모든 것을 깔끔하게 정리하기 위해 해당 답변들을 삭제했습니다. 업데이트 후에도 문제가 지속된다면 언제든지 게시해 주시기 바랍니다.

이 외에도 이번 업데이트에는 새로운 기능이 하나 추가되었습니다. 이제 데스크톱 환경에서 클릭 대신 마우스를 올리는 것(hover)으로 하위 메뉴가 표시됩니다.

14개의 좋아요

조, 좋은 업데이트네요. 모바일에서는 두 가지 문제만 발생했어요.

  1. 메뉴 항목이 많으면 좌우로 스크롤할 수 없어요.
  2. 드롭다운에서 항목을 탭해도 드롭다운이 계속 열려 있어요.
2개의 좋아요

이것은 여전히 작동해야 하지만, 모바일 뷰에서만 해당됩니다. 따라서 사용자 에이전트를 변경하지 않고 브라우저의 모바일 모사 뷰로만 테스트하면 작동하지 않습니다. 실제 휴대폰에서 테스트하고 있는지 확인해 주시겠습니까? 그렇다면 어떤 기기/브라우저를 사용하고 있는지 알려 주시겠습니까?

저도 같은 현상을 확인했습니다. 그 이유는 드롭다운(열기/닫기) 동작이 이제 JavaScript 대신 CSS로 처리되고 있기 때문입니다. 클릭 후 드롭다운을 자동으로 닫는 동작은 CSS로 처리하는 방법이 없다고 생각합니다. 따라서 해당 문제는 JavaScript로 대체해야 합니다. 모바일 스크롤 문제를 확인해 주신 후에 처리하겠습니다.

2개의 좋아요

이것은 Discourse 앱을 사용하는 iPhone 8에서 발생한 문제이며, Safari에서도 동일합니다. 조, 감사합니다!

2개의 좋아요

조, 이 건에 대해 업데이트가 있나요? 감사합니다!

스펀지 커뮤니티 사이트에서는 상단에 별도의 레이어를 추가하는 대신 메인 헤더에 이 기능을 깔끔하게 통합해 두었습니다:

이것은 어떻게 구현할 수 있을까요? 우리 사이트에도 적용하고 싶습니다.

4개의 좋아요

헤더 링크에 서브메뉴를 추가할 수 있을까요? 이 테마 컴포넌트는 헤더 위에 새로운 메뉴를 추가하지만, 일부 사용자는 새로운 내비게이션 메뉴를 원하지 않습니다. 단순히 현재 헤더 링크에 마우스를 올리면 서브메뉴가 표시되기를 원할 뿐입니다.

5개의 좋아요

정말 멋지네요. 어떻게 한 걸까요?

1개의 좋아요

혹시 이 문제를 겪고 계신 분 계신가요? 소셜 네트워크 아이콘이 작동하지 않아요(이전에는 작동했었거든요). 다른 FA를 사용해도 표시가 안 됩니다.

1개의 좋아요

이것들은 브랜드이므로 이 접두사가 필요합니다. fab 접두사를 사용해 보셨나요?

1개의 좋아요

답변 감사합니다 @davidkingham. fab 접두사를 추가했지만 로고가 표시되지 않습니다.

1개의 좋아요

링크 목록의 아이콘도 잊지 말고 수정하세요. 이 아이콘에는 fab- 접두사가 포함되어야 합니다.

4개의 좋아요

빙고! 그게 맞았어요 :slight_smile: 정말 감사합니다!

2개의 좋아요

안녕하세요, 이유를 모르겠지만 “Menu-item-active-background” 설정이 제대로 작동하지 않는 것 같습니다. 마우스를 올렸을 때 메뉴의 배경색만 바뀌어야 하는데, 선택된 색상이 텍스트를 완전히 가려 버립니다. 여기 확인해 보세요…

또한 그 아래에 있는 “Menu-item-active-color” 설정도 아무런 효과가 없는 것 같습니다. 다양한 색상 코드를 시도해 보았지만 테스트를 해봐도 아무 변화가 없습니다.

혹시 아이디어가 있으신가요?

2개의 좋아요

서브메뉴를 상단 헤더 아래에 배치하고 싶습니다. 어떻게 해야 하는지 알려 주실 수 있을까요? 코드 스니펫이 있다면 큰 도움이 될 것입니다 :pray:

1개의 좋아요

@Johani @davidkingham "드롭다운의 항목을 탭하면 드롭다운이 열린 상태로 유지된다"는 문제에 대해 해결책을 찾았나요?

감사합니다

1개의 좋아요

아니요, 아직 그런 방식으로 작동하고 있습니다. 하나의 가능한 해결책은 모바일에서는 텍스트 없이 아이콘만 표시하는 것입니다. 어떻게 생각하시나요?

1개의 좋아요

모바일에서 아이콘만 표시하는 것이 문제를 어떻게 해결합니까? “드롭다운에서 항목을 탭하면 드롭다운이 계속 열려 있습니다”

1개의 좋아요

@ElForoViajero 데스크톱과 모바일 모두에서 서브메뉴가 잘 작동하는 것 같습니다. 메뉴 항목을 클릭하면 화면이 새로고달리고 메뉴가 자동으로 닫히죠. 특별히 설정한 부분이 있나요?

1개의 좋아요