See
- https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive
- https://andrearichiardi.com/blog/posts/clojurescript-cursive-shadow-setup.html
- in shadow-cljs.edn:
,,,
| (ns ui.core | |
| (:require | |
| [rum.core :as rum] | |
| [ui.styles :as styles] | |
| [ui.drag :as drag])) | |
| (rum/defcs item-modal < (drag/draggable-mx styles/item-modal) [state item] | |
| (let [*position (get state drag/k) | |
| drag! #(drag/start-drag! *position (:id item)) |
| let pad = " ".repeat(10); | |
| for (i=0; i<20; i++) { | |
| let c = "#" + Math.floor(Math.random()*16777215).toString(16); | |
| console.log("%c" + pad + c + pad, "font-size:20px; background-color:" + c); | |
| } |
| // path needs tail tweaks | |
| var tagname = function (node) { | |
| return node.tagName || "#text"; | |
| }; | |
| var xpath = function (node, idx, tag, path) { | |
| idx = idx || 0; | |
| tag = tag || tagname(node); | |
| path = path || ""; |
| (defn rum-debug-mixin [component-name] | |
| (let [p (partial prn component-name)] | |
| {:init (fn [state props] (p :init props) state) | |
| :will-mount (fn [state] (p :will-mount) state) | |
| :before-render (fn [state] (p :before-render) state) | |
| :wrap-render (fn [render-fn] (p :wrap-render) render-fn) | |
| ;:render (fn [state] (p :render) [[:div#pseudo-dom {} "pseudodom"] state]) | |
| :did-catch (fn [state, err, info] (p :did-catch err info) state) | |
| :did-mount (fn [state] (p :did-mount) state) | |
| :after-render (fn [state] (p :after-render) state) |
| <html> | |
| <head> | |
| <title>chaos</title> | |
| </head> | |
| <body> | |
| <canvas id="chaos" width="0" height="0" style="border:1px solid #000000;"> | |
| </canvas> | |
| <script type="text/javascript"> | |
| function getRandomInt(min, max) { | |
| min = Math.ceil(min); |
| <canvas id="canvas"></canvas> | |
| <script> | |
| var num = 20000; | |
| var canvas = document.getElementById("canvas"); | |
| var width = canvas.width = 960; | |
| var height = canvas.height = 500; | |
| var ctx = canvas.getContext("2d"); | |
| var numbers = [...Array(num).keys()]; | |
| var particles = numbers.map(function(i) { | |
| return [Math.round(width*Math.random()), Math.round(height*Math.random())]; |
| (ns foo | |
| (:import | |
| [java.io File] | |
| [java.nio.file Files] | |
| [org.apache.commons.codec.binary Base64])) | |
| (def s | |
| (->> "/path/to/image.png" | |
| (new File) | |
| (.toPath) |
| (defmacro locals-map [& [env]] | |
| ;; https://gist.github.com/noisesmith/3490f2d3ed98e294e033b002bc2de178 | |
| (let [ks (->> (or env &env) | |
| keys | |
| (remove #{'_}) | |
| (remove #(-> % name (str/includes? "__"))))] | |
| (zipmap (map name ks) ks))) | |
| (defmacro pp-locals [] | |
| `(clojure.pprint/pprint |
| <body> | |
| <style type="text/css"> | |
| body { | |
| width: 600px; | |
| margin-left: auto; | |
| margin-right: auto; | |
| } | |
| pre { | |
| white-space: pre-line; | |
| } |