generated from PEZ/rn-rf-shadow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummary_field.cljs
34 lines (31 loc) · 1.63 KB
/
summary_field.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(ns gurps.pages.character.widgets.summary-field
(:require [re-frame.core :as rf]
[gurps.utils.i18n :as i18n]
[gurps.utils.debounce :as debounce]
[gurps.widgets.underlined-input :refer [labelled-underlined-input]]))
(defn summary-field
[{:keys [key editable? style input-style text-align on-change-text input-mode max-length]
:or {editable? true, on-change-text identity}}]
(let [val (some-> (rf/subscribe [(keyword :profile key)]) deref)]
[labelled-underlined-input {:label (i18n/label (keyword :t key))
:val val
:on-change-text #(debounce/debounce-and-dispatch [:profile/update key (on-change-text %)] 800)
:text-align text-align
:max-length max-length
:input-mode input-mode
:disabled? (not editable?)
:input-style input-style
:style style}]))
;; [:> view {:key key
;; :style #js [style, (tw (str/join " " ["flex-row gap-1" (if editable? "flex-1" "flex-initial")]))]}
;; ;; label
;; [:> text {:key (str key "-label")
;; :style (tw "font-bold")}
;; (i18n/label (keyword :t key))]
;; ;; input
;; (if editable?
;; [underlined-input {:val val
;; :on-change-text #(debounce/debounce-and-dispatch [:profile/update key (on-change-text %)] 800)
;; :style input-style
;; :text-align text-align}]
;; [:> text val])]