reagent

Uploading Files and Handling Upload Requests in Clojure[script]

What’s the secret? I have used ajax uploads and interactions in Clojure forever; it’s a bread-and-butter skill to use AJAX and JSON1. However, my WordPress usage led me to believe it would be equally trivial to handle file uploads. It turned out to be less trivial than I expected, though. In summary, the secrets I needed were: Make sure the encType on the client is "multipart/form-data", which happens differently with AJAX than with plain HTML

Clojurescript Reagent Image-Previewing Selector

Intro It took some elbow-grease but I was able to convert online examples1 into a working image selector in Reagent Clojurescript. It isn’t a lot of code, but there were two complications: converting the declarative style of the examples into more functional CLJS (hint: it involves closures), and doing it in a way that will jive with the React life-cycle. CSS code The following styling makes things look okay. This is using Garden2 syntax.

Easy d3 tooltips in Clojure reagent

Working with d3js I found myself in need of a tooltip to explicate data as it is explored in a chart. The best way to use d3 with Reagent (react.js) is to use reagent to handle the DOM manipulations and d3 to handle more elaborate visualizaion calculations. We don’t follow the d3 model of adding an event to every dom element to trigger a tooltip item to be created, which duplication would behave poorly with React state maintenance.

My Garden CSS has ascended

I’ve been continually seeking the answer to Garden CSS’s title question: “what’s possible when you trade a preprocessor for a programming language?” I have used Garden exclusively for years, happily wielding garden-gnome to implement hot-loading on my front-end for an excellent development experience. Writing CSS with Clojure data-structures is a hands-down win over raw css-writing, and Garden also gives useful shortcuts that some of the preprocessors also have like lighten, darken, & selectors, and more.