Use a macro to generate simple button macros
This commit is contained in:
parent
4c21a5049c
commit
b70ebfde1b
1 changed files with 59 additions and 42 deletions
|
@ -1,66 +1,83 @@
|
||||||
|
;; https://getbootstrap.com/docs/5.3/components/buttons/
|
||||||
|
|
||||||
|
;; Use Bootstrap’s custom button styles for actions in forms, dialogs, and more
|
||||||
|
;; with support for multiple sizes, states, and more.
|
||||||
|
|
||||||
|
;; Bootstrap has a base .btn class that sets up basic styles such as padding and
|
||||||
|
;; content alignment. By default, .btn controls have a transparent border and
|
||||||
|
;; background color, and lack any explicit focus and hover styles.
|
||||||
|
|
||||||
(in-package :cl-sbt)
|
(in-package :cl-sbt)
|
||||||
|
|
||||||
(defmacro btn ((&key (type nil) (size nil)) &body body)
|
(defmacro btn ((&key (type nil) (size nil)) &body body)
|
||||||
"https://getbootstrap.com/docs/5.3/components/buttons/
|
|
||||||
Use Bootstrap’s custom button styles for actions in forms, dialogs,
|
|
||||||
and more with support for multiple sizes, states, and more."
|
|
||||||
`(spinneret:with-html
|
`(spinneret:with-html
|
||||||
(:button :type "button"
|
(:button :type "button"
|
||||||
:class (concatenate 'string "btn"
|
:class (string-downcase (concatenate 'string
|
||||||
(if ,type (format nil " btn-~a" ,type))
|
"btn"
|
||||||
(if ,size (format nil " btn-~a" ,size)))
|
(if (null ,type) nil (format nil " btn-~a" ,type))
|
||||||
|
(if (null ,size) nil (format nil " btn-~a" ,size))))
|
||||||
,@body)))
|
,@body)))
|
||||||
|
|
||||||
(defmacro btn-primary (&body body)
|
(defmacro define-btns (names)
|
||||||
`(btn (:type "primary") ,@body))
|
`(progn
|
||||||
|
,@(loop for item in names
|
||||||
|
for symbol = (intern (concatenate 'string "BTN-" (symbol-name item)))
|
||||||
|
for item-name = (format nil "~a" item)
|
||||||
|
collect `(defmacro ,symbol (&body body)
|
||||||
|
`(btn (:type ,(string ',item-name)) ,@body)))))
|
||||||
|
|
||||||
(defmacro btn-secondary (&body body)
|
(define-btns (primary secondary success danger warning info light dark link))
|
||||||
`(btn (:type "secondary") ,@body))
|
|
||||||
|
|
||||||
(defmacro btn-success (&body body)
|
;; (defmacro btn-primary-lg (&body body)
|
||||||
`(btn (:type "success") ,@body))
|
;; `(btn (:type "primary" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-danger (&body body)
|
;; (defmacro btn-secondary-lg (&body body)
|
||||||
`(btn (:type "danger") ,@body))
|
;; `(btn (:type "secondary" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-warning (&body body)
|
;; (defmacro btn-success-lg (&body body)
|
||||||
`(btn (:type "warning") ,@body))
|
;; `(btn (:type "success" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-info (&body body)
|
;; (defmacro btn-danger-lg (&body body)
|
||||||
`(btn (:type "info") ,@body))
|
;; `(btn (:type "danger" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-light (&body body)
|
;; (defmacro btn-warning-lg (&body body)
|
||||||
`(btn (:type "light") ,@body))
|
;; `(btn (:type "warning" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-dark (&body body)
|
;; (defmacro btn-info-lg (&body body)
|
||||||
`(btn (:type "dark") ,@body))
|
;; `(btn (:type "info" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-link (&body body)
|
;; (defmacro btn-light-lg (&body body)
|
||||||
`(btn (:type "link") ,@body))
|
;; `(btn (:type "light" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-primary (&body body)
|
;; (defmacro btn-dark-lg (&body body)
|
||||||
`(btn (:type "outline-primary") ,@body))
|
;; `(btn (:type "dark" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-secondary (&body body)
|
;; (defmacro btn-link-lg (&body body)
|
||||||
`(btn (:type "outline-secondary") ,@body))
|
;; `(btn (:type "link" :size "lg") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-success (&body body)
|
;; (defmacro btn-outline-primary (&body body)
|
||||||
`(btn (:type "outline-success") ,@body))
|
;; `(btn (:type "outline-primary") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-danger (&body body)
|
;; (defmacro btn-outline-secondary (&body body)
|
||||||
`(btn (:type "outline-danger") ,@body))
|
;; `(btn (:type "outline-secondary") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-warning (&body body)
|
;; (defmacro btn-outline-success (&body body)
|
||||||
`(btn (:type "outline-warning") ,@body))
|
;; `(btn (:type "outline-success") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-info (&body body)
|
;; (defmacro btn-outline-danger (&body body)
|
||||||
`(btn (:type "outline-info") ,@body))
|
;; `(btn (:type "outline-danger") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-light (&body body)
|
;; (defmacro btn-outline-warning (&body body)
|
||||||
`(btn (:type "outline-light") ,@body))
|
;; `(btn (:type "outline-warning") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-dark (&body body)
|
;; (defmacro btn-outline-info (&body body)
|
||||||
`(btn (:type "outline-dark") ,@body))
|
;; `(btn (:type "outline-info") ,@body))
|
||||||
|
|
||||||
(defmacro btn-outline-link (&body body)
|
;; (defmacro btn-outline-light (&body body)
|
||||||
`(btn (:type "outline-link") ,@body))
|
;; `(btn (:type "outline-light") ,@body))
|
||||||
|
|
||||||
|
;; (defmacro btn-outline-dark (&body body)
|
||||||
|
;; `(btn (:type "outline-dark") ,@body))
|
||||||
|
|
||||||
|
;; (defmacro btn-outline-link (&body body)
|
||||||
|
;; `(btn (:type "outline-link") ,@body))
|
||||||
|
|
Loading…
Add table
Reference in a new issue