Fork me on GitHub
#re-frame
<
2017-01-09
>
qqq06:01:26

[:div {:class "mainHeader"}
                    [:i {:class "zmdi zmdi-menu"}]
                    [re-com.core/button
                     :style {:background-color (if @hover? "#ccc" "#eee")
                             :color "#000"}
                     :label "Menu"
                     :on-click (fn [& rest] (swap! show-menu? #(not %)))
                     :attr {:on-mouse-over (fn [& rest] (reset! hover? true))
                            :on-mouse-out  (fn [& rest] (reset! hover? false))}]]
^^ is there anyway to "embed the menu icon into the button label" ?

mikethompson06:01:50

plus examples on thatpage

qqq06:01:49

string | hiccup // clearly I should have read the docs

qqq06:01:59

turns out, re-com.core/md-icon-button is even better 🙂

mikethompson07:01:30

All code for the demo app can be found in the repo

qqq07:01:48

https://github.com/Day8/re-com/blob/master/src/re_demo/core.cljs#L110-L130 <-- so it looks like you guys manually created a div, then manually setup hover + click events?

qqq12:01:31

[:div [:div {:class "mainSidebarItem"
                     :style {:padding-left (str ind "px")}}
               [:span
                {:style {:display "inline-block"}}
                [re-com.core/md-icon-button :md-icon-name "zmdi-plus" :size :smaller]
                [re-com.core/md-icon-button :md-icon-name "zmdi-minus" :size :smaller]
                "Hello world"]]]
how can I force these three elements (plus, minus, "Hello world") to be on the same line?

qqq12:01:40

ah; this is what h-box is used for

notanon13:01:59

can you use flexbox? if you can work with modern browsers, it's much better than the old way of doing things.

ska14:01:06

Hi. Is there an obvious way of scheduling some events regularly? I'd like to drive an auto-update of a page every few seconds and wonder what the best way is for that.

notanon15:01:18

@ska you can do a regular js setInterval and inside the callback function do a re-frame.core/dispatch to trigger the event(s) you'd like

notanon15:01:45

dispatch

To send an event, call dispatch with the event vector as argument:

   (rf/dispatch [:event-id  value1 value2])
In this "simple" app, a :timer event is dispatched every second:

(defn dispatch-timer-event
  []
  (let [now (js/Date.)]
    (rf/dispatch [:timer now])))  ;; <-- dispatch used

;; call the dispatching function every second
(defonce do-timer (js/setInterval dispatch-timer-event 1000))
This is an unusual source of events. Normally, it is an app's UI widgets which dispatch events (in response to user actions), or an HTTP POST's on-success handler, or a websocket which gets a new packet.

ska15:01:45

@notanon Merci! I will look at that. Right now, I guess I need to revisit reg-event, reg-event-db, reg-event-fx and understand the differences.

lsnape15:01:50

Has anyone here come up with a good way of keeping js/localStorage and certain values in the app-state in sync? The best I’ve come up with is a helper fn:

(defn assoc-db-local-store
  [coeffects k v & kvs]
  (-> coeffects
      (update :db #(apply assoc % k v kvs))
      (update :local-store #(apply assoc % k v kvs))))
where :local-store invokes a register fx handler.

notanon16:01:13

@ska -db is just a simplified form of -fx. If your event only needs app-db as input and only outputs app-db changes as output, then it's shorthand for -fx, which can have anything for input and any effects for output

sandbags17:01:15

Can anyone point me at a good example of using buddy+jwt/jwe to handle authenticated calls from a re-frame SPA and a ring (Liberator in this case) backend service?

sandbags17:01:37

i'm sort of piecing it together but i'm also in a bit of a hurry and hoping i can crib from working code

qqq20:01:44

http://qqq-demos.appspot.com/ <-- the + - icons do not seem vertically aligned with the text; any idea what I should look into for debugging this?

notanon20:01:13

add an offset to the text or the icon

notanon20:01:21

margin-top: 2px; seems to work for me

notanon20:01:29

for the + icon

qqq20:01:42

this seems very hackish and browser dependent ?

qqq20:01:13

eh, figured out an even more hackish solution

qqq20:01:20

monospace fonts + '+' and '-' lol

notanon20:01:32

margin isnt browser specific, that's been around since netscape/ie1 🙂

notanon20:01:42

w/e works man

qqq21:01:02

@notanon: my concern is not :margin-top, but rather different browsers may align stuff differently before the :margin-top is applied

notanon21:01:04

i don't think you'll need to worry about that. you've assumed a browser new enough to support flexbox, those types of issues are mostly gone these days. and your bootstrap.min.css import will normalize the differences.

notanon21:01:43

e.g.

/*!
 * Bootstrap v3.3.5 ()
 * Copyright 2011-2015 Twitter, Inc.
 * Licensed under MIT ()
 *//*! normalize.css v3.0.3 | MIT License |  *

notanon21:01:31

regarding margin, there's a reason developers call web designers "pixel pushers".

qqq21:01:57

http://www.w3schools.com/cssref/pr_text_white-space.asp <-- does reframe/hiccup ignore the ":white-space" tag? the following code, is throwing an exception:

[:span {:style {:font-family "Monospace"
                                               :white-space: "pre"}}
                                "   Hello World 2"]
with error of:
java.lang.RuntimeException: Invalid token: :white-space:, compiling:(/Users/x/dodv/client/src/g/apps/index.cljc:120:53)

qqq21:01:56

it's :white-space, not :white-space:

notanon21:01:02

the actual source code doesn't have the extra colon at the end of :white-space ?

notanon21:01:34

can you do string keys in reagent?

notanon21:01:40

e.g. "white-space"

mikethompson21:01:08

@qqq I'm responding here to a question you had much earlier, not the ones immediately above ... on this page see the "Warning: Be All In" http://re-demo.s3-website-ap-southeast-2.amazonaws.com/#/layout

mikethompson21:01:51

> Never mint your own container [:div] or [:span] unless you also give them the correct flex styles, which is arduous and error prone. Probably just use vbox and hbox everywhere.

mikethompson21:01:28

@lsnape does that library work okay? If so, I'd add it to the External Resource Page

qqq21:01:44

@mikethompson: I clearly never read that part; thanks for saving future-me loads of problems

mikethompson21:01:59

@sandbags to keep you going, there's this (which you may have already found) https://funcool.github.io/buddy-auth/latest/#signed-jwt

sandbags22:01:27

thanks Mike, yeah i'm chewing over that and a few other articles i've found ... part of my problem is I am trying to do three things at once, in a hurry 🙂

sandbags22:01:16

I've made that classic error "I'm going to rewrite it and do it properly"

sandbags22:01:52

for some value of 'properly'

qqq22:01:22

@mikethompson : http://qqq-demos.appspot.com/ <-- I have implemented a tree widget 🙂

mccraigmccraig22:01:16

@sandbags: i used buddy+jwt with re-frame, but my backend is on yada, not liberator, so probably quite different plumbing... i can share some relevant code with you tomorrow if you think it would help

sandbags23:01:42

@mccraigmccraig thanks for getting back to me .. i'll plow on tomorrow and see how i get on and, if it's okay with you, ask you then if I'm stuck.

sandbags23:01:11

or at least maybe get you to look over what i've done and point out where i've made some stupid moves