From cb89d42813f391eafdf66ae2c3afc7378e7371b8 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 16 Aug 2023 21:17:18 +0200 Subject: [PATCH] Put IDs directly on nav entries --- app/helpers/bootstrap_helper.rb | 3 ++- app/views/navigation/_desktop.html.haml | 5 ++--- app/views/navigation/_mobile.html.haml | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/helpers/bootstrap_helper.rb b/app/helpers/bootstrap_helper.rb index 4d14e3dc..55544265 100644 --- a/app/helpers/bootstrap_helper.rb +++ b/app/helpers/bootstrap_helper.rb @@ -8,6 +8,7 @@ module BootstrapHelper badge_attr: {}, icon: nil, class: "", + id: nil, hotkey: nil, }.merge(options) @@ -34,7 +35,7 @@ module BootstrapHelper body += " #{content_tag(:span, options[:badge], class: badge_class, **options[:badge_attr])}".html_safe end - content_tag(:li, link_to(body.html_safe, path, class: "nav-link", data: { hotkey: options[:hotkey] }), class: classes) + content_tag(:li, link_to(body.html_safe, path, class: "nav-link", data: { hotkey: options[:hotkey] }), class: classes, id: options[:id]) end def list_group_item(body, path, options = {}) diff --git a/app/views/navigation/_desktop.html.haml b/app/views/navigation/_desktop.html.haml index 167ff830..8efb1151 100644 --- a/app/views/navigation/_desktop.html.haml +++ b/app/views/navigation/_desktop.html.haml @@ -1,4 +1,4 @@ -%nav.navbar.navbar-themed.navbar-expand-lg.bg-primary.fixed-top.d-lg-block.d-none.d-print-none{ class: Rails.env.development? ? "navbar-dev" : "", role: :navigation } +%nav.navbar.navbar-themed.navbar-expand-lg.bg-primary.fixed-top.d-lg-block.d-none.d-print-none{ class: Rails.env.tdevelopment? ? "navbar-dev" : "", role: :navigation } .container %a.navbar-brand{ href: '/', title: APP_CONFIG["site_name"] } - if APP_CONFIG["use_svg_logo"] @@ -10,8 +10,7 @@ DEV %ul.nav.navbar-nav.me-auto = nav_entry t("navigation.timeline"), root_path, icon: "home", hotkey: "g t" - #nav-inbox-desktop - = nav_entry t("navigation.inbox"), "/inbox", icon: "inbox", badge: inbox_count, badge_attr: { data: { controller: "pwa-badge" } }, hotkey: "g i" + = nav_entry t("navigation.inbox"), "/inbox", icon: "inbox", badge: inbox_count, badge_attr: { data: { controller: "pwa-badge" } }, hotkey: "g i", id: "nav-inbox-desktop" - if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? = nav_entry t("navigation.discover"), discover_path, icon: "compass", hotkey: "g d" %ul.nav.navbar-nav diff --git a/app/views/navigation/_mobile.html.haml b/app/views/navigation/_mobile.html.haml index 9c53586d..2b68f081 100644 --- a/app/views/navigation/_mobile.html.haml +++ b/app/views/navigation/_mobile.html.haml @@ -3,10 +3,9 @@ .container %ul.nav.navbar-nav.navbar-icon-row = nav_entry t("navigation.timeline"), root_path, icon: 'home', icon_only: true - #nav-inbox-mobile - = nav_entry t("navigation.inbox"), '/inbox', - badge: inbox_count, badge_color: 'primary', badge_pill: true, - icon: 'inbox', icon_only: true + = nav_entry t("navigation.inbox"), '/inbox', + badge: inbox_count, badge_color: 'primary', badge_pill: true, + icon: 'inbox', icon_only: true, id: "nav-inbox-mobile" - if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? = nav_entry t("navigation.discover"), discover_path, icon: 'compass', icon_only: true = nav_entry t("navigation.notifications"), notifications_path("all"), icon: notifications_icon,