Files
rose-ash/sx/sx/layouts/nav-sibling-row.sx
giles 4f02f82f4e HS parser: fix number+comparison keyword collision, eval-hs uses hs-compile
Parser: skip unit suffix when next ident is a comparison keyword
(starts, ends, contains, matches, is, does, in, precedes, follows).
Fixes "123 starts with '12'" returning "123starts" instead of true.

eval-hs: use hs-compile directly instead of hs-to-sx-from-source with
"return " prefix, which was causing the parser to consume the comparison
as a string suffix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 11:29:01 +00:00

57 lines
1.9 KiB
Plaintext

(defcomp
(&key node siblings is-leaf level depth)
:affinity :server
(let*
((sibs (or siblings (list)))
(count (len sibs))
(row-opacity
(if
(and level depth (> depth 0))
(+ (* (/ level depth) 0.75) 0.25)
1)))
(when
(> count 0)
(let*
((idx (find-nav-index sibs node))
(prev-idx (mod (+ (- idx 1) count) count))
(next-idx (mod (+ idx 1) count))
(prev-node (nth sibs prev-idx))
(next-node (nth sibs next-idx)))
(div
(~tw
:tokens "w-full max-w-3xl mx-auto px-4 py-2 grid grid-cols-3 items-center")
:style (str "opacity:" row-opacity ";transition:opacity 0.3s;")
(a
:href (get prev-node "href")
:sx-get (get prev-node "href")
:sx-target "#sx-content"
:sx-select "#sx-content"
:sx-swap "innerHTML"
:sx-push-url "true"
(~tw :tokens "text-right min-w-0 truncate text-stone-500 text-sm")
(str "← " (get prev-node "label")))
(a
:href (get node "href")
:sx-get (get node "href")
:sx-target "#sx-content"
:sx-select "#sx-content"
:sx-swap "innerHTML"
:sx-push-url "true"
(~tw
:tokens (str
"text-center min-w-0 truncate px-1 "
(if
is-leaf
"text-violet-700 text-2xl font-bold"
"text-violet-700 text-lg font-semibold")))
(get node "label"))
(a
:href (get next-node "href")
:sx-get (get next-node "href")
:sx-target "#sx-content"
:sx-select "#sx-content"
:sx-swap "innerHTML"
:sx-push-url "true"
(~tw :tokens "text-left min-w-0 truncate text-stone-500 text-sm")
(str (get next-node "label") " →")))))))