Style comes in all shapes and sizes. Therefore, the bigger you are, the more style you have. - Miss Piggy, The Muppets
Herein re-frame "Effects Handlers", for performing styling tasks.
In the namespace where you register your event handlers, prehaps called
handlers.cljs
, you have two things to do:
First, add this require
to the ns
:
(ns app.handlers
(:require
...
[com.smxemail.re-frame-style-fx] ;; <-- add this
...))
Second, write an event handler which uses this effect:
(reg-event-fx
:handler-with-style
(fn [{:keys [db]} _]
{:style/install {:content "body { font-family: Helvetica; }"
:on-success [:style-success]
:on-failure [:style-failure]}}))
Under the hood this uses goog.style/installStyleSheet.
Copyright © 2016 SMX Ltd.
Distributed under the Eclipse Public License, the same as Clojure.