clojurescript

Accordions out of the box with Clojurescript and Closure

Accordions are actually available out-of-the-box in Clojurescript with the included Google closure.js that Clojurescript is built upon. This code shows the AnimatedZippy, which has a nice slide-out function; there’s also a plain Zippy. They are drop-in replacements for eachother. Rendering the Accordion (Zippy) (ns toryanderson.views.components.shared "Shared components that may be used on multiple views" (:require [reagent.core :as r] [goog.dom :as dom] [goog.string :as gstr]) (:import goog.ui.AnimatedZippy)) (defn accordion [{:keys [header-text content-body]}] (let [header-id (gstr/createUniqueString) content-id (gstr/createUniqueString)] (r/create-class {:display-name "zippy" :reagent-render (fn [id] [:div.

A Lesson in the Beauty of Data - XML Parsing on the Front End: to CLJS or not to CLJS?

The task came that I need to parse some XML in a front-only app. In a sense, browsers are just big XML (≅ HTML) processors, so embracing the Clojure principle of being a hosted language, it seemed desirable to utilize the built-in power of my browser. This effort turned out to be a rabbit hole, though. Consider the following: A Native Approach (let [s "<title>Tech.ToryAnderson.com</title>" ;; 1 p (js/DOMParser.) ;; 2 doc (.

Adding Custom Transit Handlers to re-frame-http-fx AJAX requests

Setting the Scene Transit is a seamless alternative to JSON (actually an extension of JSON). Why use Transit when JSON is so prevalent? For me, the simple reason was that it allows me to preserve my data types (mine are Clojure, but they are not necessarily such) over the wire. For me in particular this was my time types, and my uuids (which I wanted to standardize so they stop alternating between UUIDs, strings, and keywords, for matching purposes).

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.