A clojurescript library for easy growl-like notifications.
To use: [siren "0.2.0"] in your project dependencies.
Comes with two default color scheme: light and dark. You can of
course give your own, either with CSS (the siren-box class) or by
an optional argument.
(sticky-siren! "Hello!")
(siren! {:content "I'm dark!})
(siren! {:content "I'm light!" :style :light})
(siren! {:content "<div>I'm light!</div><div>And complex!</div>" :style :light})
(siren! (domina/by-id "some-id"))
The sticky-siren! will remain until discarded with remove-siren! or
remove-all-sirens!.
You can set the content of a siren however you like. Either
directly, as (siren! "Hey I'm content!") or as direct HTML data:
(siren! {:content "<div>Oh, really?</div>"}).
The style can be set by giving it directly to the siren
(siren! {:style {:width "300px" :color "grey"} :content "Oy!"})
The variable base-style is available in the siren namespace.
(siren! {:style (merge base-style {:width "300px" :color "grey"}) :content "Oy!"})
You can also create your own CSS for the class siren-box.
Here are the possible siren options:
- :style
- :dark, :light, :css or your own style in the form
{:background "grey" :padding "10px"}
- :dark, :light, :css or your own style in the form
- :content
- A string or a html element.
- :delay
- Time in ms before the siren is discarded.
(siren! {:content "<div>Oy!</div> :style {:width "300px" :color "white" :background "black"} :delay 3000})
Siren will accept raw HTML. You can send HTML with multiple div
if you want to do so. You can also use enlive templates. How about
some image in the siren?
To customize an existing siren box, use the replace-siren!
function:
(replace-siren! siren-object {:content "Oh hey!"})
This is mostly useful for a sticky-siren.
You can also create a function that will always send its content
to the same siren (and reset the timeout delay) with
continuous-siren-factory.
(def my-siren (continuous-siren-factory))
(my-siren "I'm the initial message!")
(my-siren {:content "I'm the second message!" :style :light})
May the power of the REPL be with you!
Copyright © 2012 Frozenlock
Distributed under the Eclipse Public License, the same as Clojure.
