File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed
Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 22 (:require [reagent.core :as r]
33 [reagent.debug :refer-macros [dbg println]]))
44
5- (defn demo-component [{:keys [expected comp src complete no-heading]}]
6- (r/with-let [showing (r/atom false )]
5+ (defn demo-component [{:keys [expected comp src hint complete no-heading]}]
6+ (r/with-let [showing-solution (r/atom false )
7+ showing-hint (r/atom false )]
78 [:div
89 (when expected
910 [:div.demo-example.clearfix
1819 [:h3.demo-heading " Actual output " ])
1920 (if-not complete
2021 [:div.simple-demo [comp]]
21- [comp])])])
22+ [comp])])
23+ (when hint
24+ [:div
25+ [:a.demo-example-hide {:on-click (fn [e]
26+ (.preventDefault e)
27+ (swap! showing-hint not)
28+ nil )}
29+ (if @showing-hint " hide" " show" )]
30+ [:h3.demo-heading " Hint" ]
31+ (when @showing-hint
32+ hint)])])
2233
2334 (if src
2435 [:div.demo-source.clearfix
2536 [:a.demo-example-hide {:on-click (fn [e]
2637 (.preventDefault e)
27- (swap! showing not)
38+ (swap! showing-solution not)
2839 nil )}
29- (if @showing " hide" " show" )]
40+ (if @showing-solution " hide" " show" )]
3041 (when-not no-heading
3142 [:h3.demo-heading " Solution" ])
32- (when @showing src)]
43+ (when @showing-solution src)]
3344 [:div.clearfix ])]))
Original file line number Diff line number Diff line change 132132 and to be fast enough by default that you rarely have to care
133133 about performance." ]
134134
135- [:p " A very basic Reagent component may look something like this: " ]
135+ [:p " Vamos a empezar con un ejemplo de componente Reagent básico: " ]
136136 [demo-component {:expected simple-component
137137 :comp solutions/simple-component
138+ :hint [:div
139+ [:p " Los componentes en reagent usan sintaxis tipo "
140+ [:a {:href " https://github.com/weavejester/hiccup" }
141+ " hiccup" ]
142+ " . Un ejemplo de hiccup: " ]
143+ [:code (s/syntaxed " [:p \" Soy del \" [:span {:style {:color :red}} \" Rojo\" ]]" )]
144+ [:p " Ahora intenta escribir la solución en solutions/simple-component (en el archivo src/reagentdemo/solutions.cljs), de forma tal que se vea como más arriba." ]]
138145 :src (s/src-of [:simple-component ])}]
139146
140147 [:p " You can build new components using other components as
Original file line number Diff line number Diff line change 22 " Solutions for the tutorial examples. Your code goes here." )
33
44(defn simple-component []
5- [:div " Hello! " ])
5+ [:div " Fix me in reagentdemo.solutions/simple-component " ])
You can’t perform that action at this time.
0 commit comments