v0.10.1 - 2021-12-11
- Issue where somehow an invalid selector would be produced from munged function names, this fix ensures that there cannot be a selector with a hyphen+number, or number at the start of the selector. Will draft a new release when I've gotten to the bottom of this issue, currently unable to reproduce. See issue #7.
- Hashing issue using fractional values #9. Convert style object to string
before calculating hash
(= (hash 1) (hash 1.4)) => true
- The
:key
and:group
meta data is now completely removed, deciding instead to "automatically key" all functions based on the computed style. This results in a bit different class/id where a hash is appended to the selector. 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 thegoog.DEBUG
flag. If you'd like to see the hint during advanced builds setgoog.DEBUG
to true in production compiler config.(defn style [] ^{:hint "my-hint"} {:color "red"})
.ns_function_my-hint_1234567 { color: red; }
- This library from here on out only supports
cljs
environment. Previously most of the library was written incljc
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.
- By using the macro sugar
trick
users no longer have to require macros via the usual methods like
:require-macros
, just require in the macros like any other function fromherb.core
(ns my.namespace (:require [herb.core :refer [<class defgroup]]))
v0.8.2 - 2019-07-10
- Fixed issue in
<style
macro wherethrow
would get the wrong number of arguments and error out.
- Markedly improve performance when using large stylegroups
- Upgrade dependencies
v0.8.1 - 2019-05-13
- Upgrade garden dependency to version 1.3.9
- Re-enable minification/pretty-printing
v0.8.0 - 2019-03-30
- Updated dependencies
- Allow passing at-rules (at-media, at-supports ...) to defglobal
- New meta type
:combinators
, allows for targeting using garden selector combinators like>
,+
,-
,descendant
fromgarden.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.
v0.7.2 - 2019-01-01
- Remove clojure tools.analyzer dependency
- Temporarily disable pretty printing due to a bug affecting certain media queries.
- Remove debux-stubs dependency
v0.7.1 - 2018-12-28
- Split out site as a separate project.
- Move examples to demo/examples
v0.7.0 - 2018-12-27
: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 tojoin
- New global
herb.core/init!
function defined and currently takes only:vendors
and:auto-prefix
as possible options - Finish first draft of the tutorial page
- Improve error handling, and use
clojure.spec
for various input validation :auto-prefix
now accepts strings as well as keywords- Add passing multiple elements in
defglobal
for a single rule:(defglobal [:body :html {:margin 0}])
- Change how the
data-herb
attr is parsed, fixing issue with namespace slashes not matching fully qualified name
v0.6.0 - 2018-10-13
global-style!
runtime function has been replaced bydefglobal
macro
- Upgrade dependencies
- The herb data string is no longer used in production builds
- Data-string now more resemble the fully qualified name of input function
- Change project structure from multiple separate projects to a single project
- Disable CSS pretty printing on production builds
- @supports queries via
:supports
metadata - @keyframes support via
defkeyframes
macro and accompanying<keyframes
macro - vendor prefixes via
:vendors
and:auto-prefix
metadata - defglobal macro that when used appends garden style vectors to head as CSS
v0.5.0 - 2018-06-17
- Clojure support
<style
macro that returns realized styles instead of a classnamedefgroup
macro to wrap common pattern
- Business logic now in
cljc
to simplify testing, using lein test instead of a javascript runner - Rename
set-global-style!
toglobal-style!
- Rename
:mode
to:pseudo
v0.4.0 - 2018-03-31
- Issue with passing a keyword as a style key causing a crash
- New meta data
:id
that returns an id instead of a classname - Add
set-global-style!
helper fn that assists setting styles to global elements like , and so forth - Add
join-classes
helper fn that takes multiple class names and joins them. - Setup
:advanced
build, using munged function names in-place of fully qualified names
- Introduce two new macros
<class
and<id
and deprecatewith-style
- Changed identifier and data string to use input functions
.-name
field. This allows for nested forms. - Include NS in anonymous function identifiers and data string to make them easier to debug
- Args are no longer used as a data string identifier, key is used instead since it would more likley conform to a readable identifier.
v0.3.5 - 2018-02-23
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]]}
- Fixed issue where multiple levels of extended style fns would not work.
v0.3.4 - 2018-02-19
- Fixed issue where an extra dash got added to the returned classname
v0.3.3 - 2018-02-17
- Unit tests
- Improve anonymous function classname hashing
- Passed keys now replace all non legal characters with underscore, making it more lenient.
v0.3.2 - 2018-02-15
- Refactor large portions of the codebase
- Issue with :extend meta-data and multiple single functions with args
v0.3.1 - 2018-02-11
- Anonymous functions, with-style can now take named or unnamed functions.
Anonymous functions gets the name
name.space/anonymous-(hash)
. Hash is calculated from the combined string of returned style map and meta.
v0.3.0 - 2018-02-11
Macro NS has changed so, to require macro all requires of herb need to change
from herb.macro
to herb.core
- Support media queries
- Move macro ns to core.clj, move rest into core.cljs
- Fixed issues with inheritance precedence