dev.metalisp.sbt/src/component/card.lisp

67 lines
2.3 KiB
Common Lisp
Raw Normal View History

2023-07-07 19:37:58 +02:00
;; https://getbootstrap.com/docs/5.3/components/card/
;; A card is a flexible and extensible content container. It includes options for
;; headers and footers, a wide variety of content, contextual background colors,
;; and powerful display options. If youre familiar with Bootstrap 3, cards
;; replace our old panels, wells, and thumbnails. Similar functionality to those
;; components is available as modifier classes for cards.
(in-package :cl-sbt)
2023-07-07 20:45:03 +02:00
(defmacro card-title (&body body)
2023-07-08 06:59:03 +02:00
"Card titles are used by adding .card-title to a <h*> tag."
2023-07-07 20:45:03 +02:00
`(spinneret:with-html
(:h5 :class "card-title" ,@body)))
(defmacro card-subtitle (&body body)
`(spinneret:with-html
(:h6 :class "card-subtitle mb-2 text-body-secondary" ,@body)))
(defmacro card-text (&body body)
`(spinneret:with-html
(:p :class "card-text" ,@body)))
(defmacro card-link (&body body)
`(spinneret:with-html
(:a :href "#" :class "card-link" ,@body)))
2023-07-08 06:59:03 +02:00
(defmacro card-header (&body body)
`(spinneret:with-html
(:div :class "header" ,@body)))
(defmacro card-img ((&key (src nil) (alt nil)))
".card-img-top places an image to the top of the card."
`(spinneret:with-html
(:img :src ,src
:alt ,alt
:class "card-img-top")))
(defmacro card-body (&body body)
`(spinneret:with-html
(:div :class "card-body" ,@body)))
2023-07-07 20:45:03 +02:00
(defmacro card ((&key (img-src nil)) &body body)
2023-07-07 19:37:58 +02:00
`(spinneret:with-html
(:div :class "card"
2023-07-09 14:20:13 +02:00
,(if (null img-src) nil `(:img :class "card-img-top" :src ,img-src))
2023-07-07 20:45:03 +02:00
(:div :class "card-body" ,@body))))
2023-07-08 06:59:03 +02:00
(defmacro card-* (&body body)
`(spinneret:with-html
(:div :class "card" ,@body)))
;; Kitchen sink
;; Mix and match multiple content types to create the card you need, or throw
;; everything in there. Shown below are image styles, blocks, text styles, and a
;; list group—all wrapped in a fixed-width card.
(defun card-kitchen-sink ()
(card-* (card-img (:src "..."))
(card-body (card-title "Card title")
(card-text "Some quick example text to build on the card title and make up the bulk of the card's content."))
(list-group (:content "An item")
(:content "A second item")
(:content "A third item"))
(card-body (card-link "Card Link")
(card-link "Another Link"))))