2023-07-08 14:32:59 +02:00
|
|
|
;; https://getbootstrap.com/docs/5.3/components/accordion/
|
|
|
|
|
2023-07-01 16:30:10 +02:00
|
|
|
(in-package :cl-sbt)
|
|
|
|
|
2023-07-08 22:09:06 +02:00
|
|
|
(defmacro accordion-header (target name show)
|
2023-07-08 12:49:10 +02:00
|
|
|
`(spinneret:with-html
|
2023-07-08 14:31:53 +02:00
|
|
|
(:h2 :class "accordion-header"
|
|
|
|
(:button :class "accordion-button"
|
|
|
|
:type "button"
|
|
|
|
:data-bs-toggle "collapse"
|
|
|
|
:data-bs-target (format nil "#~a" ,target)
|
2023-07-09 14:00:49 +02:00
|
|
|
:aria-expanded ,(if (null show) "false" "true")
|
2023-07-08 22:09:06 +02:00
|
|
|
:aria-controls (format nil "#~a" ,target)
|
2023-07-08 17:10:57 +02:00
|
|
|
,name))))
|
2023-07-08 12:49:10 +02:00
|
|
|
|
2023-07-08 22:09:06 +02:00
|
|
|
(defmacro accordion-collapse (parent id show &body body)
|
|
|
|
`(spinneret:with-html
|
|
|
|
(:div :id ,id
|
2023-07-09 14:00:49 +02:00
|
|
|
:class ,(concatenate 'string "accordion-collapse collapse" (if (null show) nil " show"))
|
2023-07-08 22:09:06 +02:00
|
|
|
:data-bs-parent (format nil "#~a" ,parent)
|
|
|
|
(:div :class "accordion-body"
|
|
|
|
,@body))))
|
|
|
|
|
2023-07-08 12:49:10 +02:00
|
|
|
(defmacro accordion-item (&body body)
|
2023-07-08 14:31:53 +02:00
|
|
|
`(spinneret:with-html
|
|
|
|
(:div :class "accordion-item"
|
|
|
|
,@body)))
|
2023-07-01 16:30:10 +02:00
|
|
|
|
2023-07-08 14:31:53 +02:00
|
|
|
(defmacro accordion ((&key (id "accordionExample")) &rest rest)
|
|
|
|
`(spinneret:with-html
|
|
|
|
(:div :class "accordion"
|
|
|
|
:id ,id
|
|
|
|
,@(loop for item in rest
|
2023-07-08 22:09:06 +02:00
|
|
|
collect (destructuring-bind (&key target name show content) item
|
|
|
|
`(accordion-item (accordion-header ,target ,name ,show)
|
|
|
|
(accordion-collapse ,id ,target ,show ,content)))))))
|
|
|
|
|
|
|
|
(defun show-accordion-example ()
|
|
|
|
"Show an generated accordion example"
|
|
|
|
(accordion (:id "accordionExample")
|
|
|
|
(:target "collapseOne" :name "Accordion Item #1" :show t :content "This is the first item's accordion body.")
|
|
|
|
(:target "collapseTwo" :name "Accordion Item #2" :content "This is the second item's accordion body.")
|
|
|
|
(:target "collapseThree" :name "Accordion Item #3" :content "This is the second item's accordion body.")))
|