diff --git a/src/accordion.lisp b/src/accordion.lisp index d062c43..71ea4d4 100644 --- a/src/accordion.lisp +++ b/src/accordion.lisp @@ -25,7 +25,7 @@ the accordion item. Example usage: (accordion () \"Title 1\" \"Content 1\" \"Title 2\" \"Content 2\")" - (let ((class (if flush "accordion accordion-flush" "accordion"))) + (let ((class (concatenate 'string "shadow " (if flush "accordion accordion-flush" "accordion")))) `(spinneret:with-html (:div :class ,class :id ,id @@ -35,7 +35,7 @@ Example usage: for collapse-class = (concatenate 'string "accordion-collapse collapse" (when (= counter 1) " show")) for btn-class = (concatenate 'string "accordion-button" (when (not (= counter 1)) " collapsed")) collect `(:div :class "accordion-item" - (:h2 :class "accordion-header" + (:div :class "accordion-header" (:button :class ,btn-class :type "button" :data-bs-toggle "collapse" diff --git a/src/card.lisp b/src/card.lisp index b69e66b..b9e04cc 100644 --- a/src/card.lisp +++ b/src/card.lisp @@ -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 + ,@(if card-image + `((:img :class "card-img-top" + :src ,(car card-image) + :alt ,(cdr card-image)))) + ,@(if card-header + `((:h5 :class "card-header" ,card-header))) + ,@(if card-items + `((with-list-group ,card-items t))) + (:div :class "card-body" + ,card-body))))))) diff --git a/src/section.lisp b/src/section.lisp index 9a7fdd8..8c39f4f 100644 --- a/src/section.lisp +++ b/src/section.lisp @@ -2,6 +2,9 @@ (defpackage ml-sbt/section (:use :cl) + (:import-from #:ml-sbt/utility + #:make-col-class + #:combine-classes) (:import-from #:ml-sbt/btn #:btn-group-outline-primary) (:export @@ -14,13 +17,6 @@ (in-package :ml-sbt/section) -(defun make-col-class (breakpoint value) - (when value - (format nil "col~@[-~(~a~)~]~@[-~a~]" breakpoint value))) - -(defun combine-classes (&rest class-specs) - (string-trim " " (format nil "~{~a ~}" (remove nil class-specs)))) - (defmacro with-title-bar (head &rest items) "Creates a Bootstrap-styled title bar with an optional set of action buttons. diff --git a/src/utility.lisp b/src/utility.lisp index 411d365..155f22f 100644 --- a/src/utility.lisp +++ b/src/utility.lisp @@ -51,7 +51,9 @@ :sizing :spacing :text - :valign) + :valign + :make-col-class + :combine-classes) (:documentation "A module for generating Bootstrap utility classes.")) (in-package :ml-sbt/utility) @@ -553,3 +555,11 @@ Example 3: ; This will generate a string 'align-middle'" (let ((align-str (if (null align) "" (format nil "align-~a" align)))) (string-clean align-str))) + + +(defun make-col-class (breakpoint value) + (when value + (format nil "col~@[-~(~a~)~]~@[-~a~]" breakpoint value))) + +(defun combine-classes (&rest class-specs) + (string-trim " " (format nil "~{~a ~}" (remove nil class-specs))))