Skip to content

Instantly share code, notes, and snippets.

@skuro
Created November 5, 2017 15:38
Show Gist options
  • Select an option

  • Save skuro/f574f991649b57a6ac8b4de9780dcbdc to your computer and use it in GitHub Desktop.

Select an option

Save skuro/f574f991649b57a6ac8b4de9780dcbdc to your computer and use it in GitHub Desktop.
Sample code from the Clojurebridge session #2
(ns nightcoders.removeme
(:require [reagent.core :as r]
[quil.core :as q]))
(enable-console-print!)
(def image-url
"https://i.pinimg.com/originals/96/cc/3a/96cc3aafba195cecfc2662acc405c699.gif")
(def clojurebridge-url
"http://www.clojurebridge.org/")
(defn greet [name surname]
(str "hello " name " " surname ", "
" your name is " (+ (count name)
(count surname)) " long"))
(def number-sum (r/atom nil))
(defn calculate
[]
(let [first (.-value (.getElementById js/document "first"))
second (.-value (.getElementById js/document "second"))]
(reset! number-sum (+ (int first)
(int second)))))
(defn content []
[:div {:style {:width "100%"}}
[:p (greet "carlo" "sciolla")]
[:p "This website was created during a "
[:a {:href clojurebridge-url} "clojurebridge"]
" session."]
[:input {:type "text"
:id "first"}]
[:input {:type "text"
:id "second"}]
[:button {:id "calculate"
:on-click calculate}]
[:p "The sum is:" @number-sum]
[:img {:src image-url
:style {:margin-left "auto"
:margin-right "auto"
:display "block"}}]])
(r/render-component [content]
(.querySelector js/document "#content"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment