             [lt.objs.deploy :as deploy]
             [lt.util.dom :as dom]
             [lt.util.load :as load]
-            [crate.binding :refer [bound -value subatom]])
+            [crate.binding :refer [bound -value subatom]]
+            [crate.compiler :refer [dom-attr]])
   (:require-macros [lt.macros :refer [behavior defui]]))
 
 (defn css-expr [k v]


(def prev-theme "")

(defn get-themes []
  (sort-by #(.-text %)
           (for [[theme path] (object/raise-reduce app/app :themes+ {})]
              #js {:text (pr-str theme) :completion (pr-str theme)})))

(defui stylesheet [name]
  [:link {:rel "stylesheet"
          :type "text/css"
          :id (str "theme-" name)
          :href (-> (object/raise-reduce app/app :themes+ {})
                    (get name "/core/css/themes/default.css")
                    (plugins/adjust-path))}])

(defn load-theme [name]
  (when-not (empty? prev-theme)
    (dom/remove-class (dom/$ :#multi) prev-theme))
  (set! prev-theme (str "theme-" name))
  (dom/add-class (dom/$ :#multi) (str "theme-" name))
  (when-not (dom/$ (str "#theme-" name))
    (dom/append (dom/$ :head) (stylesheet name))))

(behavior ::provide-theme
                  :desc "Style: Provide editor theme"

                            :items get-skins}]
                  :type :user
                  :reaction (fn [this skin]
                              (inject-skin skin)))

(behavior ::provide-skin
                  :desc "Style: Provide skin"
                  :triggers #{:skins+}
                  :type :user
                  :params [{:label "name"} {:label "path"}]
                  :reaction (fn [this skins name path]
                              (assoc skins name (plugins/adjust-path path))))

;;**********************************************************
;; themes
