Garden unit helpers do not work
tatut opened this issue · comments
Tatu Tarvainen commented
Documentation says garden unit helpers should work.
dev:cljs.user=> (require '[stylefy.core :as stylefy])
nil
dev:cljs.user=> (require '[garden.units :refer [px]])
nil
dev:cljs.user=> (stylefy/use-style {:width (px 20)})
{:class "_stylefy_-1726757740",
:style {:width {:unit :px, :magnitude 20}}}
dev:cljs.user=> (type (get-in *1 [:style :width]))
garden.types/CSSUnit
Expected :width
to have value "20px", not a garden record instance.
Jari Hanhela commented
The converted style map has not been added in to the DOM yet, so use-style returns both the class definition and the style map as inline style, just as it is. This also causes special namespaced keywords to be handled as normal CSS properties. They don't really do anything when inline, but it's still incorrect to return them:
dev:cljs.user=> (stylefy/use-style {:width "20px" ::stylefy/media {}})
{:class "_stylefy_-1985416734",
:style {:width "20px", :stylefy.core/media {}, :visibility "hidden"}}
To fix this:
- Those special namespaced keywords should be removed from inline style.
- Garden CSSUnits (and CSSColors) should be converted to strings before returning the style as inline style.
To avoid this problem, you can always define units as strings, as I have done in all examples.
Jari Hanhela commented
This bug will be fixed in the next stylefy release (1.1.0).