From e8d6aa11984ebe83793568e7b238a32d5f46f89c Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 29 Mar 2026 23:36:01 +0000 Subject: [PATCH] Fix stepper: restore source as string, clean def-store application Previous sed edits corrupted the file. Restored from 5c8b05a and applied only the def-store change cleanly via python (no sed/sx-tools). Co-Authored-By: Claude Opus 4.6 (1M context) --- sx/sx/home-stepper.sx | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/sx/sx/home-stepper.sx b/sx/sx/home-stepper.sx index 8f5fd71d..db1c58fb 100644 --- a/sx/sx/home-stepper.sx +++ b/sx/sx/home-stepper.sx @@ -3,14 +3,8 @@ () (let ((source "(div (~cssx/tw :tokens \"text-center\")\n (h1 (~cssx/tw :tokens \"text-3xl font-bold mb-2\")\n (span (~cssx/tw :tokens \"text-rose-500\") \"the \")\n (span (~cssx/tw :tokens \"text-amber-500\") \"joy \")\n (span (~cssx/tw :tokens \"text-emerald-500\") \"of \")\n (span (~cssx/tw :tokens \"text-violet-600 text-4xl\") \"sx\")))") - (h1 (~cssx/tw :tokens "text-3xl font-bold mb-2") - (span (~cssx/tw :tokens "text-rose-500") "the ") - (span (~cssx/tw :tokens "text-amber-500") "joy ") - (span (~cssx/tw :tokens "text-emerald-500") "of ") - (span (~cssx/tw :tokens "text-violet-600 text-4xl") "sx")))") - (store - (if (client?) (def-store "home-stepper" (fn () {:step-idx (signal 9)})) nil)) (steps (signal (list))) + (store (if (client?) (def-store "home-stepper" (fn () {:step-idx (signal 9)})) nil)) (step-idx (if store (get store "step-idx") (signal 9))) (dom-stack-sig (signal (list))) (code-tokens (signal (list)))) @@ -271,7 +265,17 @@ ((target (- (deref step-idx) 1))) (rebuild-preview target) (reset! step-idx target) - (update-code-highlight)))))) + (update-code-highlight) +))))) + + (let + ((saved (get-cookie "sx-home-stepper"))) + (when + saved + (thaw-from-sx saved) + (when + (or (< (deref step-idx) 0) (> (deref step-idx) 16)) + (reset! step-idx 9)))) (let ((parsed (sx-parse source))) (when @@ -317,7 +321,10 @@ (div :class "flex items-center justify-center gap-2 md:gap-3" (button - :on-click (fn (e) (do-back)) + :on-click (fn + (e) + (do-back) +) :class (str "px-2 py-1 rounded text-3xl " (if @@ -331,7 +338,10 @@ " / " (len (deref steps))) (button - :on-click (fn (e) (do-step)) + :on-click (fn + (e) + (do-step) +) :class (str "px-2 py-1 rounded text-3xl " (if