File tree 3 files changed +26
-8
lines changed
3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 2
2
(:require [reagent.core :as r]
3
3
[reagent.debug :refer-macros [dbg println]]))
4
4
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 )]
7
8
[:div
8
9
(when expected
9
10
[:div.demo-example.clearfix
18
19
[:h3.demo-heading " Actual output " ])
19
20
(if-not complete
20
21
[: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)])])
22
33
23
34
(if src
24
35
[:div.demo-source.clearfix
25
36
[:a.demo-example-hide {:on-click (fn [e]
26
37
(.preventDefault e)
27
- (swap! showing not)
38
+ (swap! showing-solution not)
28
39
nil )}
29
- (if @showing " hide" " show" )]
40
+ (if @showing-solution " hide" " show" )]
30
41
(when-not no-heading
31
42
[:h3.demo-heading " Solution" ])
32
- (when @showing src)]
43
+ (when @showing-solution src)]
33
44
[:div.clearfix ])]))
Original file line number Diff line number Diff line change 132
132
and to be fast enough by default that you rarely have to care
133
133
about performance." ]
134
134
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: " ]
136
136
[demo-component {:expected simple-component
137
137
: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." ]]
138
145
:src (s/src-of [:simple-component ])}]
139
146
140
147
[:p " You can build new components using other components as
Original file line number Diff line number Diff line change 2
2
" Solutions for the tutorial examples. Your code goes here." )
3
3
4
4
(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