Merge branch 'main' of git.sr.ht:~marcuskammer/dev.metalisp.sbt

This commit is contained in:
Marcus Kammer 2024-11-06 19:20:59 +01:00
commit eac769dd30
Signed by: marcuskammer
GPG key ID: C374817BE285268F
4 changed files with 44 additions and 11 deletions

View file

@ -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"

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
,@(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)))))))

View file

@ -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.

View file

@ -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))))