Use rest args for hero content

This commit is contained in:
Marcus Kammer 2023-07-20 15:21:45 +02:00
parent 0e6f92e321
commit 162d0f54c6

View file

@ -147,30 +147,41 @@ Example usage:
(:a :href "/docs/5.3/getting-started/introduction/" "getting started guide")) (:a :href "/docs/5.3/getting-started/introduction/" "getting started guide"))
,@body)))) ,@body))))
(defmacro hero (&body body) ;; (defmacro hero ((&key hero-title lead cta-pri cta-sec))
"Generates an HTML 'Hero' section with the provided content. ;; "Generates an HTML 'Hero' section with the provided content.
BODY: Specifies the HTML content to be included in the 'Hero' section. This can ;; BODY: Specifies the HTML content to be included in the 'Hero' section. This can
be any valid HTML content that spinneret:with-html can parse. ;; be any valid HTML content that spinneret:with-html can parse.
The 'Hero' section is a prominent part of the page, usually used to draw ;; The 'Hero' section is a prominent part of the page, usually used to draw
attention to the most important content. The content will be wrapped in a ;; attention to the most important content. The content will be wrapped in a
Bootstrap 'container', and organized in a responsive grid using Bootstrap's ;; Bootstrap 'container', and organized in a responsive grid using Bootstrap's
'row' and 'column' system. ;; 'row' and 'column' system.
Example usage: ;; Example usage:
(hero (:h1 \"Hello, world!\" ;; (hero (:h1 \"Hello, world!\"
:p \"This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.\") ;; :p \"This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.\")
(:hr) ;; (:hr)
(:p \"It uses utility classes for typography and spacing to space content out within the larger container.\")) ;; (:p \"It uses utility classes for typography and spacing to space content out within the larger container.\"))
; This will generate a 'Hero' section with the provided headline, text, and ;; ; This will generate a 'Hero' section with the provided headline, text, and
; horizontal line." ;; ; horizontal line."
;; `(spinneret:with-html
;; (con (:spacing (:property :p :size 5))
;; (row (:spacing (:property :p :side :lg :size 5))
;; (col (:breakpoint (:kind :col :md (8 nil) :lg (6 nil))
;; :spacing (:property :p :size 5))
;; (:h1 :class "fw-light" ,hero-title)
;; (lead-p () ,lead)
;; (:p (btn-primary ,cta-pri)
;; (btn-secondary ,cta-sec)))))))
(defmacro hero (&rest rest)
`(spinneret:with-html `(spinneret:with-html
(con (:spacing (:property :p :size 5)) ,@(destructuring-bind (&key title lead cta) rest
(row (:spacing (:property :p :side :lg :size 5)) `(progn
(col (:breakpoint (:kind :col :md (8 nil) :lg (6 nil)) (:h1 :class "fw-light" ,title)
:spacing (:property :p :size 5)) (lead-p () ,lead)
,@body))))) (:p (btn-primary ,cta))))))
(defmacro lead-p ((&key (color '(:text "body-secondary"))) &body body) (defmacro lead-p ((&key (color '(:text "body-secondary"))) &body body)
`(spinneret:with-html `(spinneret:with-html
@ -183,14 +194,16 @@ Example usage:
(col (:breakpoint (:kind :col :sm (8 nil) :md (7 nil)) (col (:breakpoint (:kind :col :sm (8 nil) :md (7 nil))
:spacing (:property :p :side :y :size 4)) :spacing (:property :p :side :y :size 4))
(about () "Add some information about the album below, the author, or any other background context. Make it a few sentences long so folks can pick up some informative tidbits. Then, link them off to some social networking sites or contact information.")) (about () "Add some information about the album below, the author, or any other background context. Make it a few sentences long so folks can pick up some informative tidbits. Then, link them off to some social networking sites or contact information."))
(col (:breakpoint (:kind :col :sm (4 nil) :md (nil 1))) (col (:breakpoint (:kind :col :sm (4 nil) :md (nil 1)))
(contact (:url "#" :label "Follow on Twitter") (contact (:url "#" :label "Follow on Twitter")
(:url "#" :label "Like on Facebook") (:url "#" :label "Like on Facebook")
(:url "#" :label "Email me")))) (:url "#" :label "Email me"))))
(:main (hero (:h1 :class "fw-light")
(lead-p () "Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks dont simply skip over it entirely.") (hero :title "Album example"
(:p (cl-sbt/btn:btn-primary "Main call to action") :lead "Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks dont simply skip over it entirely."
(cl-sbt/btn:btn-secondary "Secondary action")))) :cta "Main call to action")
(footer ()))) (footer ())))
(defun write-page (filepath &key (lang "de") (style :tree) (fc 120)) (defun write-page (filepath &key (lang "de") (style :tree) (fc 120))