Liking cljdoc? Tell your friends :D

tornado.compiler

The Tornado compiler, where you should only care about these 3 functions: css, repl-css, compile-expression.

The Tornado compiler, where you should only care about these 3 functions:
css, repl-css, compile-expression.
raw docstring

*at-media-indent*clj

Extra indentation when nested inside a media query.

Extra indentation when nested inside a media query.
sourceraw docstring

*flags*clj

The current flags for a tornado build compilation:

:indent-length - Specifies, how many indentation spaces should be in the compiled CSS file after any nesting in @rule or params map. Defaults to 4.

:pretty-print? - Specifies, whether the compiled CSS should be pretty printed. Defaults to true. If set to false, the CSS file will be compressed after compilation (removal of unnecessary characters like spaces and newlines) to make the CSS file a bit smaller.

:output-to - Specifies, where the compiled CSS file should be saved.

The current flags for a tornado build compilation:

:indent-length - Specifies, how many indentation spaces should be in the compiled
                 CSS file after any nesting in @rule or params map. Defaults to 4.

:pretty-print? - Specifies, whether the compiled CSS should be pretty printed.
                 Defaults to true. If set to false, the CSS file will be compressed
                 after compilation (removal of unnecessary characters like spaces
                 and newlines) to make the CSS file a bit smaller.

:output-to     - Specifies, where the compiled CSS file should be saved.
sourceraw docstring

*in-params-context*clj

source

*keyframes-indent*clj

Extra indentation when nested inside keyframes.

Extra indentation when nested inside keyframes.
sourceraw docstring

*media-query-parents*clj

Current parents Used for compiling @media to temporarily store parents paths for compiling @media changes.

Current parents Used for compiling @media to temporarily store parents
paths for compiling @media changes.
sourceraw docstring

attr-map-to-cssclj

(attr-map-to-css attributes-map)

