Skip to content

Commit 077060f

Browse files
committed
updated to use domino-ui 0.1.2 API
1 parent d6987db commit 077060f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+283
-277
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
```
66
npm install
7-
shadow-cljs watch test-page
7+
npx shadow-cljs watch test-page
88
```
99

1010
## Building

dev/domino/ui/antd/test_page.cljs

+23-27
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,43 @@
22
(:require
33
[reagent.core :as r]
44
[re-frame.core :as rf]
5-
65
[domino.ui.core :as core]
7-
[domino.ui.component :refer [component]]
8-
6+
[domino.ui.component :refer [component] :as c]
97
[domino.ui.antd.input]
108
[domino.ui.antd.button]
119
[domino.ui.antd.select]))
1210

13-
(defmethod component :label [{:keys [label id]}]
11+
(defmethod component ::c/label [[_ {:keys [context label id]}]]
1412
(fn []
15-
[:label label " " @(rf/subscribe [::core/id id])]))
13+
[:label label " " @(rf/subscribe [::core/subscribe context id])]))
1614

1715
(def schema
1816
{:views
1917
{:default [:div
2018
[:div
2119
[:label "First name"]
22-
{:component :input
23-
:id :first-name}]
20+
[::c/input {:id :first-name}]]
2421
[:div
2522
[:label "Last name"]
26-
{:component :input
27-
:id :last-name}]
23+
[::c/input {:id :last-name}]]
2824

29-
{:label "Last name"
30-
:component :label
31-
:id :full-name}
25+
[::c/label {:label "Full name"
26+
:id :full-name}]
3227

33-
{:component :button
34-
:id :test-button
35-
:label "Hello"}
28+
[:div
29+
[::c/button
30+
{:id :test-button
31+
:label "Hello"}]]
3632

3733
[:div
3834
[: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"}}]]]}
4642
:model
4743
[[:demographics
4844
[:first-name {:id :first-name}]
@@ -52,7 +48,7 @@
5248
:effects
5349
[{:inputs [:first-name]
5450
:handler (fn [_ {:keys [first-name]}]
55-
(rf/dispatch [::core/update-component-state
51+
(rf/dispatch [::core/merge-component-state
5652
:last-name
5753
{:disabled? (empty? first-name)}]))}]
5854
:events
@@ -69,15 +65,15 @@
6965

7066
(defn home-page []
7167
[:div
72-
@(rf/subscribe [::core/view :default])
68+
@(rf/subscribe [::core/view :default-ctx :default])
7369
[:hr]
7470
[:label "component states"]
75-
[:pre (pprint @(rf/subscribe [::core/components]))]
71+
[:pre (pprint @(rf/subscribe [::core/component-states :default-ctx]))]
7672
[:label "db state"]
77-
[:pre (pprint @(rf/subscribe [::core/db]))]])
73+
[:pre (pprint @(rf/subscribe [::core/db :default-ctx]))]])
7874

7975
(defn ^:dev/after-load mount-root []
80-
(rf/dispatch-sync [::core/init schema])
76+
(rf/dispatch-sync [::core/init-ctx :default-ctx schema {}])
8177
(r/render [home-page] (.getElementById js/document "app")))
8278

8379
(defn init! []

dev/user.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
(def get-symbol-name (comp symbol module-name->kebab-case))
236236

237237
(defn define-domino-component [component base-class]
238-
(str "(defmethod domino.ui.component/component :" (get-symbol-name component) " [opts]"
238+
(str "(defmethod component ::c/" (get-symbol-name component) " [[_ opts]]"
239239
"\n"
240240
" (fn []\n"
241241
" [syn-antd." (module-name->kebab-case base-class) "/" (get-symbol-name component) " opts]))"))
@@ -245,7 +245,7 @@
245245
" (:require\n"
246246
(when reagent? (str " [syn-antd."
247247
(module-name->kebab-case class)
248-
"]\n [domino.ui.component]\n"))
248+
"]\n [domino.ui.component :refer [component] :as c]\n"))
249249
(when input? (str " [syn-antd.reagent-utils]\n"))
250250
"))\n\n"
251251
rest-of-file))
@@ -271,4 +271,4 @@
271271
[suffix])))]
272272
(make-parents filename)
273273
(spit (as-file filename)
274-
(factory-ns-shadow (or class path) file-body (some? class) input?)))))
274+
(factory-ns-shadow (or class path) file-body (some? class) input?)))))

