-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup of input fix, along with a workspace card to test it out.
- Loading branch information
Showing
3 changed files
with
64 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/workspaces/com/fulcrologic/fulcro/issues/pr552_string_buffered_input_cards.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns com.fulcrologic.fulcro.issues.pr552-string-buffered-input-cards | ||
(:require | ||
[com.fulcrologic.fulcro.algorithms.merge :as merge] | ||
[com.fulcrologic.fulcro.components :as comp :refer [defsc]] | ||
[com.fulcrologic.fulcro.dom :refer [b button div p h3 li p ul]] | ||
[com.fulcrologic.fulcro.dom.inputs :refer [StringBufferedInput]] | ||
[com.fulcrologic.fulcro.mutations :as m :refer [defmutation]] | ||
[com.fulcrologic.fulcro.rendering.ident-optimized-render :as ior] | ||
[nubank.workspaces.card-types.fulcro3 :as ct.fulcro] | ||
[nubank.workspaces.core :as ws])) | ||
|
||
(def MyInput (StringBufferedInput ::MyInput {:model->string identity | ||
:string->model identity})) | ||
|
||
(def ui-input (comp/factory MyInput)) | ||
|
||
(defsc Item | ||
[this {:item/keys [name]}] | ||
{:ident :item/id | ||
:query [:item/id :item/name :ui/clicked?] | ||
:initial-state {:item/id 1 :item/name "Item 1" :ui/clicked? false}} | ||
(let [v (last (for [n (range 1000000)] | ||
(+ n (* 2 n))))] | ||
(div | ||
(div (str v)) | ||
(ui-input {:value name | ||
:onChange (fn [v] (m/set-string! this :item/name :value v))}) | ||
(button {:onClick (fn [] (m/set-string! this :item/name :value "Bar"))} | ||
"Force to Bar") | ||
(button {:onClick (fn [] (m/set-string! this :item/name :value "Foo"))} | ||
"Force to Foo")))) | ||
|
||
(def ui-item (comp/factory Item {:keyfn :item/id})) | ||
|
||
(defsc Root [_this {:root/keys [item]}] | ||
{:query [{:root/item (comp/get-query Item)}] | ||
:initial-state {:root/item {}}} | ||
|
||
(div | ||
(ui-item item))) | ||
|
||
(ws/defcard string-buffered-input-card | ||
(ct.fulcro/fulcro-card | ||
{::ct.fulcro/wrap-root? false | ||
::ct.fulcro/root Root})) |