summaryrefslogtreecommitdiff
path: root/src/index.cljs.hl
blob: cc70325810ac224e8f36c6db590c68907223e625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(page "index.html"
  (:require [app.rpc :as rpc]
            [cljs.pprint :refer [pprint]]
            [cljsjs.semantic-ui :as ui]
            [Blockly]
            [Blockly.Blocks.loops]
            [Blockly.Blocks.lists]
            [Blockly.Blocks.texts]
            [Blockly.Blocks.procedures]
            [Blockly.Blocks.math]
            [Blockly.Blocks.variables]
            [Blockly.Blocks.colour]
            [Blockly.Blocks.logic]
            [Blockly.Msg.en]))

(rpc/init)
(defc= state rpc/state)
(defc= error rpc/error)

(def toolbox
  "<xml>
    <block type=\"controls_if\"></block>
    <block type=\"logic_compare\"></block>
    <block type=\"controls_repeat_ext\"></block>
    <block type=\"math_number\"></block>
    <block type=\"math_arithmetic\"></block>
    <block type=\"text\"></block>
    <block type=\"text_print\"></block>
  </xml>")

(defelem blockly-workspace
         [{:keys [options] :as attr} kids]
         (let [elem (div (dissoc attr :options) kids)]
           (with-init!
             (set! (.-workspace elem)
                   (.inject js/Blockly elem (clj->js options))))
           elem))


(html
  (head
    (link :rel "stylesheet" :type "text/css"
          :href "cljsjs/semantic-ui/common/semantic.min.css")
    (title "Tankputer"))
  (body
    (h1 "Tankputer")
    (textarea :text (cell= (with-out-str (pprint state))))
    (blockly-workspace :css {:height "480px" :width "600px"}
                       :options {:media "media/" :toolbox toolbox})))

;; vim: set expandtab ts=2 sw=2 filetype=clojure :