me
/
guix
Archived
1
0
Fork 0

doc: Make the HTML language menu disappear on narrow screens.

* doc/build.scm (stylized-html)[build](navigation-bar): New procedure.
(stylized-html): Use it.
Ludovic Courtès 2022-01-19 15:41:59 +01:00
parent 2c9787086a
commit fa580bf3b4
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 30 additions and 9 deletions

View File

@ -650,6 +650,23 @@ in SOURCE."
(href ,url)) (href ,url))
,label))) ,label)))
(define* (navigation-bar menus #:key split-node?)
;; Return the navigation bar showing all of MENUS.
`(header (@ (class "navbar"))
(h1 (a (@ (class "branding")
(href ,(if split-node? ".." "#")))))
(nav (@ (class "navbar-menu"))
(input (@ (class "navbar-menu-hidden-input")
(type "radio")
(name "dropdown")
(id "all-dropdowns-hidden")))
(ul ,@menus))
;; This is the button that shows up on small screen in
;; lieu of the drop-down button.
(a (@ (class "navbar-menu-btn")
(href ,(if split-node? "../.." ".."))))))
(define* (base-language-url code manual (define* (base-language-url code manual
#:key split-node?) #:key split-node?)
;; Return the base URL of MANUAL for language CODE. ;; Return the base URL of MANUAL for language CODE.
@ -682,6 +699,9 @@ in SOURCE."
(define (stylized-html sxml file) (define (stylized-html sxml file)
;; Return SXML, which was read from FILE, with additional ;; Return SXML, which was read from FILE, with additional
;; styling. ;; styling.
(define split-node?
(string-contains file "/html_node/"))
(let loop ((sxml sxml)) (let loop ((sxml sxml))
(match sxml (match sxml
(('*TOP* decl body ...) (('*TOP* decl body ...)
@ -695,15 +715,16 @@ in SOURCE."
(href #$manual-css-url))))) (href #$manual-css-url)))))
(('body ('@ attributes ...) elements ...) (('body ('@ attributes ...) elements ...)
`(body (@ ,@attributes) `(body (@ ,@attributes)
(nav (@ (class "navbar-menu")) ,(navigation-bar
(ul ;; TODO: Add "Contribute" menu, to report
;; TODO: Add "Contribute" menu, to report ;; errors, etc.
;; errors, etc. (list (menu-dropdown
,(menu-dropdown #:label #:label
`(img (@ (alt "Language") `(img (@ (alt "Language")
(src "/static/base/img/language-picker.svg"))) (src "/static/base/img/language-picker.svg")))
#:items #:items
(language-menu-items file)))) (language-menu-items file)))
#:split-node? split-node?)
,@elements)) ,@elements))
((tag ('@ attributes ...) body ...) ((tag ('@ attributes ...) body ...)
`(,tag (@ ,@attributes) ,@(map loop body))) `(,tag (@ ,@attributes) ,@(map loop body)))