0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

Update gap

This commit is contained in:
Florian Schroedl 2024-07-23 11:35:07 +02:00
parent 4cf8b2c143
commit bad9056d54

View file

@ -25,7 +25,7 @@
[app.main.ui.workspace.tokens.token :as wtt] [app.main.ui.workspace.tokens.token :as wtt]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.timers :as timers] [app.util.timers :as timers]
[clojure.set :as set] [clojure.set :as set :refer [rename-keys]]
[okulary.core :as l] [okulary.core :as l]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
@ -140,11 +140,10 @@
(defn update-layout-spacing [value shape-ids attributes] (defn update-layout-spacing [value shape-ids attributes]
(if-let [layout-gap (cond (if-let [layout-gap (cond
(:row-gap attributes) {:row-gap value} (:row-gap attributes) {:row-gap value}
(:column-gap attributes) {:column-gap value})] (:column-gap attributes) {:column-gap value})]
(st/emit! (dwsl/update-layout shape-ids {:layout-gap layout-gap})) (dwsl/update-layout shape-ids {:layout-gap layout-gap})
(st/emit! (dwsl/update-layout shape-ids {:layout-padding (zipmap attributes (repeat value))})))) (dwsl/update-layout shape-ids {:layout-padding (zipmap attributes (repeat value))})))
(defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attributes] (defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attributes]
(let [token (dt/get-token-data-from-token-id token-id) (let [token (dt/get-token-data-from-token-id token-id)
@ -259,6 +258,7 @@
(defn gap-attribute-actions [{:keys [token-id selected-shapes] :as _props}] (defn gap-attribute-actions [{:keys [token-id selected-shapes] :as _props}]
(let [token {:id token-id} (let [token {:id token-id}
on-update-shape update-layout-spacing
gap-attrs (:gap spacing) gap-attrs (:gap spacing)
all-gap-attrs (into #{} (keys gap-attrs)) all-gap-attrs (into #{} (keys gap-attrs))
{:keys [all-selected? selected-pred shape-ids]} (attribute-actions token selected-shapes all-gap-attrs) {:keys [all-selected? selected-pred shape-ids]} (attribute-actions token selected-shapes all-gap-attrs)
@ -269,7 +269,7 @@
:selected? all-selected? :selected? all-selected?
:action #(if all-selected? :action #(if all-selected?
(st/emit! (wtc/unapply-token props)) (st/emit! (wtc/unapply-token props))
(st/emit! (wtc/apply-token (assoc props :on-update-shape wtc/update-shape-radius-all))))}]) (st/emit! (wtc/apply-token (assoc props :on-update-shape on-update-shape))))}])
single-gap (->> gap-attrs single-gap (->> gap-attrs
(map (fn [[attr title]] (map (fn [[attr title]]
(let [selected? (selected-pred attr)] (let [selected? (selected-pred attr)]
@ -279,10 +279,10 @@
:token token :token token
:shape-ids shape-ids} :shape-ids shape-ids}
event (cond event (cond
all-selected? (-> (assoc props :attributes-to-remove #{:r1 :r2 :r3 :r4 :rx :ry}) all-selected? (-> (assoc props :attributes-to-remove #{:row-gap :column-gap})
(wtc/apply-token)) (wtc/apply-token))
selected? (wtc/unapply-token props) selected? (wtc/unapply-token props)
:else (-> (assoc props :on-update-shape wtc/update-shape-radius-single-corner) :else (-> (assoc props :on-update-shape on-update-shape)
(wtc/apply-token)))] (wtc/apply-token)))]
(st/emit! event))}))) (st/emit! event))})))
(into))] (into))]