:key
and :group
meta data is now completely removed,
deciding instead to "automatically key" all functions based on it's
function and argument signature. This results in a bit different
class/id where a hash is appended to the selector based on its
function and arguments, this won't break anything but it does make
the API much simpler. This also has the added benefit of improving
grouping performance significantly.Add :hint
meta data. Can be used to extend classname in case you
need some more data to attached to classname. The hint is only used
during development builds, by checking the goog.DEBUG
flag. If
you'd like to see the hint during advanced builds set goog.DEBUG
to true in production compiler config.
(defn style []
^{:hint "my-hint"}
{:color "red"})
.ns_function_my-hint_1234567 {
color: red;
}
cljs
environment. Previously most of the library was written in cljc
to
allow for easier testing, which made it possible to use Herb in
regular Clojure environments. The functionality was severly limited
and honestly I don't see much use for it. If you'd like to do some
server side CSS rendering a much better option is simply using
Garden directly.:require-macros
, just require in the macros like any other
function from herb.core
(ns my.namespace
(:require [herb.core :refer [<class defgroup]]))
<style
macro where throw
would get the wrong number of arguments and error out.:combinators
, allows for targeting using garden selector
combinators like >
, +
, -
, descendant
from garden.selectors
namespace.(defn selector-test []
^{:combinators {[:> :div :span] {:margin-left "10px"
:background "red"}
[:+ :p] {:background "purple"
:margin 0
:margin-left "20px"}
[:- :div] {:background "yellow"}
[:descendant :div] {:background "green"}}}
{:background :blue
:color :white})
Result:
.herbdemo_examples_selector-test {
background: blue;
color: white;
}
.herbdemo_examples_selector-test > div > span {
margin-left: 10px;
background: red;
}
.herbdemo_examples_selector-test + p {
background: purple;
margin: 0;
margin-left: 20px;
}
.herbdemo_examples_selector-test ~ div {
background: yellow;
}
.herbdemo_examples_selector-test div {
background: green;
}
The syntax is a map with a vector of variable length as a key, starting with whatever combinator function you want to run as a keyword. Some combinators takes multiple elements as arguments. After that put whatever style map you'd like to be applied.
:auto-prefix
in component meta is removed, instead use either global config
via herb.core/init! or pass :prefix true
and :vendors
for a local override.join-classes
is renamed to join
herb.core/init!
function defined and currently takes only
:vendors
and :auto-prefix
as possible optionsclojure.spec
for various input validation:auto-prefix
now accepts strings as well as keywordsdefglobal
for a single rule:
(defglobal [:body :html {:margin 0}])
data-herb
attr is parsed, fixing issue with namespace slashes not matching fully qualified nameglobal-style!
runtime function has been replaced by defglobal
macro:supports
metadatadefkeyframes
macro and accompanying <keyframes
macro:vendors
and :auto-prefix
metadata<style
macro that returns realized styles instead of a classnamedefgroup
macro to wrap common patterncljc
to simplify testing, using lein test instead of a javascript runnerset-global-style!
to global-style!
:mode
to :pseudo
:id
that returns an id instead of a classnameset-global-style!
helper fn that assists setting styles to global elements like , join-classes
helper fn that takes multiple class names and joins them.:advanced
build, using munged function names in-place of fully qualified names<class
and <id
and deprecate with-style
.-name
field. This
allows for nested forms.A change in the :extend metadata syntax:
;; Passing single function
^{:extend some-style-fn}
;; Passing fn with args
^{:extend [some-style-fn some-arg]}
;; passing multiple functions
^{:extend [[style-fn1 "green" 42] [style-fn]]}
name.space/anonymous-(hash)
. Hash is
calculated from the combined string of returned style map and meta.Macro NS has changed so, to require macro all requires of herb need to change
from herb.macro
to herb.core
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close