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.
Extra indentation when nested inside a media query.
Extra indentation when nested inside a media query.
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.
_show-time - When set to true, elapsed time will be printed.
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. _show-time - When set to true, elapsed time will be printed.
Extra indentation when nested inside keyframes.
Extra indentation when nested inside keyframes.
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.
(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/css-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/css-rem 3) :auto]] :background-color (colors/rotate-hue "#ff0000" 60)} => width: 50%; margin: 0 15px rem3 auto; background-color: hsl(60 1 0.5);
A special map for calc keywords.
A special map for calc keywords.
(comma-join {:keys [compiles-to args]})
Redefining functions/comma-join because there would be a cyclic dependency otherwise.
Redefining functions/comma-join because there would be a cyclic dependency otherwise.
(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.
Generates CSS from a CSSAtRule record, at the moment, these are available: at-media, at-keyframes, at-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: at-media, at-keyframes, at-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.
(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].
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.
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".
(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/space-joined 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/space-joined structures with a comma. E.g.: (compile-expression [[(u/px 15) (u/percent 20)] [:red :chocolate]]) => "15px 20%, #FF0000 #D2691E"
(compile-params attributes-map)
Given a map of HTML style attributes described in Tornado, compiles all the values of the parameters, but the parameters names remain the same. This function is useful for Reagent to allow you describing the style with Tornado. Example usage:
(compile-params {:width (px 500) :background-color (important (rgb 100 150 200)) :border [[(px 1) :solid :black]] :display :flex})
=> {:width "500px", :background-color "rgb(100, 150, 200) !important", :border "1px solid #000000", :display "flex"}
Given a map of HTML style attributes described in Tornado, compiles all the values of the parameters, but the parameters names remain the same. This function is useful for Reagent to allow you describing the style with Tornado. Example usage: (compile-params {:width (px 500) :background-color (important (rgb 100 150 200)) :border [[(px 1) :solid :black]] :display :flex}) => {:width "500px", :background-color "rgb(100, 150, 200) !important", :border "1px solid #000000", :display "flex"}
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.
(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"
(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; }
(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.
(conjs s value)
Conj(oin)s to a (potentially empty) set.
Conj(oin)s to a (potentially empty) set.
(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.
(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.
(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.
(flatten-seqs coll)
Recursively expands collections for which (seq? coll)
returns true. Always expands
the first collection, even if it is e.g. a vector ((seq? []) is false); all more
deeply nested collections will not be expanded.
See clojure.core/flatten.
Recursively expands collections for which `(seq? coll)` returns true. Always expands the first collection, even if it is e.g. a vector ((seq? []) is false); all more deeply nested collections will not be expanded. See clojure.core/flatten.
(html-style attributes-map)
Can be used for compilation of a map of style parameters to a single string of html style="..." attribute. Receives the styles map as its argument and returns a string of compiled style:
(html-style {:width (px 500) :height (percent 15) :color :font-black :background-color :teal})
=> "width:500px;height:15%;color:#1A1B1F;background-color:#008080"
Can be used for compilation of a map of style parameters to a single string of html style="..." attribute. Receives the styles map as its argument and returns a string of compiled style: (html-style {:width (px 500) :height (percent 15) :color :font-black :background-color :teal}) => "width:500px;height:15%;color:#1A1B1F;background-color:#008080"
(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.
(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.
(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.
(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.
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"} ...
(update-in-keys m f path & ks)
Given a map or a record, a function, a common partial path and keys which will be appended to that path, updates all keys in the given map with that function.
Given a map or a record, a function, a common partial path and keys which will be appended to that path, updates all keys in the given map with that function.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close