project.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
:dependencies [[org.clojure/clojure "1.10.1" :scope "provided"]
99
[syn-antd "1.3.0"]
10-
[domino/ui "0.1.0" :scope "provided"]]
10+
[domino/ui "0.1.2" :scope "provided"]]
1111

1212
:source-paths ["src"]
1313
:clean-targets ^{:protect false} ["target"]
@@ -22,4 +22,4 @@
2222
;; For code completion in cursive, managed by shadow-cljs.edn
2323
[reagent "0.9.0-rc1"]
2424
[re-frame "0.11.0-rc1"]]
25-
:repl-options {:init-ns user}}})
25+
:repl-options {:init-ns user}}})

shadow-cljs.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[[reagent "0.9.0-rc1"]
77
[re-frame "0.11.0-rc1"]
88
[syn-antd "1.3.0"]
9-
[domino/ui "0.1.0" :scope "provided"]]
9+
[domino/ui "0.1.2" :scope "provided"]]
1010

1111
:builds
1212
{:test-page {:target :browser

src/domino/ui/antd/affix.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.affix
22
(:require
33
[syn-antd.affix]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :affix [opts]
7+
(defmethod component ::c/affix [[_ opts]]
88
(fn []
9-
[syn-antd.affix/affix opts]))
9+
[syn-antd.affix/affix opts]))

src/domino/ui/antd/alert.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.alert
22
(:require
33
[syn-antd.alert]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :alert [opts]
7+
(defmethod component ::c/alert [[_ opts]]
88
(fn []
9-
[syn-antd.alert/alert opts]))
9+
[syn-antd.alert/alert opts]))

src/domino/ui/antd/anchor.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(ns domino.ui.antd.anchor
22
(:require
33
[syn-antd.anchor]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :anchor [opts]
7+
(defmethod component ::c/anchor [[_ opts]]
88
(fn []
99
[syn-antd.anchor/anchor opts]))
1010

11-
(defmethod domino.ui.component/component :anchor-link [opts]
11+
(defmethod component ::c/anchor-link [[_ opts]]
1212
(fn []
13-
[syn-antd.anchor/anchor-link opts]))
13+
[syn-antd.anchor/anchor-link opts]))

src/domino/ui/antd/auto_complete.cljs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
(ns domino.ui.antd.auto-complete
22
(:require
33
[syn-antd.auto-complete]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
[syn-antd.reagent-utils]
66
))
77

8-
(defmethod domino.ui.component/component :auto-complete [opts]
8+
(defmethod component ::c/auto-complete [[_ opts]]
99
(fn []
1010
[syn-antd.auto-complete/auto-complete opts]))
1111

12-
(defmethod domino.ui.component/component :auto-complete-opt-group [opts]
12+
(defmethod component ::c/auto-complete-opt-group [[_ opts]]
1313
(fn []
1414
[syn-antd.auto-complete/auto-complete-opt-group opts]))
1515

16-
(defmethod domino.ui.component/component :auto-complete-option [opts]
16+
(defmethod component ::c/auto-complete-option [[_ opts]]
1717
(fn []
18-
[syn-antd.auto-complete/auto-complete-option opts]))
18+
[syn-antd.auto-complete/auto-complete-option opts]))

src/domino/ui/antd/avatar.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.avatar
22
(:require
33
[syn-antd.avatar]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :avatar [opts]
7+
(defmethod component ::c/avatar [[_ opts]]
88
(fn []
9-
[syn-antd.avatar/avatar opts]))
9+
[syn-antd.avatar/avatar opts]))

src/domino/ui/antd/back_top.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.back-top
22
(:require
33
[syn-antd.back-top]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :back-top [opts]
7+
(defmethod component ::c/back-top [[_ opts]]
88
(fn []
9-
[syn-antd.back-top/back-top opts]))
9+
[syn-antd.back-top/back-top opts]))

src/domino/ui/antd/badge.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.badge
22
(:require
33
[syn-antd.badge]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :badge [opts]
7+
(defmethod component ::c/badge [[_ opts]]
88
(fn []
9-
[syn-antd.badge/badge opts]))
9+
[syn-antd.badge/badge opts]))

