diff --git a/frontend/src/app/main/ui/workspace/tokens/common.cljs b/frontend/src/app/main/ui/workspace/tokens/common.cljs index ea0b8bc65..e81c93999 100644 --- a/frontend/src/app/main/ui/workspace/tokens/common.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/common.cljs @@ -19,20 +19,10 @@ [cuerdas.core :as str] [goog.events :as events] [rumext.v2 :as mf]) - (:import - goog.events.EventType)) + (:import goog.events.EventType)) ;; Helpers --------------------------------------------------------------------- -(defn workspace-shapes [workspace page-id shape-ids] - (-> (get-in workspace [:pages-index page-id :objects]) - (keep shape-ids))) - -(defn vec-remove - "remove elem in coll" - [pos coll] - (into (subvec coll 0 pos) (subvec coll (inc pos)))) - (defn camel-keys [m] (->> m (d/deep-mapm diff --git a/frontend/src/app/main/ui/workspace/tokens/form.cljs b/frontend/src/app/main/ui/workspace/tokens/form.cljs index b202c3ac8..8f19159c4 100644 --- a/frontend/src/app/main/ui/workspace/tokens/form.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/form.cljs @@ -203,8 +203,9 @@ Token names should only contain letters and digits separated by . characters.")} color? (wtt/color-token? token) selected-set-tokens (mf/deref refs/workspace-selected-token-set-tokens) active-theme-tokens (mf/deref refs/workspace-active-theme-sets-tokens) - resolved-tokens (sd/use-resolved-tokens active-theme-tokens {:names-map? true - :cache-atom form-token-cache-atom}) + resolved-tokens (sd/use-resolved-tokens (vals active-theme-tokens) {:names-map? true + :cache-atom form-token-cache-atom}) + _ (js/console.log "resolved-tokens" resolved-tokens) token-path (mf/use-memo (mf/deps (:name token)) #(wtt/token-name->path (:name token))) diff --git a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs index 4e44c1415..bb67de78b 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs @@ -10,7 +10,6 @@ [app.common.data :as d] [app.main.data.modal :as modal] [app.main.data.tokens :as dt] - [app.main.data.tokens :as wdt] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.components.color-bullet :refer [color-bullet]] @@ -19,7 +18,6 @@ [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.assets.common :as cmm] [app.main.ui.workspace.tokens.changes :as wtch] - [app.main.ui.workspace.tokens.common :refer [labeled-input]] [app.main.ui.workspace.tokens.context-menu :refer [token-context-menu]] [app.main.ui.workspace.tokens.core :as wtc] [app.main.ui.workspace.tokens.sets :refer [sets-list]] @@ -42,15 +40,6 @@ (def ^:private download-icon (i/icon-xref :download (stl/css :download-icon))) -(def selected-set-id - (l/derived :selected-set-id st/state)) - - ;; Event Functions ------------------------------------------------------------- - -(defn on-set-add-click [_event] - (when-let [set-name (js/window.prompt "Set name")] - (st/emit! (wdt/create-token-set {:name set-name})))) - ;; Components ------------------------------------------------------------------ (mf/defc token-pill @@ -173,23 +162,6 @@ {:empty (sort-by :token-key empty) :filled (sort-by :token-key filled)})) -(mf/defc tokene-theme-create - [_props] - (let [group (mf/use-state "") - name (mf/use-state "")] - [:div {:style {:display "flex" - :flex-direction "column" - :gap "10px"}} - [:& labeled-input {:label "Group name" - :input-props {:value @group - :on-change #(reset! group (dom/event->value %))}}] - [:& labeled-input {:label "Theme name" - :input-props {:value @name - :on-change #(reset! name (dom/event->value %))}}] - [:button {:on-click #(st/emit! (wdt/create-token-theme {:group @group - :name @name}))} - "Create"]])) - (mf/defc edit-button [{:keys [create?]}] [:button {:class (stl/css :themes-button) diff --git a/frontend/src/app/main/ui/workspace/tokens/token.cljs b/frontend/src/app/main/ui/workspace/tokens/token.cljs index 9c097b180..6a7448195 100644 --- a/frontend/src/app/main/ui/workspace/tokens/token.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/token.cljs @@ -6,10 +6,6 @@ [clojure.set :as set] [cuerdas.core :as str])) -(defn get-workspace-tokens - [state] - (get-in state [:workspace-data :tokens] {})) - (defn get-workspace-token [token-id state] (get-in state [:workspace-data :tokens token-id])) @@ -67,12 +63,6 @@ [token shape token-attributes] (some #(token-attribute-applied? token shape %) token-attributes)) -(defn token-applied-attributes - "Return a set of which `token-attributes` are applied with `token`." - [token shape token-attributes] - (-> (filter #(token-attribute-applied? token shape %) token-attributes) - (set))) - (defn shapes-token-applied? "Test if `token` is applied to to any of `shapes` with at least one of the one of the given `token-attributes`." [token shapes token-attributes] @@ -120,6 +110,12 @@ (defonce a (atom nil)) +(comment + + (token-names-tree-id-map @a) + nil) + + (defn token-names-tree-id-map [tokens] (reset! a tokens) (reduce