Skip to content

Instantly share code, notes, and snippets.

@zehnpaard
zehnpaard / clicker2.core.cljs
Created November 13, 2016 21:46
Reagent Form-2 Component Nesting Part 2 (Purely Demonstrative Purposes)
(ns clicker2.core
(:require [reagent.core :as r]))
(def message (r/atom "Hello"))
(defn clicker [some-message]
(let [john? (r/atom true)]
(fn [some-message]
(let [clicks (r/atom 0)]
(fn [some-message]
@zehnpaard
zehnpaard / react-tutorial-v2.core.cljs
Last active September 24, 2018 01:50
Reagent port of official React tutorial code upto "Lifting State Up" https://facebook.github.io/react/tutorial/tutorial.html#lifting-state-up
(ns react-tutorial.core
(:require
[reagent.core :as r]))
(defn Square [value click-fn]
[:button.square {:on-click click-fn} value])
(defn Board []
(let [squares (r/atom (apply vector (repeat 9 nil)))
handle-click #(swap! squares assoc % "X")
@zehnpaard
zehnpaard / react-tutorial-v3.core.cljs
Last active November 16, 2016 08:20
Reagent port of official React tutorial code upto Declaring a Winner https://facebook.github.io/react/tutorial/tutorial.html#declaring-a-winner
(ns react-tutorial.core
(:require
[reagent.core :as r]))
(defn calculateWinner [squares]
(let [lines [[0 1 2]
[3 4 5]
[6 7 8]
[0 3 6]
@zehnpaard
zehnpaard / react-tutorial-v4.core-parts.cljs
Last active November 17, 2016 10:02
Reagent port of official React tutorial code for the Storing a History section https://facebook.github.io/react/tutorial/tutorial.html#storing-a-history
(defn Board [squares click-fn]
(let [renderSquare (fn [i]
[Square (get squares i) #(click-fn i)])]
[:div
[:div.board-row
[renderSquare 0]
[renderSquare 1]
[renderSquare 2]]
[:div.board-row
[renderSquare 3]
@zehnpaard
zehnpaard / react-tutorial-v5.core.cljs
Last active November 18, 2016 10:15
Reagent port of official React tutorial upto the end https://facebook.github.io/react/tutorial/tutorial.html
(ns react-tutorial.core
(:require
[reagent.core :as r]))
(defn calculateWinner [squares]
(let [lines [[0 1 2]
[3 4 5]
[6 7 8]
[0 3 6]
@zehnpaard
zehnpaard / min-css.core.cljs
Created November 18, 2016 22:18
Minimal ClojureScript/Reagent/Figwheel setup for automatic CSS loading
(ns min-css.core
(:require
[reagent.core :as r]))
(defn my-app []
[:div
[:h1 "Hello Reagent"]
[:p "Some random text in a regular p tag"]
[:p.my-class "More random text in a my-class p tag"]])
@zehnpaard
zehnpaard / min-garden.core.clj
Created November 20, 2016 06:13
Minimal setup for compiling CSS to file using Garden
(ns min-garden.core
(:require [garden.core :refer [css]]))
(def style
[:body {:font-size "16px"}])
(defn -main []
(css {:output-to "resources/public/css/main.css"}
style))
@zehnpaard
zehnpaard / min-garden.core.clj
Created November 20, 2016 06:13
Minimal setup for compiling CSS to file using Garden
(ns min-garden.core
(:require [garden.core :refer [css]]))
(def style
[:body {:font-size "16px"}])
(defn -main []
(css {:output-to "resources/public/css/main.css"}
style))
@zehnpaard
zehnpaard / min-lein-garden.core.clj
Last active November 20, 2016 07:26
Minimal setup for using lein garden to auto-compile CSS
(ns min-lein-garden.core
(:require [garden.def :refer [defstyles]]))
(defstyles style
[:body
{:font-size "14px"
:background "#f00"}])
@zehnpaard
zehnpaard / figwheel-garden.core.cljs
Created November 22, 2016 08:34
Minimal setup to get lein-garden auto-compile and Figwheel auto-load working with Reagent
(ns figwheel-garden.core
(:require
[reagent.core :as r]))
(defn my-app []
[:div
[:h1 "Hello Reagent!"]
[:p "Hello Garden!"]
[:p.my-class "Hello My-Class!"]])