-
Notifications
You must be signed in to change notification settings - Fork 0
CSS Unleashed
Kenneth Tilton edited this page Mar 29, 2022
·
4 revisions
WIP. We'll see that, yes, we do still just code CSS, but we do so with the power of CLJS and reactive formulas, as well as the class attribute, if we like.
Matrix-powered CSS means three wins:
- the full power of CLJS to cobble together our CSS;
- individual formulas for individual CSS attributes, making code easy to follow; and
- "co-location", meaning our CSS resides in the source with our component. Sorry, Virginia, "separation of concerns" is almost always a mistake.
Below we tick off the several ways CSS can be specified for mxWeb components, but it might be just as easy to read the source code where the same remarks are alongside actual code.
- the null capability: use the
classDOM parameter to connect to predefined CSS; - nearly null: just supply an in-line
styleas a string, e.g, "background:gray; border: thin dotted red"; - write a cell formula that reactively builds a style string based on other appstate;
- create a CLJS map
{:color :red :padding "6px"}and convert to a style string with thestyle-stringutility; - build a CLJS in a cell formula;
- create a Matrix model of type
mxweb.css/cssand specify individual rules for individual style properties.
Help learning mxWeb is available on the #matrix channel of Clojurians Slack.
Issues with this trainer can be reported on its GitHub repo.