Last active
April 5, 2018 21:22
-
-
Save alekcz/cab59db57ba71e5bc2b6f7c883836107 to your computer and use it in GitHub Desktop.
HoneyBadger Express: Getting started with Clojurescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns honeybadger.core | |
(:require [rum.core :as rum])) | |
(enable-console-print!) | |
(println "This text is printed from src/honeybadger/core.cljs. Go ahead and edit it and see reloading in action.") | |
;; define your app data so that it doesn't get over-written on reload | |
(defonce app-state (atom {:text "Hello world!"})) | |
;;^^^ I'm not sure what's cracking here, so let's leave that for another day. | |
(def unsplash-endpoint "https://source.unsplash.com/collection/782142/400x300/") | |
(rum/defc image-box [] | |
[:div { :style { :background-image (str "url('" unsplash-endpoint "?sig=" (rand 999999999) "')") | |
:background-size "cover" | |
:background-repeat "no-repeat" | |
:border-radius "5px" | |
:box-shadow "0px 2px 2px 2px rgba(0, 0, 0, 0.2)" | |
:height "200px" | |
:margin "10px" | |
:width "300px"}}]) | |
(rum/defc image-grid [n] | |
[:div { :style { :display "flex" | |
:flex-direction "row" | |
:flex-wrap "wrap" | |
:padding "30px"}} | |
(repeat n (image-box))]) | |
(rum/mount (image-grid 21) | |
(. js/document (getElementById "app"))) | |
(defn on-js-reload [] | |
;; optionally touch your app-state to force rerendering depending on | |
;; your application | |
;; (swap! app-state update-in [:__figwheel_counter] inc) | |
) | |
;;^^^ More autogenerated code that seems useful. Let's leave it too. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment