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 you’re familiar with Bootstrap 3, cards
|
|
|
|
|
;; replace our old panels, wells, and thumbnails. Similar functionality to those
|
|
|
|
|
;; components is available as modifier classes for cards.
|
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defpackage cl-sbt-card
|
|
|
|
|
(:use :cl)
|
|
|
|
|
(:export
|
|
|
|
|
:title
|
|
|
|
|
:subtitle
|
|
|
|
|
:text
|
|
|
|
|
:link
|
|
|
|
|
:header
|
|
|
|
|
:img
|
|
|
|
|
:body
|
|
|
|
|
:card-with-img
|
|
|
|
|
:card))
|
2023-07-07 19:37:58 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(in-package :cl-sbt-card)
|
|
|
|
|
|
|
|
|
|
(defmacro title (&body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card title.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the title."
|
|
|
|
|
|
2023-07-07 20:45:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:h5 :class "card-title" ,@body)))
|
2023-07-07 20:45:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro subtitle (&body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card subtitle.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the subtitle."
|
|
|
|
|
|
2023-07-07 20:45:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:h6 :class "card-subtitle mb-2 text-body-secondary" ,@body)))
|
2023-07-07 20:45:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro text (&body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card text.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the text."
|
|
|
|
|
|
2023-07-07 20:45:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:p :class "card-text" ,@body)))
|
2023-07-07 20:45:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro link ((&key (href "#")) &body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card link.
|
|
|
|
|
|
|
|
|
|
HREF: The URL that the link will point to.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the link."
|
|
|
|
|
|
2023-07-07 20:45:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:a :href ,href :class "card-link" ,@body)))
|
2023-07-07 20:45:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro header (&body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card header.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the header."
|
|
|
|
|
|
2023-07-08 06:59:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:div :class "header" ,@body)))
|
2023-07-08 06:59:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro img ((&key (src "#") (alt "Card Image")))
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card image.
|
|
|
|
|
|
|
|
|
|
SRC: The URL of the image.
|
|
|
|
|
|
|
|
|
|
ALT: The alt text for the image."
|
|
|
|
|
|
2023-07-08 06:59:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:img :src ,src
|
|
|
|
|
:alt ,alt
|
|
|
|
|
:class "card-img-top")))
|
2023-07-08 06:59:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro body (&body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card body.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the body."
|
|
|
|
|
|
2023-07-08 06:59:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:div :class "card-body" ,@body)))
|
2023-07-08 06:59:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro card-with-img ((&key (img-src nil)) &body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card with an image.
|
|
|
|
|
|
|
|
|
|
IMG-SRC: The URL of the image.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the body."
|
|
|
|
|
|
2023-07-07 19:37:58 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:div :class "card"
|
|
|
|
|
,(if (null img-src) nil `(img (:src ,img-src)))
|
|
|
|
|
(:div :class "card-body" ,@body))))
|
2023-07-08 06:59:03 +02:00
|
|
|
|
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(defmacro card (&body body)
|
2023-07-11 19:14:01 +02:00
|
|
|
|
"This macro generates a Bootstrap card.
|
|
|
|
|
|
|
|
|
|
BODY: The contents of the card."
|
|
|
|
|
|
2023-07-08 06:59:03 +02:00
|
|
|
|
`(spinneret:with-html
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(:div :class "card" ,@body)))
|
2023-07-08 06:59:03 +02:00
|
|
|
|
|
|
|
|
|
;; 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 ()
|
2023-07-11 18:48:32 +02:00
|
|
|
|
(card (img (:src "..."))
|
|
|
|
|
(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."))
|
|
|
|
|
(cl-sbt-list-group (:content "An item")
|
|
|
|
|
(:content "A second item")
|
|
|
|
|
(:content "A third item"))
|
|
|
|
|
(body (card-link "Card Link")
|
|
|
|
|
(card-link "Another Link"))))
|