diff --git a/frontend/src/app/plugins/events.cljs b/frontend/src/app/plugins/events.cljs index babbe590c..ae1d17bd0 100644 --- a/frontend/src/app/plugins/events.cljs +++ b/frontend/src/app/plugins/events.cljs @@ -49,7 +49,10 @@ new-theme (get-in new-val [:profile :theme])] (if (identical? old-theme new-theme) ::not-changed - new-theme))) + (if (= new-theme "default") + "dark" + new-theme)))) + (defmethod handle-state-change :default [_ _ _] diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index e56373a40..43b6db02c 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -8,36 +8,59 @@ "RPC for plugins runtime." (:require [app.common.data :as d] - [app.common.data.macros :as dm] [app.common.record :as crc] [app.plugins.utils :as utils] + [app.util.object :as obj] [cuerdas.core :as str])) -(defn- fills - [shape] +(defn- make-fills + [fills] ;; TODO: Transform explicitly? (apply array - (->> (:fills shape) + (->> fills (map #(clj->js % {:keyword-fn (fn [k] (str/camel (name k)))}))))) -(deftype ShapeProxy - [id - name - type - fills - _data]) +(deftype ShapeProxy [_data] + Object + (clone [_] (.log js/console (clj->js _data))) + (delete [_] (.log js/console (clj->js _data))) + (appendChild [_] (.log js/console (clj->js _data)))) (crc/define-properties! ShapeProxy {:name js/Symbol.toStringTag :get (fn [] (str "ShapeProxy"))}) + +(defn get-data + ([this attr] + (-> this + (obj/get "_data") + (get attr))) + ([this attr transform-fn] + (-> this + (get-data attr) + (transform-fn)))) + (defn data->shape-proxy [data] - (utils/hide-data! - (->ShapeProxy (dm/str (:id data)) - (:name data) - (d/name (:type data)) - (fills data) - data))) + + (-> (->ShapeProxy data) + (js/Object.defineProperties + #js {"_data" #js {:enumerable false} + + :id + #js {:get #(get-data (js* "this") :id str) + :enumerable true} + + :name + #js {:get #(get-data (js* "this") :name) + ;;:set (fn [] (prn "SET NAME")) + :enumerable true} + + :fills + #js {:get #(get-data (js* "this") :fills make-fills) + ;;:set (fn [] (prn "SET FILLS")) + :enumerable true}} + )))