From eb3035ba60222322aaffc12fe15e2cfd0d928894 Mon Sep 17 00:00:00 2001 From: "Paul B." Date: Mon, 25 Mar 2024 12:15:47 +0100 Subject: [PATCH] nav: set the active item on the top navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the three collections “help”, “guides” and “product-updates” this commit adds a CSS property `active` on the active category in the top navigation bar. Visually I've simply added an underlined text decoration (but fill free to suggest something else). Part of #193 --- src/_components/shared/nav/item.css | 4 ++++ src/_components/shared/nav/item.erb | 2 +- src/_components/shared/nav/item.rb | 4 ++-- src/_components/shared/navbar.erb | 2 +- src/_components/shared/navbar.rb | 8 +++++++- src/_data/navbar.yml | 6 +++--- src/_layouts/default.erb | 7 +++++-- src/_pages/guides.md | 2 ++ 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/_components/shared/nav/item.css b/src/_components/shared/nav/item.css index 926d62e5..2d958797 100644 --- a/src/_components/shared/nav/item.css +++ b/src/_components/shared/nav/item.css @@ -1,3 +1,7 @@ +nav-item.active { + text-decoration: underline; +} + nav-item :is(a, a:visited, a:focus) { border-radius: var(--border-radius-medium); color: var(--text-color); diff --git a/src/_components/shared/nav/item.erb b/src/_components/shared/nav/item.erb index 53458d8d..d5aeb58c 100644 --- a/src/_components/shared/nav/item.erb +++ b/src/_components/shared/nav/item.erb @@ -1,3 +1,3 @@ - + class="active"<% end %>> <%= @title %> diff --git a/src/_components/shared/nav/item.rb b/src/_components/shared/nav/item.rb index a5ab892b..d88733d4 100644 --- a/src/_components/shared/nav/item.rb +++ b/src/_components/shared/nav/item.rb @@ -1,5 +1,5 @@ class Shared::Nav::Item < Bridgetown::Component - def initialize(title:, link:) - @title, @link = title, link + def initialize(title:, link:, active: false) + @title, @link, @active = title, link, active end end diff --git a/src/_components/shared/navbar.erb b/src/_components/shared/navbar.erb index cb0b3b2a..5fed3bcb 100644 --- a/src/_components/shared/navbar.erb +++ b/src/_components/shared/navbar.erb @@ -7,7 +7,7 @@