|
2 | 2 | (:require
|
3 | 3 | [reagent.core :as r]
|
4 | 4 | [re-frame.core :as rf]
|
5 |
| - |
6 | 5 | [domino.ui.core :as core]
|
7 |
| - [domino.ui.component :refer [component]] |
8 |
| - |
| 6 | + [domino.ui.component :refer [component] :as c] |
9 | 7 | [domino.ui.antd.input]
|
10 | 8 | [domino.ui.antd.button]
|
11 | 9 | [domino.ui.antd.select]))
|
12 | 10 |
|
13 |
| -(defmethod component :label [{:keys [label id]}] |
| 11 | +(defmethod component ::c/label [[_ {:keys [context label id]}]] |
14 | 12 | (fn []
|
15 |
| - [:label label " " @(rf/subscribe [::core/id id])])) |
| 13 | + [:label label " " @(rf/subscribe [::core/subscribe context id])])) |
16 | 14 |
|
17 | 15 | (def schema
|
18 | 16 | {:views
|
19 | 17 | {:default [:div
|
20 | 18 | [:div
|
21 | 19 | [:label "First name"]
|
22 |
| - {:component :input |
23 |
| - :id :first-name}] |
| 20 | + [::c/input {:id :first-name}]] |
24 | 21 | [:div
|
25 | 22 | [:label "Last name"]
|
26 |
| - {:component :input |
27 |
| - :id :last-name}] |
| 23 | + [::c/input {:id :last-name}]] |
28 | 24 |
|
29 |
| - {:label "Last name" |
30 |
| - :component :label |
31 |
| - :id :full-name} |
| 25 | + [::c/label {:label "Full name" |
| 26 | + :id :full-name}] |
32 | 27 |
|
33 |
| - {:component :button |
34 |
| - :id :test-button |
35 |
| - :label "Hello"} |
| 28 | + [:div |
| 29 | + [::c/button |
| 30 | + {:id :test-button |
| 31 | + :label "Hello"}]] |
36 | 32 |
|
37 | 33 | [:div
|
38 | 34 | [:label "Gender"]
|
39 |
| - {:component :select |
40 |
| - :id :gender |
41 |
| - :options [{:id "M" |
42 |
| - :label "Male"} |
43 |
| - {:id "F" |
44 |
| - :label "Female"}] |
45 |
| - :style {:width "200px"}}]]} |
| 35 | + [::c/select |
| 36 | + {:id :gender |
| 37 | + :options [{:id "M" |
| 38 | + :label "Male"} |
| 39 | + {:id "F" |
| 40 | + :label "Female"}] |
| 41 | + :style {:width "200px"}}]]]} |
46 | 42 | :model
|
47 | 43 | [[:demographics
|
48 | 44 | [:first-name {:id :first-name}]
|
|
52 | 48 | :effects
|
53 | 49 | [{:inputs [:first-name]
|
54 | 50 | :handler (fn [_ {:keys [first-name]}]
|
55 |
| - (rf/dispatch [::core/update-component-state |
| 51 | + (rf/dispatch [::core/merge-component-state |
56 | 52 | :last-name
|
57 | 53 | {:disabled? (empty? first-name)}]))}]
|
58 | 54 | :events
|
|
69 | 65 |
|
70 | 66 | (defn home-page []
|
71 | 67 | [:div
|
72 |
| - @(rf/subscribe [::core/view :default]) |
| 68 | + @(rf/subscribe [::core/view :default-ctx :default]) |
73 | 69 | [:hr]
|
74 | 70 | [:label "component states"]
|
75 |
| - [:pre (pprint @(rf/subscribe [::core/components]))] |
| 71 | + [:pre (pprint @(rf/subscribe [::core/component-states :default-ctx]))] |
76 | 72 | [:label "db state"]
|
77 |
| - [:pre (pprint @(rf/subscribe [::core/db]))]]) |
| 73 | + [:pre (pprint @(rf/subscribe [::core/db :default-ctx]))]]) |
78 | 74 |
|
79 | 75 | (defn ^:dev/after-load mount-root []
|
80 |
| - (rf/dispatch-sync [::core/init schema]) |
| 76 | + (rf/dispatch-sync [::core/init-ctx :default-ctx schema {}]) |
81 | 77 | (r/render [home-page] (.getElementById js/document "app")))
|
82 | 78 |
|
83 | 79 | (defn init! []
|
|
0 commit comments