Skip to content

Commit

Permalink
fix bugs after states refactor; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed May 24, 2020
1 parent 344ca3d commit aa2899a
Show file tree
Hide file tree
Showing 11 changed files with 392 additions and 387 deletions.
458 changes: 221 additions & 237 deletions calcit.cirru

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions meyvn.edn

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
"author": "jiyinyiyong",
"license": "MIT",
"devDependencies": {
"http-server": "^0.12.1",
"shadow-cljs": "2.8.93"
"http-server": "^0.12.3",
"shadow-cljs": "2.9.8"
},
"dependencies": {
"node-notifier": "7.0.1",
"shortid": "^2.2.15"
}
}
2 changes: 1 addition & 1 deletion release.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:version "0.4.0"
{:version "0.4.1-a1"
:group-id "respo"
:artifact-id "reel"
:skip-tag true
Expand Down
4 changes: 2 additions & 2 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
:dependencies [
[mvc-works/hsl "0.1.2"]
[mvc-works/shell-page "0.1.10"]
[respo "0.12.0"]
[respo "0.12.1"]
[respo/ui "0.3.14"]
[respo/value "0.3.0"]
[cumulo/util "0.1.10"]
[cumulo/util "0.1.11"]
[cirru/favored-edn "0.1.3"]
[org.clojure/core.incubator "0.1.4"]
]
Expand Down
2 changes: 1 addition & 1 deletion src/reel/comp/container.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
(let [store (:store reel), states (:states store)]
(div
{:style (merge ui/global)}
(comp-todolist states (:tasks store))
(comp-todolist (>> states :todolist) (:tasks store))
(comp-reel (>> states :reel) reel nil))))
22 changes: 6 additions & 16 deletions src/reel/comp/reel.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
[reel.style :as style]
[favored-edn.core :refer [write-edn]]))

(defn on-merge [e dispatch! m!] (dispatch! :reel/merge nil))

(defn on-reset [e dispatch!] (dispatch! :reel/reset nil))

(defn on-run [e dispatch!] (dispatch! :reel/run nil))

(defn on-step [e d! m!] (d! :reel/step nil))

(defn on-toggle [e dispatch!] (dispatch! :reel/toggle nil))

(defn render-button [guide on-click enabled?]
(div
{:style (merge ui/link {:user-select :none} (if (not enabled?) {:color (hsl 0 0 90)})),
Expand All @@ -45,13 +35,13 @@
{:style (merge ui/flex ui/column style-reel user-styles)}
(div
{}
(render-button "Merge" on-merge true)
(render-button "Reset" on-reset true)
(render-button "Step" on-step (:stopped? reel))
(render-button "Run" on-run (:stopped? reel))
(render-button "Close" on-toggle (not (:stopped? reel))))
(render-button "Merge" (fn [e d!] (d! :reel/merge nil)) true)
(render-button "Reset" (fn [e d!] (d! :reel/reset nil)) true)
(render-button "Step" (fn [e d!] (d! :reel/step nil)) (:stopped? reel))
(render-button "Run" (fn [e d!] (d! :reel/run nil)) (:stopped? reel))
(render-button "Close" (fn [e d!] (d! :reel/toggle nil)) (not (:stopped? reel))))
(div
{:style ui/row}
{:style (merge ui/expand ui/row)}
(comp-records (:records reel) (:pointer reel))
(div
{:style (merge ui/column ui/flex {:overflow :auto, :padding "0 8px"})}
Expand Down
12 changes: 3 additions & 9 deletions src/reel/comp/task.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
[respo.comp.space :refer [=<]]
[respo-ui.core :as ui]))

(defn on-input [task-id] (fn [e dispatch!] (dispatch! :task/edit [task-id (:value e)])))

(defn on-remove [task-id] (fn [e dispatch!] (dispatch! :task/remove task-id)))

(defn on-toggle [task-id] (fn [e dispatch!] (dispatch! :task/toggle task-id)))

(def style-container {:margin "8px 0", :height 32})

(def style-done
Expand All @@ -27,17 +21,17 @@
{:style style-container}
(div
{:style (merge style-done (if (:done? task) {:background-color (hsl 42 100 60)})),
:on-click (on-toggle (:id task))})
:on-click (fn [e d!] (d! :task/toggle (:id task)))})
(=< 8 nil)
(input
{:value (:text task),
:placeholder "Content of task",
:on-input (on-input (:id task)),
:on-input (fn [e d!] (d! :task/edit [(:id task) (:value e)])),
:style ui/input})
(=< 8 nil)
(button
{:style (merge
ui/button
{:background-color (hsl 6 100 60), :color :white, :border :none}),
:on-click (on-remove (:id task))}
:on-click (fn [e d!] (d! :task/remove (:id task)))}
(<> "Remove"))))
14 changes: 6 additions & 8 deletions src/reel/comp/todolist.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
[respo-ui.core :as ui]
[reel.comp.task :refer [comp-task]]))

(defn on-click [state] (fn [e dispatch! mutate!] (dispatch! :task/add state) (mutate! "")))

(defn on-input [e dispatch! mutate!] (mutate! (:value e)))

(def style-container {:padding 8, :overflow :auto})

(defcomp
comp-todolist
(states tasks)
(let [state (or (:data states) "")]
(let [cursor (:cursor states), state (or (:data states) "")]
(div
{:style (merge ui/fullscreen style-container)}
(div
Expand All @@ -23,8 +19,10 @@
{:placeholder "Task to add...",
:value state,
:style ui/input,
:on-input on-input,
:on-keydown (fn [e d! m!] (if (= (:keycode e) 13) (do (d! :task/add state) (m! ""))))})
:on-input (fn [e d!] (d! cursor (:value e))),
:on-keydown (fn [e d!] (if (= (:keycode e) 13) (do (d! :task/add state) (d! [] ""))))})
(=< 8 nil)
(button {:style ui/button, :on-click (on-click state)} (<> "Add")))
(button
{:style ui/button, :on-click (fn [e d!] (d! :task/add state) (d! cursor ""))}
(<> "Add")))
(list-> {} (->> tasks (map (fn [task] [(:id task) (comp-task task)])))))))
6 changes: 2 additions & 4 deletions src/reel/updater.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

(ns reel.updater )
(ns reel.updater (:require [respo.cursor :refer [update-states]]))

(defn updater [store op op-data op-id op-time]
(case op
:states
(let [[cursor new-state] op-data]
(assoc-in store (concat [:states] op [:data]) new-state))
:states (update-states store op-data)
:task/add
(update store :tasks (fn [tasks] (cons {:id op-id, :done? false, :text op-data} tasks)))
:task/remove
Expand Down
Loading

0 comments on commit aa2899a

Please sign in to comment.