react

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.