diff --git a/src/TopNav.php b/src/TopNav.php index 285fb506..986a18cd 100644 --- a/src/TopNav.php +++ b/src/TopNav.php @@ -2,21 +2,29 @@ namespace App; use Symfony\Contracts\Translation\TranslatorInterface; + +enum TopNavItemType { + case Link; + case Dropdown; + case ThemeToggle; +} + class TopNav { public function __construct(TranslatorInterface $tr) { $this->navbar = [ - [$tr->trans('News'), '/news'], - [$tr->trans('Download'), '/download'], - [$tr->trans('Get Involved'), '/get-involved'], - [[$tr->trans('Documentation'), $tr->trans('Docs')], '/documentation'], - [$tr->trans('Forum'), '/forum'], - [[$tr->trans('Sharing Platform'), $tr->trans('Share')], '/lsp'], + [$tr->trans('News'), '/news', TopNavItemType::Link], + [$tr->trans('Download'), '/download', TopNavItemType::Link], + [$tr->trans('Get Involved'), '/get-involved', TopNavItemType::Link], + [[$tr->trans('Documentation'), $tr->trans('Docs')], '/documentation', TopNavItemType::Link], + [$tr->trans('Forum'), '/forum', TopNavItemType::Link], + [[$tr->trans('Sharing Platform'), $tr->trans('Share')], '/lsp', TopNavItemType::Link], [$tr->trans('More'), null, [ ['fa-eye', $tr->trans('Showcase'), '/showcase'], ['fa-trophy', $tr->trans('Competitions'), '/competitions'], - ['fa-tags', $tr->trans('Branding'), '/branding']]], + ['fa-tags', $tr->trans('Branding'), '/branding']], TopNavItemType::Link], + [$tr->trans('Theme'), null, TopNavItemType::Link] ]; } diff --git a/templates/macros.twig b/templates/macros.twig index 1924f089..2bf8a7c5 100644 --- a/templates/macros.twig +++ b/templates/macros.twig @@ -62,7 +62,7 @@ {% set extension = file_name|split('.')|last %} {{file_name}}
({{macros.get_file_description(extension)|trim}}) -
  +   {% endif %} {% endfor %}




@@ -81,7 +81,7 @@ 'bmp' : 'Bitmap Format'|trans, 'ico' : 'Windows Icon Format'|trans, 'icns': 'Apple Icon Format'|trans, - } + } %} {{descriptions[extension]|default("Unknown File")}} {% endmacro %} @@ -95,7 +95,7 @@ {% endmacro %} -{% macro create_navbar_menu_item(text, url, children = null, rightAlign = false, active = '') %} +{% macro create_navbar_menu_item(text, url = null, children = null, rightAlign = false, active = '') %} {% import _self as macros %} {% if children is null %} {# Simple menu item. If $text is an array, $text[0] is the title displayed @@ -103,6 +103,9 @@ {% if text is iterable %}
  • {{text[0]}}
  • + {# If there is no URL, make a blank list item #} + {% elseif url is null %} +
  • {{text}}
  • {% else %}
  • {{text}}
  • {% endif %} @@ -132,14 +135,14 @@ {% for item in items %} {% if not item[3] is defined %} {% set active = item[1] == current_uri ? 'active' : '' %} - {{macros.create_navbar_menu_item(item[0], item[1], item[2]|default(null), false, active)}} + {{macros.create_navbar_menu_item(item[0], item[1]|default(null), item[2]|default(null), false, active)}} {% endif %} {% endfor %}