Fork me on GitHub
#hoplon
<
2017-03-12
>
jumblerg04:03:18

[hoplon/ui "0.2.0-SNAPSHOT"] is on clojars. most significant changes are to the markdown, text, and font apis. fonts are now constructed like this:

(def geometos      (font :system ["Geometos"]      :opentype "geometos.ttf"      :generic :sans-serif))
(def lato-regular  (font :system ["Lato Regular"]  :opentype "lato-regular.ttf"  :generic :sans-serif))
(def lato-italic   (font :system ["Lato Italic"]   :opentype "lato-italic.ttf"   :generic :sans-serif))
(def lato-medium   (font :system ["Lato Medium"]   :opentype "lato-medium.ttf"   :generic :sans-serif))
(def lato-semibold (font :system ["Lato Semibold"] :opentype "lato-semibold.ttf" :generic :sans-serif))
and used like this:
(elem :sh (r 1 1) :ah :mid :t 21 :tf lato-medium
  "hey foo!")
a more detailed explanation can be found in the docstrings: https://github.com/hoplon/ui/blob/master/lib/src/hoplon/ui/attrs.cljs#L382-L481 https://github.com/hoplon/ui/blob/master/lib/src/hoplon/ui.cljs#L272-L342

mynomoto13:03:16

@jumblerg both docstring are in the wrong place, they should go before the args. 😉 Nice work writing them.

chromalchemy17:03:31

Nice @jumblerg! I am doing some design and will try out today

chromalchemy17:03:20

How can I override an (on) attribute method in an element instance like so:

(defelem myelem [attr] (elem attr :click #(print "foo")))
(myelem :click #(print "bar")
I want to declare default behavior in the defelem but replace/augment that behavior as needed (without necessarily creating a new custom attribute)

jjttjj17:03:05

@chromalchemy you have to switch where attr is in the elem, like this:

(defelem myelem [attr] (elem :click #(print "foo") attr))
(myelem :click #(print "bar")

jjttjj17:03:29

because the attributes are evaluated in order i believe so having the argument attrs after the "default" ones will all the defaults to be overridden

chromalchemy17:03:48

That makes sense. More elegant than I expected. Thx!