garden
garden copied to clipboard
Improve at-font-face
This seems like a start.
(defn at-font-face [& {:as kwargs}]
(let [kwargs (->> (select-keys kwargs [:family :weight :style :eot :woff :svg])
(remove (comp nil? second))
(into {}))
font-attrs (select-keys kwargs [:family :weight :style])
srcs (select-keys kwargs [:eot :woff :svg])
url (cssfn :url)
format (cssfn :format)]
["@font-face"
{:font font-attrs}
(when-not (empty? srcs)
{:src (for [[fmt uri] srcs]
[(url uri) (format (name fmt))])})]))
(at-font-face
:family "Family"
:weight :normal
:style :normal
:eot "/path/to/eot")
Result
@font-face {
font-style: normal;
font-weight: normal;
font-family: Family;
src: url(/path/to/eot) format(eot);
}
Edit: Add url
Edit: Add demonstration
Does at-font-face work?
I'm trying to use it like so:
(css [(at-font-face :family "Family"
:weight :normal
:style :normal
:eot "/path/to/eot")])
It yields an empty string though.
Any progress on this? I see that at-font-face exists in the source, but I also get an empty string when using it. In src/garden/stylesheet.cljc:
(defn at-font-face
"Create a CSS @font-face rule."
[& font-properties]
["@font-face" font-properties])
This seems not to be implemented usefully (the implementation does not have any of the original definition from the first post)