This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-10
Channels
- # beginners (97)
- # boot (77)
- # cider (7)
- # cljs-dev (47)
- # cljsrn (3)
- # clojure (125)
- # clojure-austin (5)
- # clojure-dusseldorf (1)
- # clojure-italy (4)
- # clojure-russia (91)
- # clojure-spec (80)
- # clojure-uk (54)
- # clojurescript (92)
- # core-async (6)
- # cursive (17)
- # datomic (56)
- # hoplon (7)
- # immutant (3)
- # liberator (3)
- # luminus (4)
- # off-topic (26)
- # om (41)
- # om-next (11)
- # pedestal (3)
- # perun (3)
- # protorepl (25)
- # re-frame (32)
- # reagent (33)
- # ring (46)
- # rum (3)
- # spacemacs (5)
- # specter (82)
- # test-check (16)
- # untangled (8)
- # yada (26)
Yeah, else I'm going to come back to the code and wonder WTH 13 is about. Still stuck in the ugly atom conflict though 😕
There's also https://google.github.io/closure-library/api/goog.events.KeyCodes.html
In our app we have a couple of input fields where the user is supposed to enter quite large numbers (money). User testing makes it clear that it would be easier for our users if could format the numbers separated in groups of thousands. We have tried a couple of naïve ways to do it, but it has resulted in input fields that behave strangely. We have started to use reagent-forms and it would be nice to solve it in a way that works well together with that.
So, anyone has any suggestions how to go about this? It would be a good first step to have the input field format in groups of thousands on blur.
@pez We are using a formatter from google closure to do that:
(def formatter (NumberFormat. (.. NumberFormat -Format -CURRENCY)))
(defn number->formatted
[number]
(.format formatter number))
(defn string->number
"Tries to transform a string to a number, if it cannot parse the number it returns NaN"
[string]
(.parse formatter string))
And you'll need to add the import for NumberFormat
(:import [goog.i18n NumberFormat])
@mitchelkuijpers: thanks! Seems like a robust way to get the formatting right.
@mitchelkuijpers That is a great snippet (if it works; which I assume it does)
While we are on Google closure; is there an accepted strategy to use goog.ui components, or is that bad practice in react-ville
@emccue You can just wrap them in reagent components probably by using the componentDidMount lifecycle calls and stuff
Btw this formatting is for money but I think you can switch the format
hi, how do you implement the StyleSheet
component in reagent? e.g.:
const styles = StyleSheet.create({
kw: {
k: 'v'
}
});
<Text style={styles.kw}>Hello World!</Text>
I mean, the style is in a single object holding the stylesheet names that will just be called later on by desired components
(def styles
{:foo
{:color "red"}})
(defn my-comp []
[:div {:style (get styles :foo)}
"Hello, World!"])
thanks @gadfly361!
^ it's for re-natal, I'm going through the tutorial and finding out what's the equivalent syntax
the example is a separate const that holds the styles then are just referred to by different components
hi, an extended question if it's ok, so calling a single hashmap is ok, but how about if I want to call multiple hashmaps? e.g.
;; The target:
<Text style={[styles.name1, styles.name2]}>Hello World!</Text>
;; I tried this but didn't worked:
[text {:style (get styles [:name1 :name2])} "Hello World!"]
(def styles
{:foo
{:color "red"}
:bar
{:background-color "green"}})
(defn my-comp []
[:div {:style (merge
(get styles :foo)
(get styles :bar))}
"Hello, World!"])
as an aside, i dont generally do something like that, but that is how to replicate the tutorial you are following
I saw something similar to Luno
that's why I thought it will work {:style (get-in s/styles [:app])}
@ejelome if you haven't seen this yet, you may find it interesting: https://github.com/noprompt/garden
the merge one is probably enough, hopefully I can find a more sensible way of injecting styles XD
thanks again @gadfly361! genius 😄