Simplify with-navbar interface

This commit is contained in:
Marcus Kammer 2024-10-20 08:28:01 +02:00
parent afd66328e4
commit 08d60db002

View file

@ -35,6 +35,8 @@
:con
:row)
(:export
:*brand-name*
:*brand-url*
:with-navbar
:navbar
:brand
@ -224,21 +226,21 @@ Example:
,(getf navitem :name))))))
nil))))))
(defmacro with-navbar ((&key (brand "My Brand") (brand-url "/") active-item) &rest items)
(defparameter *brand-name* "My Brand")
(defparameter *brand-url* "/")
(defmacro with-navbar (container active-item &rest items)
"Creates a Bootstrap navigation bar.
BRAND: The brand name to display (default: \"My Brand\")
BRAND-URL: The URL for the brand link (default: \"/\")
ACTIVE-ITEM: The key of the currently active item
ITEMS: A plist of nav items in the form of :key \"url\" pairs"
`(spinneret:with-html
(:nav :class "navbar navbar-expand-lg bg-body-tertiary mb-5"
:aria-label "Main"
(:div :class "container"
(:a :class "navbar-brand" :href ,brand-url ,brand)
(:div :class ,container
(:a :class "navbar-brand" :href ,*brand-url* ,*brand-name*)
(:button :class "navbar-toggler" :type "button"
:data-bs-toggle "collapse" :data-bs-target "#navbarNav"
:aria-controls "navbarNav" :aria-expanded "false" :aria-label "Toggle navigation"