src/domino/ui/antd/breadcrumb.cljs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
(ns domino.ui.antd.breadcrumb
22
(:require
33
[syn-antd.breadcrumb]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :breadcrumb [opts]
7+
(defmethod component ::c/breadcrumb [[_ opts]]
88
(fn []
99
[syn-antd.breadcrumb/breadcrumb opts]))
1010

11-
(defmethod domino.ui.component/component :breadcrumb-item [opts]
11+
(defmethod component ::c/breadcrumb-item [[_ opts]]
1212
(fn []
1313
[syn-antd.breadcrumb/breadcrumb-item opts]))
1414

15-
(defmethod domino.ui.component/component :breadcrumb-separator [opts]
15+
(defmethod component ::c/breadcrumb-separator [[_ opts]]
1616
(fn []
17-
[syn-antd.breadcrumb/breadcrumb-separator opts]))
17+
[syn-antd.breadcrumb/breadcrumb-separator opts]))

src/domino/ui/antd/button.cljs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
(ns domino.ui.antd.button
22
(:require
33
[syn-antd.button]
4-
[domino.ui.component]
54
[domino.ui.core :as core]
5+
[domino.ui.component :refer [component] :as c]
66
[re-frame.core :as rf]))
77

8-
(defmethod domino.ui.component/component :button [{:keys [id disabled on-click label] :as opts}]
8+
(defmethod component ::c/button [[_ {:keys [context id disabled on-click label] :as opts}]]
99
(fn []
10-
[syn-antd.button/button (assoc opts :on-click (or on-click #(rf/dispatch [::core/id id (.now js/Date)]))
11-
:disabled (or disabled @(rf/subscribe [::core/component id :disabled?])))
10+
[syn-antd.button/button
11+
(-> opts
12+
(dissoc :render)
13+
(assoc :on-click (or on-click #(rf/dispatch [::core/transact context [id (.now js/Date)]]))
14+
:disabled (or disabled (:disabled? @(rf/subscribe [::core/subscribe context id])))))
1215
label]))
1316

14-
(defmethod domino.ui.component/component :button-group [opts]
17+
(defmethod component ::c/button-group [[_ opts]]
1518
(fn []
16-
[syn-antd.button/button-group opts]))
19+
[syn-antd.button/button-group opts]))

src/domino/ui/antd/calendar.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.calendar
22
(:require
33
[syn-antd.calendar]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :calendar [opts]
7+
(defmethod component ::c/calendar [[_ opts]]
88
(fn []
9-
[syn-antd.calendar/calendar opts]))
9+
[syn-antd.calendar/calendar opts]))

src/domino/ui/antd/card.cljs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
(ns domino.ui.antd.card
22
(:require
33
[syn-antd.card]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :card [opts]
7+
(defmethod component ::c/card [[_ opts]]
88
(fn []
99
[syn-antd.card/card opts]))
1010

11-
(defmethod domino.ui.component/component :card-grid [opts]
11+
(defmethod component ::c/card-grid [[_ opts]]
1212
(fn []
1313
[syn-antd.card/card-grid opts]))
1414

15-
(defmethod domino.ui.component/component :card-meta [opts]
15+
(defmethod component ::c/card-meta [[_ opts]]
1616
(fn []
17-
[syn-antd.card/card-meta opts]))
17+
[syn-antd.card/card-meta opts]))

src/domino/ui/antd/carousel.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.carousel
22
(:require
33
[syn-antd.carousel]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :carousel [opts]
7+
(defmethod component ::c/carousel [[_ opts]]
88
(fn []
9-
[syn-antd.carousel/carousel opts]))
9+
[syn-antd.carousel/carousel opts]))

src/domino/ui/antd/cascader.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns domino.ui.antd.cascader
22
(:require
33
[syn-antd.cascader]
4-
[domino.ui.component]
4+
[domino.ui.component :refer [component] :as c]
55
))
66

7-
(defmethod domino.ui.component/component :cascader [opts]
7+
(defmethod component ::c/cascader [[_ opts]]
88
(fn []
9-
[syn-antd.cascader/cascader opts]))
9+
[syn-antd.cascader/cascader opts]))

0 commit comments

Comments
 (0)