|
1 | 1 | #lang racket/base |
2 | 2 |
|
3 | | -(require pollen/decode pollen/tag txexpr) |
| 3 | +(require pollen/decode pollen/tag txexpr racket/string) |
4 | 4 | (provide (all-defined-out)) |
5 | 5 |
|
6 | 6 | (module setup racket/base |
|
52 | 52 | (iframe ((src ,src) |
53 | 53 | (title "Brickell Research status dashboard") |
54 | 54 | (loading "lazy"))))) |
| 55 | + |
| 56 | +;; -------- Notebook tags -------- |
| 57 | + |
| 58 | +;; Right-margin aside (becomes inline callout on narrow screens) |
| 59 | +(define (aside . body) |
| 60 | + `(aside ,@body)) |
| 61 | + |
| 62 | +;; Aside with vertical alignment to a nearby paragraph: ◊aside-up[2]{...} |
| 63 | +(define (aside-up n . body) |
| 64 | + `(aside ((class "move-up") (style ,(format "--move-up: ~a" n))) ,@body)) |
| 65 | + |
| 66 | +;; Figure — clean cyan-framed media. Use for diagrams, screenshots, charts. |
| 67 | +(define (figure src . caption) |
| 68 | + `(figure (img ((src ,src) (alt ""))) |
| 69 | + (figcaption ,@caption))) |
| 70 | + |
| 71 | +;; Sketch — "photo of paper" variant with offset pink-tinted shadow. |
| 72 | +(define (sketch src . caption) |
| 73 | + `(figure ((class "sketch")) |
| 74 | + (img ((src ,src) (alt ""))) |
| 75 | + (figcaption ,@caption))) |
| 76 | + |
| 77 | +;; Video demo — autoplays muted, loops, playsinline. Use for screen recordings. |
| 78 | +(define (video src) |
| 79 | + `(figure (video ((src ,src) (controls "") (playsinline "") |
| 80 | + (preload "metadata") (muted "") (loop ""))))) |
| 81 | + |
| 82 | +;; Per-note byline + backlink, dropped at the top of every entry. |
| 83 | +(define (note-meta date) |
| 84 | + `(p ((class "note-meta")) |
| 85 | + (time ((datetime ,date)) ,date) |
| 86 | + " · " |
| 87 | + (a ((href "/notes")) "← all notes"))) |
| 88 | + |
| 89 | +;; A single entry in a dated note list — used on both /notes and the home page. |
| 90 | +(define (note date href . title) |
| 91 | + `(li ((class "note-item")) |
| 92 | + (time ((datetime ,date)) ,date) |
| 93 | + (a ((href ,href)) ,@title))) |
| 94 | + |
| 95 | +;; Container for a list of notes. |
| 96 | +(define (note-list . items) |
| 97 | + `(ul ((class "note-index")) ,@items)) |
| 98 | + |
| 99 | +;; Inline code — for tag names, types, identifiers in prose. |
| 100 | +(define (code . body) |
| 101 | + `(code ,@body)) |
| 102 | + |
| 103 | +;; Code block — preserves whitespace and indentation literally. |
| 104 | +;; CONVENTION: write the body with leading + trailing newlines, like: |
| 105 | +;; ◊code-block{ |
| 106 | +;; first line of code |
| 107 | +;; indented line |
| 108 | +;; } |
| 109 | +;; This bypasses Scribble's leading-line dedent (which strips a variable |
| 110 | +;; amount based on the first content line's shape). The function trims the |
| 111 | +;; sentinel newlines back off. |
| 112 | +(define (code-block . body) |
| 113 | + (let* ([raw (apply string-append |
| 114 | + (map (lambda (x) (if (string? x) x "")) body))] |
| 115 | + [trimmed (string-trim raw "\n" #:repeat? #t)]) |
| 116 | + `(pre ((class "code-block")) (code ,trimmed)))) |
0 commit comments