mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 09:16:10 +02:00
💄 Minor cosmetic changes on workspace.
This commit is contained in:
parent
24f2f3b677
commit
ee0cda67c1
2 changed files with 31 additions and 82 deletions
|
@ -39,7 +39,7 @@
|
||||||
[uxbox.util.transit :as t]
|
[uxbox.util.transit :as t]
|
||||||
[uxbox.util.webapi :as wapi]
|
[uxbox.util.webapi :as wapi]
|
||||||
[uxbox.util.avatars :as avatars]
|
[uxbox.util.avatars :as avatars]
|
||||||
[uxbox.main.data.workspace.common :refer [IBatchedChange IUpdateGroup] :as common]
|
[uxbox.main.data.workspace.common :as dwc]
|
||||||
[uxbox.main.data.workspace.transforms :as transforms]))
|
[uxbox.main.data.workspace.transforms :as transforms]))
|
||||||
|
|
||||||
;; TODO: temporal workaround
|
;; TODO: temporal workaround
|
||||||
|
@ -198,13 +198,13 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter #(satisfies? IUpdateGroup %))
|
(rx/filter #(satisfies? dwc/IUpdateGroup %))
|
||||||
(rx/map #(adjust-group-shapes (common/get-ids %)))))))
|
(rx/map #(adjust-group-shapes (dwc/get-ids %)))))))
|
||||||
|
|
||||||
(defn adjust-group-shapes
|
(defn adjust-group-shapes
|
||||||
[ids]
|
[ids]
|
||||||
(ptk/reify ::adjust-group-shapes
|
(ptk/reify ::adjust-group-shapes
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
|
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
@ -395,12 +395,12 @@
|
||||||
(ptk/type? ::initialize-page %))
|
(ptk/type? ::initialize-page %))
|
||||||
stream)
|
stream)
|
||||||
notifier (->> stream
|
notifier (->> stream
|
||||||
(rx/filter (ptk/type? ::common/commit-changes))
|
(rx/filter (ptk/type? ::dwc/commit-changes))
|
||||||
(rx/debounce 2000)
|
(rx/debounce 2000)
|
||||||
(rx/merge stoper))]
|
(rx/merge stoper))]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter (ptk/type? ::common/commit-changes))
|
(rx/filter (ptk/type? ::dwc/commit-changes))
|
||||||
(rx/map deref)
|
(rx/map deref)
|
||||||
(rx/buffer-until notifier)
|
(rx/buffer-until notifier)
|
||||||
(rx/map vec)
|
(rx/map vec)
|
||||||
|
@ -408,9 +408,9 @@
|
||||||
(rx/map #(persist-changes page-id %))
|
(rx/map #(persist-changes page-id %))
|
||||||
(rx/take-until (rx/delay 100 stoper)))
|
(rx/take-until (rx/delay 100 stoper)))
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter #(satisfies? IBatchedChange %))
|
(rx/filter #(satisfies? dwc/IBatchedChange %))
|
||||||
(rx/debounce 200)
|
(rx/debounce 200)
|
||||||
(rx/map (fn [_] (common/diff-and-commit-changes page-id)))
|
(rx/map (fn [_] (dwc/diff-and-commit-changes page-id)))
|
||||||
(rx/take-until stoper)))))))
|
(rx/take-until stoper)))))))
|
||||||
|
|
||||||
(defn persist-changes
|
(defn persist-changes
|
||||||
|
@ -892,7 +892,7 @@
|
||||||
|
|
||||||
frame-id (if (= :frame (:type shape))
|
frame-id (if (= :frame (:type shape))
|
||||||
uuid/zero
|
uuid/zero
|
||||||
(common/calculate-frame-overlap objects shape))
|
(dwc/calculate-frame-overlap objects shape))
|
||||||
|
|
||||||
shape (merge
|
shape (merge
|
||||||
(if (= :frame (:type shape))
|
(if (= :frame (:type shape))
|
||||||
|
@ -910,7 +910,7 @@
|
||||||
uchange {:type :del-obj
|
uchange {:type :del-obj
|
||||||
:id id}]
|
:id id}]
|
||||||
|
|
||||||
(rx/of (common/commit-changes [rchange] [uchange] {:commit-local? true})
|
(rx/of (dwc/commit-changes [rchange] [uchange] {:commit-local? true})
|
||||||
(select-shapes #{id}))))))
|
(select-shapes #{id}))))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -957,7 +957,7 @@
|
||||||
moved-obj (geom/move renamed-obj delta)
|
moved-obj (geom/move renamed-obj delta)
|
||||||
frame-id (if frame-id
|
frame-id (if frame-id
|
||||||
frame-id
|
frame-id
|
||||||
(common/calculate-frame-overlap objects moved-obj))
|
(dwc/calculate-frame-overlap objects moved-obj))
|
||||||
|
|
||||||
parent-id (or parent-id frame-id)
|
parent-id (or parent-id frame-id)
|
||||||
|
|
||||||
|
@ -1031,7 +1031,7 @@
|
||||||
(map #(get-in % [:obj :id]))
|
(map #(get-in % [:obj :id]))
|
||||||
(into #{}))]
|
(into #{}))]
|
||||||
|
|
||||||
(rx/of (common/commit-changes rchanges uchanges {:commit-local? true})
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})
|
||||||
(select-shapes selected))))))
|
(select-shapes selected))))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1071,8 +1071,8 @@
|
||||||
(us/verify ::us/uuid id)
|
(us/verify ::us/uuid id)
|
||||||
(us/verify ::shape-attrs attrs)
|
(us/verify ::shape-attrs attrs)
|
||||||
(ptk/reify ::update-shape
|
(ptk/reify ::update-shape
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
IUpdateGroup
|
dwc/IUpdateGroup
|
||||||
(get-ids [_] [id])
|
(get-ids [_] [id])
|
||||||
|
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
|
@ -1086,7 +1086,7 @@
|
||||||
[opts]
|
[opts]
|
||||||
(us/verify ::cp/options opts)
|
(us/verify ::cp/options opts)
|
||||||
(ptk/reify ::update-options
|
(ptk/reify ::update-options
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [pid (:current-page-id state)]
|
(let [pid (:current-page-id state)]
|
||||||
|
@ -1166,7 +1166,7 @@
|
||||||
:parent-id (get cpindex id)
|
:parent-id (get cpindex id)
|
||||||
:obj obj}))
|
:obj obj}))
|
||||||
(reverse (map :id rchanges)))]
|
(reverse (map :id rchanges)))]
|
||||||
(rx/of (common/commit-changes rchanges uchanges {:commit-local? true}))))))
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))
|
||||||
|
|
||||||
(def delete-selected
|
(def delete-selected
|
||||||
"Deselect all and remove all selected shapes."
|
"Deselect all and remove all selected shapes."
|
||||||
|
@ -1189,7 +1189,7 @@
|
||||||
(us/verify ::us/uuid id)
|
(us/verify ::us/uuid id)
|
||||||
(us/verify string? name)
|
(us/verify string? name)
|
||||||
(ptk/reify ::rename-shape
|
(ptk/reify ::rename-shape
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (:current-page-id state)]
|
(let [page-id (:current-page-id state)]
|
||||||
|
@ -1221,7 +1221,7 @@
|
||||||
:id frame-id
|
:id frame-id
|
||||||
:operations [{:type :abs-order :id id :index cindex}]}))
|
:operations [{:type :abs-order :id id :index cindex}]}))
|
||||||
selected)]
|
selected)]
|
||||||
(rx/of (common/commit-changes rchanges uchanges {:commit-local? true}))))))
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Change Shape Order (D&D Ordering)
|
;; --- Change Shape Order (D&D Ordering)
|
||||||
|
@ -1244,7 +1244,7 @@
|
||||||
selected (get-in state [:workspace-local :selected])
|
selected (get-in state [:workspace-local :selected])
|
||||||
objects (get-in state [:workspace-data page-id :objects])
|
objects (get-in state [:workspace-data page-id :objects])
|
||||||
parent-id (helpers/get-parent ref-id objects)]
|
parent-id (helpers/get-parent ref-id objects)]
|
||||||
(rx/of (common/commit-changes [{:type :mov-objects
|
(rx/of (dwc/commit-changes [{:type :mov-objects
|
||||||
:parent-id parent-id
|
:parent-id parent-id
|
||||||
:index index
|
:index index
|
||||||
:shapes (vec selected)}]
|
:shapes (vec selected)}]
|
||||||
|
@ -1283,7 +1283,7 @@
|
||||||
[axis]
|
[axis]
|
||||||
(us/verify ::geom/align-axis axis)
|
(us/verify ::geom/align-axis axis)
|
||||||
(ptk/reify :align-objects
|
(ptk/reify :align-objects
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
|
@ -1311,7 +1311,7 @@
|
||||||
[axis]
|
[axis]
|
||||||
(us/verify ::geom/dist-axis axis)
|
(us/verify ::geom/dist-axis axis)
|
||||||
(ptk/reify :align-objects
|
(ptk/reify :align-objects
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
|
@ -1400,8 +1400,8 @@
|
||||||
(us/verify #{:width :height} attr)
|
(us/verify #{:width :height} attr)
|
||||||
(us/verify ::us/number value)
|
(us/verify ::us/number value)
|
||||||
(ptk/reify ::update-rect-dimensions
|
(ptk/reify ::update-rect-dimensions
|
||||||
IBatchedChange
|
dwc/IBatchedChange
|
||||||
IUpdateGroup
|
dwc/IUpdateGroup
|
||||||
(get-ids [_] [id])
|
(get-ids [_] [id])
|
||||||
|
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
|
@ -1410,23 +1410,6 @@
|
||||||
(update-in state [:workspace-data page-id :objects id]
|
(update-in state [:workspace-data page-id :objects id]
|
||||||
geom/resize-rect attr value)))))
|
geom/resize-rect attr value)))))
|
||||||
|
|
||||||
(defn update-circle-dimensions
|
|
||||||
[id attr value]
|
|
||||||
(us/verify ::us/uuid id)
|
|
||||||
(us/verify #{:rx :ry} attr)
|
|
||||||
(us/verify ::us/number value)
|
|
||||||
(ptk/reify ::update-rect-dimensions
|
|
||||||
IBatchedChange
|
|
||||||
IUpdateGroup
|
|
||||||
(get-ids [_] [id])
|
|
||||||
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(let [page-id (:current-page-id state)]
|
|
||||||
state
|
|
||||||
#_(update-in state [:workspace-data page-id :objects id]
|
|
||||||
geom/resize-circle attr value)))))
|
|
||||||
|
|
||||||
;; --- Shape Proportions
|
;; --- Shape Proportions
|
||||||
|
|
||||||
(defn toggle-shape-proportion-lock
|
(defn toggle-shape-proportion-lock
|
||||||
|
@ -1650,7 +1633,7 @@
|
||||||
(filter #(selected (:old-id %)))
|
(filter #(selected (:old-id %)))
|
||||||
(map #(get-in % [:obj :id]))
|
(map #(get-in % [:obj :id]))
|
||||||
(into #{}))]
|
(into #{}))]
|
||||||
(rx/of (common/commit-changes rchanges uchanges {:commit-local? true})
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})
|
||||||
(select-shapes selected))))))
|
(select-shapes selected))))))
|
||||||
|
|
||||||
(def paste
|
(def paste
|
||||||
|
@ -1735,7 +1718,7 @@
|
||||||
:shapes (vec selected)}
|
:shapes (vec selected)}
|
||||||
{:type :del-obj
|
{:type :del-obj
|
||||||
:id id}]]
|
:id id}]]
|
||||||
(rx/of (common/commit-changes rchanges uchanges {:commit-local? true})
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})
|
||||||
(select-shapes #{id}))))))))
|
(select-shapes #{id}))))))))
|
||||||
|
|
||||||
(def remove-group
|
(def remove-group
|
||||||
|
@ -1771,7 +1754,7 @@
|
||||||
:parent-id parent-id
|
:parent-id parent-id
|
||||||
:shapes [group-id]
|
:shapes [group-id]
|
||||||
:index index-in-parent}]]
|
:index index-in-parent}]]
|
||||||
(rx/of (common/commit-changes rchanges uchanges {:commit-local? true}))))))))
|
(rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Exports
|
;; Exports
|
||||||
|
@ -1806,10 +1789,10 @@
|
||||||
"shift+1" #(st/emit! reset-zoom)
|
"shift+1" #(st/emit! reset-zoom)
|
||||||
"shift+2" #(st/emit! zoom-to-200)
|
"shift+2" #(st/emit! zoom-to-200)
|
||||||
"ctrl+d" #(st/emit! duplicate-selected)
|
"ctrl+d" #(st/emit! duplicate-selected)
|
||||||
"ctrl+z" #(st/emit! common/undo)
|
"ctrl+z" #(st/emit! dwc/undo)
|
||||||
"ctrl+shift+z" #(st/emit! common/redo)
|
"ctrl+shift+z" #(st/emit! dwc/redo)
|
||||||
"ctrl+y" #(st/emit! common/redo)
|
"ctrl+y" #(st/emit! dwc/redo)
|
||||||
"ctrl+q" #(st/emit! common/reinitialize-undo)
|
"ctrl+q" #(st/emit! dwc/reinitialize-undo)
|
||||||
"ctrl+b" #(st/emit! (select-for-drawing :rect))
|
"ctrl+b" #(st/emit! (select-for-drawing :rect))
|
||||||
"ctrl+e" #(st/emit! (select-for-drawing :circle))
|
"ctrl+e" #(st/emit! (select-for-drawing :circle))
|
||||||
"ctrl+t" #(st/emit! (select-for-drawing :text))
|
"ctrl+t" #(st/emit! (select-for-drawing :text))
|
||||||
|
|
|
@ -60,14 +60,6 @@
|
||||||
(d/parse-integer 0))]
|
(d/parse-integer 0))]
|
||||||
(st/emit! (udw/update-rect-dimensions (:id shape) attr value))))
|
(st/emit! (udw/update-rect-dimensions (:id shape) attr value))))
|
||||||
|
|
||||||
on-circle-size-change
|
|
||||||
(fn [event attr]
|
|
||||||
(let [value (-> (dom/get-target event)
|
|
||||||
(dom/get-value)
|
|
||||||
(d/parse-integer 0)
|
|
||||||
(/ 2))] ; Convert back to radius before update
|
|
||||||
(st/emit! (udw/update-circle-dimensions (:id shape) attr value))))
|
|
||||||
|
|
||||||
on-proportion-lock-change
|
on-proportion-lock-change
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(st/emit! (udw/toggle-shape-proportion-lock (:id shape))))
|
(st/emit! (udw/toggle-shape-proportion-lock (:id shape))))
|
||||||
|
@ -101,9 +93,7 @@
|
||||||
on-width-change #(on-size-change % :width)
|
on-width-change #(on-size-change % :width)
|
||||||
on-height-change #(on-size-change % :height)
|
on-height-change #(on-size-change % :height)
|
||||||
on-pos-x-change #(on-position-change % :x)
|
on-pos-x-change #(on-position-change % :x)
|
||||||
on-pos-y-change #(on-position-change % :y)
|
on-pos-y-change #(on-position-change % :y)]
|
||||||
on-size-rx-change #(on-circle-size-change % :rx)
|
|
||||||
on-size-ry-change #(on-circle-size-change % :ry)]
|
|
||||||
|
|
||||||
[:div.element-set
|
[:div.element-set
|
||||||
[:div.element-set-content
|
[:div.element-set-content
|
||||||
|
@ -136,30 +126,6 @@
|
||||||
(d/coalesce 0)
|
(d/coalesce 0)
|
||||||
(math/round)))}]]])
|
(math/round)))}]]])
|
||||||
|
|
||||||
;; Circle RX RY
|
|
||||||
(when (options :circle-size)
|
|
||||||
[:div.row-flex
|
|
||||||
[:span.element-set-subtitle (t locale "workspace.options.size")]
|
|
||||||
[:div.lock-size {:class (when (:proportion-lock shape) "selected")
|
|
||||||
:on-click on-proportion-lock-change}
|
|
||||||
(if (:proportion-lock shape)
|
|
||||||
i/lock
|
|
||||||
i/unlock)]
|
|
||||||
[:div.input-element.pixels
|
|
||||||
[:input.input-text {:type "number"
|
|
||||||
:min "0"
|
|
||||||
:on-change on-size-rx-change
|
|
||||||
:value (str (-> (* 2 (:rx shape)) ; Show to user diameter and not radius
|
|
||||||
(d/coalesce 0)
|
|
||||||
(math/round)))}]]
|
|
||||||
[:div.input-element.pixels
|
|
||||||
[:input.input-text {:type "number"
|
|
||||||
:min "0"
|
|
||||||
:on-change on-size-ry-change
|
|
||||||
:value (str (-> (* 2 (:ry shape))
|
|
||||||
(d/coalesce 0)
|
|
||||||
(math/round)))}]]])
|
|
||||||
|
|
||||||
;; POSITION
|
;; POSITION
|
||||||
(when (options :position)
|
(when (options :position)
|
||||||
[:div.row-flex
|
[:div.row-flex
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue