Add with-card* alternative

This commit is contained in:
Marcus Kammer 2024-11-04 17:29:50 +01:00
parent b1a478d3c1
commit 0d352e816c

View file

@ -44,7 +44,8 @@
:card-with-img
:card
:card-group
:with-card)
:with-card
:with-card*)
(:documentation "A Common Lisp package for generating Bootstrap Card components."))
(in-package :ml-sbt/card)
@ -184,3 +185,29 @@ Example:
`((with-list-group ,items t)))
(:div :class "card-body"
,@body)))))
(defmacro with-card* (&body body)
"Creates a Bootstrap card with a header, optional list items, and additional content.
Example:
(with-card* :col \"col-lg-12\"
:card-image (\"foo.png\" . \"foo image\")
:card-header \"Foo\"
:card-items '(\"foo\" \"bar\")
:card-body \"body\")"
(destructuring-bind (&key col card-image card-header card-items card-body) body
(let ((col-class (if col col "col"))
(sizing-class "card h-100"))
`(spinneret:with-html
(:div :class ,col-class
(:div :class ,sizing-class
,@(when card-image
`((:img :class "card-img-top"
:src ,(car card-image)
:alt ,(cdr card-image))))
,@(when card-header
`((:h5 :class "card-header" ,card-header)))
,@(when card-items
`((with-list-group ,card-items t)))
(:div :class "card-body"
,card-body)))))))