Compiles an attributes map and translates the compiled data to CSS: (attr-map-to-css {:width (units/percent 50) :margin [[0 (units/px 15) (units/rem* 3) :auto]] :background-color (colors/rotate-hue "#ff0000" 60)} => width: 50%; margin: 0 15px rem3 auto; background-color: hsl(60 1 0.5);

Compiles an attributes map and translates the compiled data to CSS:
(attr-map-to-css {:width            (units/percent 50)
                  :margin           [[0 (units/px 15) (units/rem* 3) :auto]]
                  :background-color (colors/rotate-hue "#ff0000" 60)}
=> width: 50%;
   margin: 0 15px rem3 auto;
   background-color: hsl(60 1 0.5);
sourceraw docstring

calc-keywordsclj

A special map for calc keywords

A special map for calc keywords
sourceraw docstring

commajoinclj

(commajoin {:keys [compiles-to args]})

Redefining functions/commajoin because there would be a cyclic dependency otherwise.

Redefining functions/commajoin because there would be a cyclic dependency otherwise.
sourceraw docstring

compile-all-selectors-params-combinationsclj

(compile-all-selectors-params-combinations prepared-hiccup)

Given a prepared hiccup vector (with precalculated and simplified combinations of all selectors, children and params, this function generates a CSS string from the data.

Given a prepared hiccup vector (with precalculated and simplified combinations of all
selectors, children and params, this function generates a CSS string from the data.
sourceraw docstring

compile-at-rulecljmultimethod

Generates CSS from a CSSAtRule record, at the moment, these are available: @media, @keyframes, @font-face.

E.g.: #tornado.types.CSSAtRule{:identifier "media" :value {:rules {:min-width "500px" :max-width "700px"} :changes [:.abc {:margin-top "20px"}]}}

Depending on the :identifier ("media" in this case), a relevant method is called.

Generates CSS from a CSSAtRule record, at the moment, these are available:
@media, @keyframes, @font-face.

E.g.:
#tornado.types.CSSAtRule{:identifier "media"
                         :value      {:rules   {:min-width "500px"
                                                 :max-width "700px"}
                                      :changes [:.abc {:margin-top "20px"}]}}

Depending on the :identifier ("media" in this case), a relevant method is called.
sourceraw docstring

compile-attributes-mapclj

(compile-attributes-map attributes-map)

Compiles an attributes map, returns a sequence of [compiled-attribute compiled-value].

Compiles an attributes map, returns a sequence of [compiled-attribute compiled-value].
sourceraw docstring

compile-colorcljmultimethod

Generates CSS from a color, calls a relevant method to do so depending on the color's type: "rgb", "rgba", "hsl", "hsla", keyword, string, keyword (for keywords, tries to get an exact hex-value of the color from colors/default-colors), otherwise prints out a warning and returns a string form of that keyword.

Generates CSS from a color, calls a relevant method to do so depending on the
color's type:
"rgb", "rgba", "hsl", "hsla", keyword, string, keyword (for keywords,
tries to get an exact hex-value of the color from colors/default-colors),
otherwise prints out a warning and returns a string form of that keyword.
sourceraw docstring

compile-css-recordcljmultimethod

Compiles a CSS record (unit, function, at-rule, color). For 4 different types of CSS selectors, there is a different multifunction "compile-selector".

Compiles a CSS record (unit, function, at-rule, color). For 4 different types of
CSS selectors, there is a different multifunction "compile-selector".
sourceraw docstring

compile-expressionclj

(compile-expression expr)

Compiles an expression: a number, string, symbol or a record. If the expression is a vector of sequential structures, compiles each of the structures and str/joins them with a space. Then, str/joins all these str/spacejoined structures with a comma.

E.g.: (compile-expression [[(u/px 15) (u/percent 20)] [:red :chocolate]]) => "15px 20%, #FF0000 #D2691E"

Compiles an expression: a number, string, symbol or a record. If the expression is
a vector of sequential structures, compiles each of the structures and str/joins them
with a space. Then, str/joins all these str/spacejoined structures with a comma.

E.g.:
(compile-expression [[(u/px 15) (u/percent 20)] [:red :chocolate]])
=> "15px 20%, #FF0000 #D2691E"
sourceraw docstring

compile-selectorcljmultimethod

Compiles a CSS combinator, attribute selector, pseudoclass or pseudoelement or a selector in a keyword/symbol/string form.

Compiles a CSS combinator, attribute selector, pseudoclass or pseudoelement
or a selector in a keyword/symbol/string form.
sourceraw docstring

compile-selectorsclj

(compile-selectors selectors-sequences)

Given a sequence of selectors paths, e.g. '([:iframe :.abc] [:#def sel/after :.ghi]), this function translates all the selectors paths to CSS and str/joins them with a comma, which is a shorthand that can be used in CSS to give different selectors paths the same parameters. ... => "iframe .abc, #def::after .ghi"

Given a sequence of selectors paths, e.g. '([:iframe :.abc] [:#def sel/after :.ghi]),
this function translates all the selectors paths to CSS and str/joins them with a comma,
which is a shorthand that can be used in CSS to give different selectors paths the same
parameters. ... => "iframe .abc, #def::after .ghi"
sourceraw docstring

compile-selectors-and-paramsclj

(compile-selectors-and-params {:keys [paths params at-media at-font-face
                                      at-keyframes]})

For a current :paths & :params/:at-media map, translates the paths (selectors) which all have the equal params map or at-media record to CSS and str/joins them with a comma (a shorthand which can be used in CSS). Also translates the params map or at-media record to CSS and creates a CSS block from these compiled things, e.g.: (compile-selectors-and-params {:paths #{[:.abc :#def :iframe] [:td :span sel/hover]} :params {:color :font-black :margin [[(units/px 15) (units/em 2)]] :display :flex}} => .abc #def iframe, td span:hover { color: #1A1B1F; margin: 15px 2em; display: flex; }

For a current :paths & :params/:at-media map, translates the paths (selectors) which
all have the equal params map or at-media record to CSS and str/joins them with a comma
(a shorthand which can be used in CSS). Also translates the params map or at-media
record to CSS and creates a CSS block from these compiled things, e.g.:
(compile-selectors-and-params {:paths  #{[:.abc :#def :iframe] [:td :span sel/hover]}
                               :params {:color   :font-black
                                        :margin  [[(units/px 15) (units/em 2)]]
                                        :display :flex}}
=> .abc #def iframe, td span:hover {
       color: #1A1B1F;
       margin: 15px 2em;
       display: flex;
    }
sourceraw docstring

compile-selectors-sequenceclj

(compile-selectors-sequence selectors-path)

Given a selectors path, which can contain special selectors, this function generates a CSS string from the selectors.

Given a selectors path, which can contain special selectors, this function
generates a CSS string from the selectors.
sourceraw docstring

conjsclj

(conjs s value)

Conj(oin)s to a (potentially empty) set,

Conj(oin)s to a (potentially empty) set,
sourceraw docstring

cssclj

(css css-hiccup)
(css flags css-hiccup)

Generates CSS from a hiccup vector or a (maybe multiple times) nested list of hiccup vectors (and/or with @keyframes, @font-face). If pretty-print? is set to false, compresses it as well. Then saves the compiled CSS string to a given file path.

You can also call this function without flags whenever you want to to just get the whole compiled CSS string printed out.

Generates CSS from a hiccup vector or a (maybe multiple times) nested list of hiccup
vectors (and/or with @keyframes, @font-face). If pretty-print? is set to false,
compresses it as well. Then saves the compiled CSS string to a given file path.

You can also call this function without flags whenever you want to to just get
the whole compiled CSS string printed out.
sourceraw docstring

expand-hiccup-list-for-compilationclj

(expand-hiccup-list-for-compilation parents
                                    unevaluated-hiccup
                                    nested-hiccup-vectors-list)

Given a hiccup element path (parents) and current unevaluated hiccup, this function first expands all lists and lazy sequences until it comes across a structure which is neither of them. After that, the function recursively goes through all hiccup vectors in the expanded hiccup vectors list: The current vector of unevaluated hiccup combinations is passed to another expanding function which recursively calculates all combinations of a current hiccup vector by calling itself and then this function for deeper expanding again - all combinations of its selectors (+ selectors received from parents), params and children. It then inserts all these combinations to the unevaluated hiccup and returns it updated with the combinations inserted.

Given a hiccup element path (parents) and current unevaluated hiccup, this function
first expands all lists and lazy sequences until it comes across a structure which
is neither of them. After that, the function recursively goes through all hiccup vectors
in the expanded hiccup vectors list:
The current vector of unevaluated hiccup combinations is passed to another expanding
function which recursively calculates all combinations of a current hiccup vector by
calling itself and then this function for deeper expanding again - all combinations of
its selectors (+ selectors received from parents), params and children. It then
inserts all these combinations to the unevaluated hiccup and returns it updated with
the combinations inserted.
sourceraw docstring

expand-hiccup-vectorclj

(expand-hiccup-vector parents unevaluated-hiccup hiccup-vector)

Given a (potentially nil) current parents sequence, unevaluated hiccup combinations in a vector the current hiccup vector, which is in a form [sel1 maybe-sel2 maybe-sel3 ... {maybe-params-map} [maybe-child1] [maybe-child2] ... ] where each child is a hiccup vector as well, this function adds all combinations of selectors and descendant children and their selectors together with corresponding parameters (or skips the combination of params are nil) to the unevaluated-hiccup argument, recursively.

Given a (potentially nil) current parents sequence, unevaluated hiccup combinations
in a vector the current hiccup vector, which is in a form
[sel1 maybe-sel2 maybe-sel3 ... {maybe-params-map} [maybe-child1] [maybe-child2] ... ]
where each child is a hiccup vector as well, this function adds all combinations
of selectors and descendant children and their selectors together with corresponding
parameters (or skips the combination of params are nil) to the unevaluated-hiccup
argument, recursively.
sourceraw docstring

expand-seqsclj

(expand-seqs coll)

Expands lists and lazy sequences in a nested structure. Always expands the first collection. When any more deeply nested collection is neither a list nor a lazy-seq, this function does not expand it. (expand-seqs [:a :b]) => (:a :b) ... the first element is anything seqable -> transforms it to a list

(expand-seqs [[:a :b]]) => ([:a :b]) ... the 2nd element is neither a list nor a lazy-seq -> does not expand it

(expand-seqs [(list :a [:b (map identity [:c :d :e])])]) => (:a [:b (:c :d :e)]) ... 2nd element a vector -> does not expand the nested lazy-seq.

See clojure.core/flatten. This function just only expands seqs.

Expands lists and lazy sequences in a nested structure. Always expands the first
collection. When any more deeply nested collection is neither a list nor a lazy-seq,
this function does not expand it.
(expand-seqs [:a :b])
=> (:a :b) ... the first element is anything seqable -> transforms it to a list

(expand-seqs [[:a :b]])
=> ([:a :b]) ... the 2nd element is neither a list nor a lazy-seq -> does not expand it

(expand-seqs [(list :a [:b (map identity [:c :d :e])])])
=> (:a [:b (:c :d :e)]) ... 2nd element a vector -> does not expand the nested lazy-seq.

See clojure.core/flatten. This function just only expands seqs.
sourceraw docstring

in-keyframes-contextcljmacro

(in-keyframes-context & body)

Temporarily adds extra + 1* globally used indent for compiling @keyframes.

Temporarily adds extra + 1* globally used indent for compiling @keyframes.
sourceraw docstring

in-params-contextcljmacro

(in-params-context & body)

A macro to bind in-params-context to true, which causes a css at-rule keyframes record to be compiled to {:anim-name} (assuming it is for :animation-name)

A macro to bind *in-params-context* to true, which causes a css at-rule keyframes
record to be compiled to {:anim-name} (assuming it is for :animation-name)
sourceraw docstring

indentclj

(indent)

The actual globally used indent in a string form of X spaces.

The actual globally used indent in a string form of *X* spaces.
sourceraw docstring

just-cssclj

(just-css css-hiccup)

Compiles the hiccup to a string of CSS. Does not do any printing or file output, that is what the functions below are. This one is separate to simplify both functions css and repl-css which just do something with the output of this function.

Compiles the hiccup to a string of CSS. Does not do any printing or file output,
that is what the functions below are. This one is separate to simplify both
functions css and repl-css which just do something with the output of this function.
sourceraw docstring

repl-cssclj

(repl-css css-hiccup)

Generates CSS from a hiccup vector or a (maybe multiple times) nested list of hiccup vectors (and/or with @keyframes, @font-face). It then pretty prints the output string, which is useful for evaluating any tornado code in REPL.

Generates CSS from a hiccup vector or a (maybe multiple times) nested list of hiccup
vectors (and/or with @keyframes, @font-face). It then pretty prints the output string,
which is useful for evaluating any tornado code in REPL.
sourceraw docstring

selectors-params-childrenclj

(selectors-params-children hiccup)

Given a hiccup vector, this function returns a map with keys :selectors, :params, :children and :at-media, where each of these keys' value is a vector of those elements. Besides :params, which is returned as a map, since there cannot be more than 1 params map. Including incorrect elements or failing to comply the right order of the elements (selector -> & more-selectors -> maybe-params -> & maybe-children & maybe-at-media) will throw a detailed error message.

Given a hiccup vector, this function returns a map with keys :selectors, :params,
:children and :at-media, where each of these keys' value is a vector of those
elements. Besides :params, which is returned as a map, since there cannot be more
than 1 params map.
Including incorrect elements or failing to comply the right order of the elements
(selector -> & more-selectors -> maybe-params -> & maybe-children & maybe-at-media)
will throw a detailed error message.
sourceraw docstring

simplify-prepared-expanded-hiccupclj

(simplify-prepared-expanded-hiccup path-params-vector)

Simplifies the expanded hiccup vector: A new map will be created for every unique parameters map or at-media record with {:params {...}, :paths #{...}} (with :at-media instead of :params alternatively), where elements with equal params or at-media record will be inserted to a set behind the :paths key. This function returns a vector of these unique params/at-media maps.

Simplifies the expanded hiccup vector: A new map will be created for every unique
parameters map or at-media record with {:params {...}, :paths #{...}} (with :at-media
instead of :params alternatively), where elements with equal params or at-media record
will be inserted to a set behind the :paths key. This function returns a vector of
these unique params/at-media maps.
sourceraw docstring

special-media-rules-mapclj

A special map for generating media queries rules, e.g.: (tornado.at-rules/at-media {:rules {:screen :only -> "only screen" :screen false -> "not screen" :screen true -> "screen"} ...

A special map for generating media queries rules, e.g.:
(tornado.at-rules/at-media {:rules {:screen  :only   -> "only screen"
                                    :screen  false   -> "not screen"
                                    :screen  true    -> "screen"} ... 
sourceraw docstring

with-custom-flagscljmacro

(with-custom-flags flags & body)

Given custom-flags & body, temporarily merges default flags with the given flags and executes the body.

Given custom-flags & body, temporarily merges default *flags* with the given flags
and executes the body.
sourceraw docstring

with-media-query-parentscljmacro

(with-media-query-parents -parents- & body)

Temporarily stores current parents paths for compiling @media and adds

  • 1* globally used indent.
Temporarily stores current parents paths for compiling @media and adds
+ 1* globally used indent.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close