mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 08:29:42 -05:00
💄 Add cosmetic changes to several viewer related react components
This commit is contained in:
parent
df2d242746
commit
003dec6c6b
3 changed files with 61 additions and 45 deletions
|
@ -174,8 +174,10 @@
|
||||||
|
|
||||||
|
|
||||||
(mf/defc viewer-wrapper
|
(mf/defc viewer-wrapper
|
||||||
|
{::mf/wrap-props false}
|
||||||
[{:keys [wrapper-size orig-frame orig-viewport-ref orig-size page file users current-viewport-ref
|
[{:keys [wrapper-size orig-frame orig-viewport-ref orig-size page file users current-viewport-ref
|
||||||
size frame interactions-mode overlays zoom section index] :as props}]
|
size frame interactions-mode overlays zoom section index]}]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
[:& viewer-pagination-and-sidebar
|
[:& viewer-pagination-and-sidebar
|
||||||
{:section section
|
{:section section
|
||||||
|
@ -220,12 +222,13 @@
|
||||||
:interactions-mode interactions-mode}]
|
:interactions-mode interactions-mode}]
|
||||||
|
|
||||||
(for [overlay overlays]
|
(for [overlay overlays]
|
||||||
[:& viewer-overlay {:overlay overlay
|
[:& viewer-overlay
|
||||||
:key (dm/str (:id overlay))
|
{:overlay overlay
|
||||||
:page page
|
:key (dm/str (:id overlay))
|
||||||
:frame frame
|
:page page
|
||||||
:zoom zoom
|
:frame frame
|
||||||
:wrapper-size wrapper-size
|
:zoom zoom
|
||||||
|
:wrapper-size wrapper-size
|
||||||
:interactions-mode interactions-mode}])]]
|
:interactions-mode interactions-mode}])]]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,60 +42,72 @@
|
||||||
{::mf/wrap [mf/memo]
|
{::mf/wrap [mf/memo]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [page (unchecked-get props "page")
|
(let [page (unchecked-get props "page")
|
||||||
frame (unchecked-get props "frame")
|
frame (unchecked-get props "frame")
|
||||||
base (unchecked-get props "base")
|
base (unchecked-get props "base")
|
||||||
offset (unchecked-get props "offset")
|
offset (unchecked-get props "offset")
|
||||||
size (unchecked-get props "size")
|
size (unchecked-get props "size")
|
||||||
delta (or (unchecked-get props "delta") (gpt/point 0 0))
|
delta (or (unchecked-get props "delta") (gpt/point 0 0))
|
||||||
|
vbox (:vbox size)
|
||||||
vbox (:vbox size)
|
|
||||||
|
|
||||||
fixed-ids (filter :fixed-scroll (vals (:objects page)))
|
fixed-ids (filter :fixed-scroll (vals (:objects page)))
|
||||||
|
|
||||||
;; we have con consider the children if the fixed element is a group
|
;; we have con consider the children if the fixed element is a group
|
||||||
fixed-children-ids (into #{} (mapcat #(cph/get-children-ids (:objects page) (:id %)) fixed-ids))
|
fixed-children-ids
|
||||||
|
(into #{} (mapcat #(cph/get-children-ids (:objects page) (:id %)) fixed-ids))
|
||||||
|
|
||||||
parent-children-ids (->> fixed-ids
|
parent-children-ids
|
||||||
(mapcat #(cons (:id %) (cph/get-parent-ids (:objects page) (:id %))))
|
(->> fixed-ids
|
||||||
(remove #(= % uuid/zero)))
|
(mapcat #(cons (:id %) (cph/get-parent-ids (:objects page) (:id %))))
|
||||||
|
(remove #(= % uuid/zero)))
|
||||||
|
|
||||||
fixed-ids (concat fixed-children-ids parent-children-ids)
|
fixed-ids
|
||||||
|
(concat fixed-children-ids parent-children-ids)
|
||||||
|
|
||||||
not-fixed-ids (->> (remove (set fixed-ids) (keys (:objects page)))
|
not-fixed-ids
|
||||||
(remove #(= % uuid/zero)))
|
(->> (remove (set fixed-ids) (keys (:objects page)))
|
||||||
|
(remove #(= % uuid/zero)))
|
||||||
|
|
||||||
calculate-objects (fn [ids] (->> ids
|
calculate-objects
|
||||||
(map (d/getf (:objects page)))
|
(fn [ids]
|
||||||
(concat [frame])
|
(->> ids
|
||||||
(d/index-by :id)
|
(map (d/getf (:objects page)))
|
||||||
(prepare-objects frame size delta)))
|
(concat [frame])
|
||||||
|
(d/index-by :id)
|
||||||
|
(prepare-objects frame size delta)))
|
||||||
|
|
||||||
objects-fixed (mf/with-memo [fixed-ids page frame size delta]
|
objects-fixed
|
||||||
(calculate-objects fixed-ids))
|
(mf/with-memo [fixed-ids page frame size delta]
|
||||||
|
(calculate-objects fixed-ids))
|
||||||
|
|
||||||
objects-not-fixed (mf/with-memo [not-fixed-ids page frame size delta]
|
objects-not-fixed
|
||||||
(calculate-objects not-fixed-ids))
|
(mf/with-memo [not-fixed-ids page frame size delta]
|
||||||
|
(calculate-objects not-fixed-ids))
|
||||||
|
|
||||||
all-objects (mf/with-memo [objects-fixed objects-not-fixed]
|
all-objects
|
||||||
(merge objects-fixed objects-not-fixed))
|
(mf/with-memo [objects-fixed objects-not-fixed]
|
||||||
|
(merge objects-fixed objects-not-fixed))
|
||||||
|
|
||||||
wrapper-fixed (mf/with-memo [page frame size]
|
wrapper-fixed
|
||||||
(shapes/frame-container-factory objects-fixed all-objects))
|
(mf/with-memo [page frame size]
|
||||||
|
(shapes/frame-container-factory (assoc objects-fixed ::fixed true) all-objects))
|
||||||
|
|
||||||
wrapper-not-fixed (mf/with-memo [objects-not-fixed]
|
wrapper-not-fixed
|
||||||
(shapes/frame-container-factory objects-not-fixed all-objects))
|
(mf/with-memo [objects-not-fixed]
|
||||||
|
(shapes/frame-container-factory objects-not-fixed all-objects))
|
||||||
|
|
||||||
;; Retrieve frames again with correct modifier
|
;; Retrieve frames again with correct modifier
|
||||||
frame (get all-objects (:id frame))
|
frame (get all-objects (:id frame))
|
||||||
base (get all-objects (:id base))
|
base (get all-objects (:id base))
|
||||||
|
|
||||||
non-delay-interactions (->> (:interactions frame)
|
non-delay-interactions
|
||||||
(filterv #(not= (:event-type %) :after-delay)))
|
(->> (:interactions frame)
|
||||||
|
(filterv #(not= (:event-type %) :after-delay)))
|
||||||
|
|
||||||
fixed-frame (-> frame
|
fixed-frame
|
||||||
(dissoc :fills)
|
(-> frame
|
||||||
(assoc :interactions non-delay-interactions))]
|
(dissoc :fills)
|
||||||
|
(assoc :interactions non-delay-interactions))]
|
||||||
|
|
||||||
[:& (mf/provider shapes/base-frame-ctx) {:value base}
|
[:& (mf/provider shapes/base-frame-ctx) {:value base}
|
||||||
[:& (mf/provider shapes/frame-offset-ctx) {:value offset}
|
[:& (mf/provider shapes/frame-offset-ctx) {:value offset}
|
||||||
|
@ -124,8 +136,9 @@
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [;; NOTE: with `use-equal-memo` hook we ensure that all values
|
(let [;; NOTE: with `use-equal-memo` hook we ensure that all values
|
||||||
;; conserves the reference identity for avoid unnecessary dummy
|
;; conserves the reference identity for avoid unnecessary
|
||||||
;; rerenders.
|
;; dummy rerenders.
|
||||||
|
|
||||||
mode (h/use-equal-memo (unchecked-get props "interactions-mode"))
|
mode (h/use-equal-memo (unchecked-get props "interactions-mode"))
|
||||||
offset (h/use-equal-memo (unchecked-get props "frame-offset"))
|
offset (h/use-equal-memo (unchecked-get props "frame-offset"))
|
||||||
size (h/use-equal-memo (unchecked-get props "size"))
|
size (h/use-equal-memo (unchecked-get props "size"))
|
||||||
|
|
|
@ -469,7 +469,7 @@
|
||||||
(let [shape (if frame
|
(let [shape (if frame
|
||||||
(gsh/translate-to-frame shape frame)
|
(gsh/translate-to-frame shape frame)
|
||||||
shape)
|
shape)
|
||||||
|
|
||||||
opts #js {:shape shape
|
opts #js {:shape shape
|
||||||
:objects objects
|
:objects objects
|
||||||
:all-objects all-objects}]
|
:all-objects all-objects}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue