Fork me on GitHub
#hoplon
<
2018-01-10
>
thedavidmeister07:01:24

@flyboarder otoh i have a component that is a basic wrapper around the stripe API that is closer to those states

thedavidmeister07:01:28

(defn credit-card-form
 [customer]
 {:pre [(j/cell? customer)]}
 (let [element (j/cell nil)
       token (stripe.api/token-cell)
       error (stripe.api/error-cell)
       source (j/cell= (stripe.customer/customer->default-source customer))
       processing? (j/cell false)]
  ; Once we have a token from Stripe we need to ship it to our backend for
  ; processing.
  (h/do-watch
   token
   (fn [_ n]
    (when-let [tok-str (:id n)]
     (stripe.wire/token->customer! customer tok-str))))

  (h/form
   :class "stripe-form"
   ; 
   :submit (fn [event]
            (wheel.dom.events/prevent-default event)
            (reset! processing? true)
            (stripe.api/create-token
             @element
             (fn [result]
              (j/dosync
               (reset! error (oops.core/oget result "?error"))
               (reset! token (oops.core/oget result "?token"))
               (reset! processing? false)))))
   (card customer element token error)
   (h/when-tpl error
    (error.hoplon/error (j/cell= (:message error))))
   (button.hoplon/normal
    :type "submit"
    :processing? processing?
    (j/cell= (str (if source "Update" "Add") " your details"))))))

thedavidmeister07:01:41

there can be errors, and the need to process/validate externally, and concepts like a "token" that are more about data in other systems than managing the DOM state of the component itself (although it's important the component does also respond correctly to this data)

donmullen22:01:49

@flyboarder @thedavidmeister any preference on greenfield projects with hoplon for css frameworks. Matt you have both material-ui and semantic. David - any preference for you? hoplon/ui?