This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-09
Channels
- # beginners (38)
- # boot (160)
- # cider (143)
- # cljs-dev (62)
- # cljsjs (2)
- # cljsrn (3)
- # clojure (278)
- # clojure-austin (8)
- # clojure-brasil (5)
- # clojure-greece (2)
- # clojure-italy (11)
- # clojure-russia (188)
- # clojure-sg (2)
- # clojure-spec (118)
- # clojure-uk (103)
- # clojurescript (87)
- # core-async (8)
- # cryogen (2)
- # cursive (12)
- # datomic (119)
- # emacs (13)
- # hoplon (4)
- # immutant (12)
- # off-topic (12)
- # om (54)
- # om-next (5)
- # onyx (1)
- # pedestal (2)
- # portland-or (2)
- # re-frame (58)
- # reagent (18)
- # ring-swagger (18)
- # rum (4)
- # spacemacs (4)
- # specter (3)
- # untangled (65)
- # yada (25)
[: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" ?Yep, see description of :label
field:
http://re-demo.s3-website-ap-southeast-2.amazonaws.com/#/button
plus examples on thatpage
thanks! @mikethompson
All code for the demo app can be found in the repo
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?
[: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?can you use flexbox? if you can work with modern browsers, it's much better than the old way of doing things.
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.
@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
there's actually an example on the re-frame docs page https://github.com/Day8/re-frame/blob/master/docs/CodeWalkthrough.md
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.
@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.
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.Scrap that, just found https://github.com/akiroz/re-frame-storage 🙂
@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
here's the doc page. https://github.com/Day8/re-frame/blob/master/docs/EffectfulHandlers.md
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?
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
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?
@notanon: my concern is not :margin-top, but rather different browsers may align stuff differently before the :margin-top is applied
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.
e.g.
/*!
* Bootstrap v3.3.5 ()
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT ()
*//*! normalize.css v3.0.3 | MIT License | *
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)
@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
> 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.
@lsnape does that library work okay? If so, I'd add it to the External Resource Page
@mikethompson: I clearly never read that part; thanks for saving future-me loads of problems
@mccraigmccraig do you have any advice for @sandbags https://clojurians.slack.com/archives/re-frame/p1483981755003606
Ah, thanks @mikethompson
@sandbags to keep you going, there's this (which you may have already found) https://funcool.github.io/buddy-auth/latest/#signed-jwt
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 🙂
@mikethompson : http://qqq-demos.appspot.com/ <-- I have implemented a tree widget 🙂
@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
@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.