From 7564f27f954052c293bc3c610e423fd2d22ee7ff Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 1 Dec 2021 14:39:02 +0100 Subject: [PATCH] :zap: Improvements after review --- common/src/app/common/data.cljc | 2 +- common/src/app/common/geom/shapes/transforms.cljc | 3 +-- common/src/app/common/pages/helpers.cljc | 7 ++++--- .../src/app/main/data/workspace/libraries_helpers.cljs | 2 +- frontend/src/app/main/ui/shapes/export.cljs | 2 +- frontend/src/app/main/ui/workspace/shapes/frame.cljs | 2 +- frontend/src/app/main/ui/workspace/sidebar/assets.cljs | 2 +- .../main/ui/workspace/sidebar/options/menus/shadow.cljs | 2 +- frontend/src/app/util/import/parser.cljs | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index bd0b6044c..47f75a2c3 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -157,7 +157,7 @@ "Return a map without the keys provided in the `keys` parameter." [data keys] - (when (and (some? data) (map? data)) + (when (map? data) (persistent! (reduce #(dissoc! %1 %2) (transient data) keys)))) diff --git a/common/src/app/common/geom/shapes/transforms.cljc b/common/src/app/common/geom/shapes/transforms.cljc index 70391996d..9cec2339f 100644 --- a/common/src/app/common/geom/shapes/transforms.cljc +++ b/common/src/app/common/geom/shapes/transforms.cljc @@ -345,8 +345,7 @@ ;; or not. (defn empty-modifiers? [modifiers] - (or (nil? modifiers) - (empty? (d/without-keys modifiers [:ignore-geometry?])))) + (empty? (dissoc modifiers :ignore-geometry?))) (defn resize-modifiers [shape attr value] diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index e27c8ac5b..a6f4299bb 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -502,6 +502,7 @@ (defn children-seq "Creates a sequence of shapes through the objects tree" [shape objects] - (tree-seq #(d/not-empty? (get shape :shapes)) - #(->> (get % :shapes) (map (partial get objects))) - shape)) + (let [getter (partial get objects)] + (tree-seq #(d/not-empty? (get shape :shapes)) + #(->> (get % :shapes) (map getter)) + shape))) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 48a77a9e9..61a8598e8 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -506,7 +506,7 @@ (let [typographies (get-assets library-id :typographies state) update-node (fn [node] (if-let [typography (get typographies (:typography-ref-id node))] - (merge node (d/without-keys typography [:name :id])) + (merge node (dissoc typography :name :id)) (dissoc node :typography-ref-id :typography-ref-file)))] (generate-sync-text-shape shape container update-node))) diff --git a/frontend/src/app/main/ui/shapes/export.cljs b/frontend/src/app/main/ui/shapes/export.cljs index 45f4b48bd..9f26a0712 100644 --- a/frontend/src/app/main/ui/shapes/export.cljs +++ b/frontend/src/app/main/ui/shapes/export.cljs @@ -133,7 +133,7 @@ [{:keys [grids]}] [:> "penpot:grids" #js {} (for [{:keys [type display params]} grids] - (let [props (->> (d/without-keys params [:color]) + (let [props (->> (dissoc params :color) (prefix-keys) (clj->js))] [:> "penpot:grid" diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index 2637dbf90..5009d926f 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -57,7 +57,7 @@ (let [{:keys [x y width height fill-color] :as shape} (obj/get props "shape")] (if (some? (:thumbnail shape)) [:& thumbnail {:shape shape}] - [:rect {:x x :y y :width width :height height :style {:fill (or fill-color "white")}}]))) + [:rect {:x x :y y :width width :height height :style {:fill (or fill-color "var(--color-white)")}}]))) (defn custom-deferred [component] diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index 71bc1139a..917f4f519 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -1172,7 +1172,7 @@ attrs (merge {:typography-ref-file file-id :typography-ref-id (:id typography)} - (d/without-keys typography [:id :name]))] + (dissoc typography :id :name))] (run! #(st/emit! (dwt/update-text-attrs {:id % :editor (get-in local [:editors %]) :attrs attrs})) ids))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs index a5473dd47..f7e126c70 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs @@ -78,7 +78,7 @@ update-color (fn [index] (fn [color opacity] - (let [color (d/without-keys color [:id :file-id :gradient])] + (let [color (dissoc color :id :file-id :gradient)] (st/emit! (dch/update-shapes ids #(-> % diff --git a/frontend/src/app/util/import/parser.cljs b/frontend/src/app/util/import/parser.cljs index 85e976167..8a51ff871 100644 --- a/frontend/src/app/util/import/parser.cljs +++ b/frontend/src/app/util/import/parser.cljs @@ -483,7 +483,7 @@ color {:color (:color attrs) :opacity (-> attrs :opacity d/parse-double)} - params (-> (d/without-keys attrs [:color :opacity :display :type]) + params (-> (dissoc attrs :color :opacity :display :type) (d/update-when :size d/parse-double) (d/update-when :item-length d/parse-double) (d/update-when :gutter d/parse-double)