Fix container class handling

This commit is contained in:
Marcus Kammer 2024-08-03 10:09:20 +02:00
parent 3adf1c26e6
commit 40f94662e6
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -130,8 +130,6 @@ META: The meta-information for the web page.
TITLE: Specifies the title of the web page. Defaults to 'Web page'. TITLE: Specifies the title of the web page. Defaults to 'Web page'.
MAIN-CON: If t add css class `container` to <main>.
ADD-CSS-URLS: An optional parameter for additional CSS file URLs. ADD-CSS-URLS: An optional parameter for additional CSS file URLs.
ADD-JS-URLS: An optional parameter for additional JavaScript file URLs. ADD-JS-URLS: An optional parameter for additional JavaScript file URLs.
@ -169,22 +167,27 @@ Example usage:
,@(loop for url in add-js-urls ,@(loop for url in add-js-urls
collect `(:script :src ,url))))) collect `(:script :src ,url)))))
(defmacro body-header (main-heading &body body) (defmacro body-header (container main-heading &body body)
`(spinneret:with-html (let ((class (cond ((eq container t) "container")
(:header :class "mb-3" ((stringp container) (format nil "container-~a" container))
(:div :class "skippy visually-hidden-focusable overflow-hidden" (t ""))))
(:a :href "#main-content" `(spinneret:with-html
:class "d-inline-flex p-2 m-1" (:header :class "mb-3"
(find-l10n "skip-link" *html-lang* *l10n*))) (:div :class "skippy visually-hidden-focusable overflow-hidden"
,@body (:a :href "#main-content"
(:div :class "container" :class "d-inline-flex p-2 m-1"
(:h1 ,main-heading))))) (find-l10n "skip-link" *html-lang* *l10n*)))
,@body
(:div ,@(when (not (string= class "")) `(:class ,class))
(:h1 ,main-heading))))))
(defmacro body-main (&optional main-con &body body) (defmacro body-main (container &body body)
(let ((class-str (concatenate 'string "" (when main-con " container")))) (let ((class (cond ((eq container t) "container")
((stringp container) (format nil "container-~a" container))
(t ""))))
`(spinneret:with-html `(spinneret:with-html
(:main :id "main-content" (:main :id "main-content"
:class ,class-str ,@(when (not (string= class "")) `(:class ,class))
,@body)))) ,@body))))
(defun remove-special-chars (str) (defun remove-special-chars (str)