diff --git a/sx/sx/spreads.sx b/sx/sx/spreads.sx index 33488f1..d0a08fa 100644 --- a/sx/sx/spreads.sx +++ b/sx/sx/spreads.sx @@ -22,12 +22,9 @@ (p "A spread is a value type. " (code "make-spread") " creates one from a dict of " "attributes. When the renderer encounters a spread as a child of an element, " "it merges the attrs onto the parent element instead of appending a DOM node.") - (~docs/code :code "(defcomp ~highlight (&key colour) - (make-spread {\"class\" (str \"highlight-\" colour) - \"data-highlight\" colour}))") + (~docs/code :code (highlight "(defcomp ~highlight (&key colour)\n (make-spread {\"class\" (str \"highlight-\" colour)\n \"data-highlight\" colour}))" "lisp")) (p "Use it as a child of any element:") - (~docs/code :code "(div (~highlight :colour \"yellow\") - \"This div gets class=highlight-yellow\")") + (~docs/code :code (highlight "(div (~highlight :colour \"yellow\")\n \"This div gets class=highlight-yellow\")" "lisp")) (p (code "class") " values are appended (space-joined). " (code "style") " values are appended (semicolon-joined). " "All other attributes overwrite.")) @@ -35,13 +32,7 @@ (~docs/subsection :title "2. collect! / collected / clear-collected!" (p "Render-time accumulators. Values are collected into named buckets " "during rendering and retrieved at flush points. Deduplication is automatic.") - (~docs/code :code ";; Deep inside a component tree: -(collect! \"cssx\" \".sx-bg-red-500{background-color:hsl(0,72%,53%)}\") - -;; At the flush point (once, in the layout): -(let ((rules (collected \"cssx\"))) - (clear-collected! \"cssx\") - (raw! (str \"\")))") + (~docs/code :code (highlight ";; Deep inside a component tree:\n(collect! \"cssx\" \".sx-bg-red-500{background-color:hsl(0,72%,53%)}\")\n\n;; At the flush point (once, in the layout):\n(let ((rules (collected \"cssx\")))\n (clear-collected! \"cssx\")\n (raw! (str \"\")))" "lisp")) (p "This is upward communication through the render tree: " "a deeply nested component contributes a CSS rule, and the layout " "emits all accumulated rules as a single " (code "