mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 18:18:24 -05:00
💄 Cosmetic changes
This commit is contained in:
parent
870eff5826
commit
a42d87742f
5 changed files with 89 additions and 83 deletions
|
@ -537,7 +537,7 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:workspace-libraries file-id]
|
(update-in [:workspace-libraries file-id]
|
||||||
#(assoc % :modified-at modified-at :revn revn))
|
assoc :modified-at modified-at :revn revn)
|
||||||
(d/update-in-when [:workspace-libraries file-id :data]
|
(d/update-in-when [:workspace-libraries file-id :data]
|
||||||
cp/process-changes changes)))))
|
cp/process-changes changes)))))
|
||||||
|
|
||||||
|
@ -571,7 +571,10 @@
|
||||||
(defn update-component
|
(defn update-component
|
||||||
"Modify the component linked to the shape with the given id, in the current page, so that
|
"Modify the component linked to the shape with the given id, in the current page, so that
|
||||||
all attributes of its shapes are equal to the shape and its children. Also set all attributes
|
all attributes of its shapes are equal to the shape and its children. Also set all attributes
|
||||||
of the shape untouched."
|
of the shape untouched.
|
||||||
|
|
||||||
|
NOTE: It's possible that the component to update is defined in an external library file, so
|
||||||
|
this function may cause to modify a file different of that the one we are currently editing."
|
||||||
[id]
|
[id]
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::update-component
|
(ptk/reify ::update-component
|
||||||
|
@ -593,22 +596,19 @@
|
||||||
file-id (:component-file shape)
|
file-id (:component-file shape)
|
||||||
file (dwlh/get-file state file-id)
|
file (dwlh/get-file state file-id)
|
||||||
|
|
||||||
local-rchanges (->> rchanges
|
xf-filter (comp
|
||||||
(filter :local-change?)
|
(filter :local-change?)
|
||||||
(map #(dissoc % :local-change?))
|
(map #(dissoc % :local-change?)))
|
||||||
vec)
|
|
||||||
local-uchanges (->> uchanges
|
local-rchanges (into [] xf-filter rchanges)
|
||||||
(filter :local-change?)
|
local-uchanges (into [] xf-filter uchanges)
|
||||||
(map #(dissoc % :local-change?))
|
|
||||||
vec)
|
xf-remove (comp
|
||||||
rchanges (->> rchanges
|
(remove :local-change?)
|
||||||
(remove :local-change?)
|
(map #(dissoc % :local-change?)))
|
||||||
(map #(dissoc % :local-change?))
|
|
||||||
vec)
|
rchanges (into [] xf-remove rchanges)
|
||||||
uchanges (->> uchanges
|
uchanges (into [] xf-remove uchanges)]
|
||||||
(remove :local-change?)
|
|
||||||
(map #(dissoc % :local-change?))
|
|
||||||
vec)]
|
|
||||||
|
|
||||||
(log/debug :msg "UPDATE-COMPONENT finished"
|
(log/debug :msg "UPDATE-COMPONENT finished"
|
||||||
:js/local-rchanges (log-changes
|
:js/local-rchanges (log-changes
|
||||||
|
@ -656,12 +656,17 @@
|
||||||
file-changes [(dwlh/generate-sync-file file-id :components library-id state)
|
file-changes [(dwlh/generate-sync-file file-id :components library-id state)
|
||||||
(dwlh/generate-sync-file file-id :colors library-id state)
|
(dwlh/generate-sync-file file-id :colors library-id state)
|
||||||
(dwlh/generate-sync-file file-id :typographies library-id state)]
|
(dwlh/generate-sync-file file-id :typographies library-id state)]
|
||||||
|
|
||||||
|
xf-fcat (comp (remove nil?) (map first) (mapcat identity))
|
||||||
rchanges (d/concat []
|
rchanges (d/concat []
|
||||||
(->> library-changes (remove nil?) (map first) (flatten))
|
(sequence xf-fcat library-changes)
|
||||||
(->> file-changes (remove nil?) (map first) (flatten)))
|
(sequence xf-fcat file-changes))
|
||||||
|
|
||||||
|
xf-scat (comp (remove nil?) (map second) (mapcat identity))
|
||||||
uchanges (d/concat []
|
uchanges (d/concat []
|
||||||
(->> library-changes (remove nil?) (map second) (flatten))
|
(sequence xf-scat library-changes)
|
||||||
(->> file-changes (remove nil?) (map second) (flatten)))]
|
(sequence xf-scat file-changes))]
|
||||||
|
|
||||||
(log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes
|
(log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes
|
||||||
rchanges
|
rchanges
|
||||||
file))
|
file))
|
||||||
|
@ -674,6 +679,9 @@
|
||||||
;; When we have just updated the library file, give some time for the
|
;; When we have just updated the library file, give some time for the
|
||||||
;; update to finish, before marking this file as synced.
|
;; update to finish, before marking this file as synced.
|
||||||
;; TODO: look for a more precise way of syncing this.
|
;; TODO: look for a more precise way of syncing this.
|
||||||
|
;; Maybe by using the stream (second argument passed to watch)
|
||||||
|
;; to wait for the corresponding changes-commited and then proced
|
||||||
|
;; with the :update-sync mutation.
|
||||||
(rx/concat (rx/timer 3000)
|
(rx/concat (rx/timer 3000)
|
||||||
(rp/mutation :update-sync
|
(rp/mutation :update-sync
|
||||||
{:file-id file-id
|
{:file-id file-id
|
||||||
|
|
|
@ -714,8 +714,8 @@
|
||||||
(= (:id change) (:id shape-inst))
|
(= (:id change) (:id shape-inst))
|
||||||
(assoc :local-change? true)))
|
(assoc :local-change? true)))
|
||||||
|
|
||||||
rchanges (vec (map check-local rchanges))
|
rchanges (mapv check-local rchanges)
|
||||||
uchanges (vec (map check-local uchanges))]
|
uchanges (mapv check-local uchanges)]
|
||||||
|
|
||||||
[(d/concat rchanges child-rchanges)
|
[(d/concat rchanges child-rchanges)
|
||||||
(d/concat uchanges child-uchanges)]))
|
(d/concat uchanges child-uchanges)]))
|
||||||
|
|
|
@ -55,12 +55,12 @@
|
||||||
(rx/debounce 2000)
|
(rx/debounce 2000)
|
||||||
(rx/merge stoper forcer))
|
(rx/merge stoper forcer))
|
||||||
|
|
||||||
local-file? #(let [event-file-id (:file-id %)]
|
local-file? #(as-> (:file-id %) event-file-id
|
||||||
(or (nil? event-file-id)
|
(or (nil? event-file-id)
|
||||||
(= event-file-id file-id)))
|
(= event-file-id file-id)))
|
||||||
library-file? #(let [event-file-id (:file-id %)]
|
library-file? #(as-> (:file-id %) event-file-id
|
||||||
(and (some? event-file-id)
|
(and (some? event-file-id)
|
||||||
(not= event-file-id file-id)))
|
(not= event-file-id file-id)))
|
||||||
|
|
||||||
on-dirty
|
on-dirty
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -189,12 +189,11 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(if (= file-id (:current-file-id state))
|
(if (= file-id (:current-file-id state))
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:workspace-file :revn] #(max % revn))
|
(update-in [:workspace-file :revn] max revn)
|
||||||
(update :workspace-data cp/process-changes changes)
|
(update :workspace-data cp/process-changes changes)
|
||||||
(update-in [:workspace-file :data] cp/process-changes changes))
|
(update-in [:workspace-file :data] cp/process-changes changes))
|
||||||
(-> state
|
(-> state
|
||||||
(update-in state [:workspace-libraries file-id :revn]
|
(update-in state [:workspace-libraries file-id :revn] max revn)
|
||||||
#(max % revn))
|
|
||||||
(update-in [:workspace-libraries file-id :data]
|
(update-in [:workspace-libraries file-id :data]
|
||||||
cp/process-changes changes))))))
|
cp/process-changes changes))))))
|
||||||
|
|
||||||
|
|
|
@ -54,38 +54,37 @@
|
||||||
|
|
||||||
current-file-id (mf/use-ctx ctx/current-file-id)
|
current-file-id (mf/use-ctx ctx/current-file-id)
|
||||||
|
|
||||||
do-duplicate #(st/emit! dw/duplicate-selected)
|
do-duplicate (st/emitf dw/duplicate-selected)
|
||||||
do-delete #(st/emit! dw/delete-selected)
|
do-delete (st/emitf dw/delete-selected)
|
||||||
do-copy #(st/emit! (dw/copy-selected))
|
do-copy (st/emitf (dw/copy-selected))
|
||||||
do-cut #(st/emit! (dw/copy-selected) dw/delete-selected)
|
do-cut (st/emitf (dw/copy-selected) dw/delete-selected)
|
||||||
do-paste #(st/emit! dw/paste)
|
do-paste (st/emitf dw/paste)
|
||||||
do-bring-forward #(st/emit! (dw/vertical-order-selected :up))
|
do-bring-forward (st/emitf (dw/vertical-order-selected :up))
|
||||||
do-bring-to-front #(st/emit! (dw/vertical-order-selected :top))
|
do-bring-to-front (st/emitf (dw/vertical-order-selected :top))
|
||||||
do-send-backward #(st/emit! (dw/vertical-order-selected :down))
|
do-send-backward (st/emitf (dw/vertical-order-selected :down))
|
||||||
do-send-to-back #(st/emit! (dw/vertical-order-selected :bottom))
|
do-send-to-back (st/emitf (dw/vertical-order-selected :bottom))
|
||||||
do-show-shape #(st/emit! (dw/update-shape-flags id {:hidden false}))
|
do-show-shape (st/emitf (dw/update-shape-flags id {:hidden false}))
|
||||||
do-hide-shape #(st/emit! (dw/update-shape-flags id {:hidden true}))
|
do-hide-shape (st/emitf (dw/update-shape-flags id {:hidden true}))
|
||||||
do-lock-shape #(st/emit! (dw/update-shape-flags id {:blocked true}))
|
do-lock-shape (st/emitf (dw/update-shape-flags id {:blocked true}))
|
||||||
do-unlock-shape #(st/emit! (dw/update-shape-flags id {:blocked false}))
|
do-unlock-shape (st/emitf (dw/update-shape-flags id {:blocked false}))
|
||||||
do-create-group #(st/emit! dw/group-selected)
|
do-create-group (st/emitf dw/group-selected)
|
||||||
do-remove-group #(st/emit! dw/ungroup-selected)
|
do-remove-group (st/emitf dw/ungroup-selected)
|
||||||
do-mask-group #(st/emit! dw/mask-group)
|
do-mask-group (st/emitf dw/mask-group)
|
||||||
do-unmask-group #(st/emit! dw/unmask-group)
|
do-unmask-group (st/emitf dw/unmask-group)
|
||||||
do-add-component #(st/emit! dwl/add-component)
|
do-add-component (st/emitf dwl/add-component)
|
||||||
do-detach-component #(st/emit! (dwl/detach-component id))
|
do-detach-component (st/emitf (dwl/detach-component id))
|
||||||
do-reset-component #(st/emit! (dwl/reset-component id))
|
do-reset-component (st/emitf (dwl/reset-component id))
|
||||||
do-update-component #(do
|
do-update-component (st/emitf
|
||||||
(st/emit! (dwc/start-undo-transaction))
|
(dwc/start-undo-transaction)
|
||||||
(st/emit! (dwl/update-component id))
|
(dwl/update-component id)
|
||||||
(st/emit! (dwl/sync-file current-file-id
|
(dwl/sync-file current-file-id (:component-file shape))
|
||||||
(:component-file shape)))
|
(dwc/commit-undo-transaction))
|
||||||
(st/emit! (dwc/commit-undo-transaction)))
|
confirm-update-remote-component (st/emitf
|
||||||
confirm-update-remote-component #(do
|
(dwl/update-component id)
|
||||||
(st/emit! (dwl/update-component id))
|
(dwl/sync-file current-file-id
|
||||||
(st/emit! (dwl/sync-file current-file-id
|
(:component-file shape))
|
||||||
(:component-file shape)))
|
(dwl/sync-file (:component-file shape)
|
||||||
(st/emit! (dwl/sync-file (:component-file shape)
|
(:component-file shape)))
|
||||||
(:component-file shape))))
|
|
||||||
do-update-remote-component (st/emitf (modal/show
|
do-update-remote-component (st/emitf (modal/show
|
||||||
{:type :confirm
|
{:type :confirm
|
||||||
:message ""
|
:message ""
|
||||||
|
@ -95,9 +94,9 @@
|
||||||
:accept-label (t locale "modals.update-remote-component.accept")
|
:accept-label (t locale "modals.update-remote-component.accept")
|
||||||
:accept-style :primary
|
:accept-style :primary
|
||||||
:on-accept confirm-update-remote-component}))
|
:on-accept confirm-update-remote-component}))
|
||||||
do-show-component #(st/emit! (dw/go-to-layout :assets))
|
do-show-component (st/emitf (dw/go-to-layout :assets))
|
||||||
do-navigate-component-file #(st/emit! (dwl/nav-to-component-file
|
do-navigate-component-file (st/emitf (dwl/nav-to-component-file
|
||||||
(:component-file shape)))]
|
(:component-file shape)))]
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.copy")
|
[:& menu-entry {:title (t locale "workspace.shape.menu.copy")
|
||||||
:shortcut "Ctrl + c"
|
:shortcut "Ctrl + c"
|
||||||
|
@ -204,7 +203,7 @@
|
||||||
(mf/defc viewport-context-menu
|
(mf/defc viewport-context-menu
|
||||||
[{:keys [mdata] :as props}]
|
[{:keys [mdata] :as props}]
|
||||||
(let [locale (mf/deref i18n/locale)
|
(let [locale (mf/deref i18n/locale)
|
||||||
do-paste #(st/emit! dw/paste)]
|
do-paste (st/emitf dw/paste)]
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.paste")
|
[:& menu-entry {:title (t locale "workspace.shape.menu.paste")
|
||||||
:shortcut "Ctrl + v"
|
:shortcut "Ctrl + v"
|
||||||
|
@ -231,7 +230,7 @@
|
||||||
(.setAttribute ^js dropdown "style" new-style))))))
|
(.setAttribute ^js dropdown "style" new-style))))))
|
||||||
|
|
||||||
[:& dropdown {:show (boolean mdata)
|
[:& dropdown {:show (boolean mdata)
|
||||||
:on-close #(st/emit! dw/hide-context-menu)}
|
:on-close (st/emitf dw/hide-context-menu)}
|
||||||
[:ul.workspace-context-menu
|
[:ul.workspace-context-menu
|
||||||
{:ref dropdown-ref
|
{:ref dropdown-ref
|
||||||
:style {:top top :left left}
|
:style {:top top :left left}
|
||||||
|
|
|
@ -50,19 +50,19 @@
|
||||||
on-menu-close (mf/use-callback
|
on-menu-close (mf/use-callback
|
||||||
#(swap! local assoc :menu-open false))
|
#(swap! local assoc :menu-open false))
|
||||||
|
|
||||||
do-detach-component #(st/emit! (dwl/detach-component id))
|
do-detach-component (st/emitf (dwl/detach-component id))
|
||||||
do-reset-component #(st/emit! (dwl/reset-component id))
|
do-reset-component (st/emitf (dwl/reset-component id))
|
||||||
do-update-component #(do
|
do-update-component (st/emitf
|
||||||
(st/emit! (dwc/start-undo-transaction))
|
(dwc/start-undo-transaction)
|
||||||
(st/emit! (dwl/update-component id))
|
(dwl/update-component id)
|
||||||
(st/emit! (dwl/sync-file current-file-id current-file-id))
|
(dwl/sync-file current-file-id current-file-id)
|
||||||
(st/emit! (dwc/commit-undo-transaction)))
|
(dwc/commit-undo-transaction))
|
||||||
confirm-update-remote-component #(do
|
confirm-update-remote-component (st/emitf
|
||||||
(st/emit! (dwl/update-component id))
|
(dwl/update-component id)
|
||||||
(st/emit! (dwl/sync-file current-file-id
|
(dwl/sync-file current-file-id
|
||||||
(:component-file values)))
|
(:component-file values))
|
||||||
(st/emit! (dwl/sync-file (:component-file values)
|
(dwl/sync-file (:component-file values)
|
||||||
(:component-file values))))
|
(:component-file values)))
|
||||||
do-update-remote-component (st/emitf (modal/show
|
do-update-remote-component (st/emitf (modal/show
|
||||||
{:type :confirm
|
{:type :confirm
|
||||||
:message ""
|
:message ""
|
||||||
|
@ -72,8 +72,8 @@
|
||||||
:accept-label (t locale "modals.update-remote-component.accept")
|
:accept-label (t locale "modals.update-remote-component.accept")
|
||||||
:accept-style :primary
|
:accept-style :primary
|
||||||
:on-accept confirm-update-remote-component}))
|
:on-accept confirm-update-remote-component}))
|
||||||
do-show-component #(st/emit! (dw/go-to-layout :assets))
|
do-show-component (st/emitf (dw/go-to-layout :assets))
|
||||||
do-navigate-component-file #(st/emit! (dwl/nav-to-component-file
|
do-navigate-component-file (st/emitf (dwl/nav-to-component-file
|
||||||
(:component-file values)))]
|
(:component-file values)))]
|
||||||
(when show?
|
(when show?
|
||||||
[:div.element-set
|
[:div.element-set
|
||||||
|
|
Loading…
Add table
Reference in a new issue