mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
a055a31286
46 changed files with 756 additions and 620 deletions
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.data.viewer
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
|
@ -22,6 +23,9 @@
|
|||
[cljs.spec.alpha :as s]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(s/def ::nilable-boolean (s/nilable ::us/boolean))
|
||||
(s/def ::nilable-animation (s/nilable ::ctsi/animation))
|
||||
|
||||
;; --- Local State Initialization
|
||||
|
||||
(def ^:private
|
||||
|
@ -34,7 +38,6 @@
|
|||
:comments-show :unresolved
|
||||
:selected #{}
|
||||
:collapsed #{}
|
||||
:overlays []
|
||||
:hover nil
|
||||
:share-id ""
|
||||
:file-comments-users []})
|
||||
|
@ -351,7 +354,8 @@
|
|||
|
||||
(declare flash-done)
|
||||
|
||||
(def flash-interactions
|
||||
(defn flash-interactions
|
||||
[]
|
||||
(ptk/reify ::flash-interactions
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -389,7 +393,7 @@
|
|||
(ptk/reify ::complete-animation
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(d/dissoc-in state [:viewer-local :current-animation]))))
|
||||
(dissoc state :viewer-animation))))
|
||||
|
||||
;; --- Navigation inside page
|
||||
|
||||
|
@ -398,7 +402,7 @@
|
|||
(ptk/reify ::go-to-frame-by-index
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:viewer-local :overlays] []))
|
||||
(assoc state :viewer-overlays []))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
|
@ -413,8 +417,9 @@
|
|||
(go-to-frame frame-id nil))
|
||||
|
||||
([frame-id animation]
|
||||
(us/verify ::us/uuid frame-id)
|
||||
(us/verify (s/nilable ::ctsi/animation) animation)
|
||||
(us/assert! ::us/uuid frame-id)
|
||||
(us/assert! ::nilable-animation animation)
|
||||
|
||||
(ptk/reify ::go-to-frame
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -426,13 +431,13 @@
|
|||
frame (get frames index)]
|
||||
(cond-> state
|
||||
:always
|
||||
(assoc-in [:viewer-local :overlays] [])
|
||||
(assoc :viewer-overlays [])
|
||||
|
||||
(some? animation)
|
||||
(assoc-in [:viewer-local :current-animation]
|
||||
{:kind :go-to-frame
|
||||
:orig-frame-id (:id frame)
|
||||
:animation animation}))))
|
||||
(assoc :viewer-animation
|
||||
{:kind :go-to-frame
|
||||
:orig-frame-id (:id frame)
|
||||
:animation animation}))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
|
@ -462,7 +467,7 @@
|
|||
(ptk/reify ::go-to-section
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:viewer-local :overlays] []))
|
||||
(assoc state :viewer-overlays []))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
|
@ -473,64 +478,69 @@
|
|||
|
||||
;; --- Overlays
|
||||
|
||||
(defn- do-open-overlay
|
||||
(defn- open-overlay*
|
||||
[state frame position close-click-outside background-overlay animation]
|
||||
(cond-> state
|
||||
:always
|
||||
(update-in [:viewer-local :overlays] conj
|
||||
{:frame frame
|
||||
:position position
|
||||
:close-click-outside close-click-outside
|
||||
:background-overlay background-overlay})
|
||||
(some? animation)
|
||||
(assoc-in [:viewer-local :current-animation]
|
||||
{:kind :open-overlay
|
||||
:overlay-id (:id frame)
|
||||
:animation animation})))
|
||||
(update :viewer-overlays conj
|
||||
{:frame frame
|
||||
:id (:id frame)
|
||||
:position position
|
||||
:close-click-outside close-click-outside
|
||||
:background-overlay background-overlay})
|
||||
|
||||
(defn- do-close-overlay
|
||||
(some? animation)
|
||||
(assoc :viewer-animation
|
||||
{:kind :open-overlay
|
||||
:overlay-id (:id frame)
|
||||
:animation animation})))
|
||||
|
||||
(defn- close-overlay*
|
||||
[state frame-id animation]
|
||||
(if (nil? animation)
|
||||
(update-in state [:viewer-local :overlays]
|
||||
(fn [overlays]
|
||||
(d/removev #(= (:id (:frame %)) frame-id) overlays)))
|
||||
(assoc-in state [:viewer-local :current-animation]
|
||||
{:kind :close-overlay
|
||||
:overlay-id frame-id
|
||||
:animation animation})))
|
||||
(update state :viewer-overlays
|
||||
(fn [overlays]
|
||||
(d/removev #(= (:id (:frame %)) frame-id) overlays)))
|
||||
(assoc state :viewer-animation
|
||||
{:kind :close-overlay
|
||||
:overlay-id frame-id
|
||||
:animation animation})))
|
||||
|
||||
(defn open-overlay
|
||||
[frame-id position close-click-outside background-overlay animation]
|
||||
(us/verify ::us/uuid frame-id)
|
||||
(us/verify ::gpt/point position)
|
||||
(us/verify (s/nilable ::us/boolean) close-click-outside)
|
||||
(us/verify (s/nilable ::us/boolean) background-overlay)
|
||||
(us/verify (s/nilable ::ctsi/animation) animation)
|
||||
(us/assert! ::us/uuid frame-id)
|
||||
(us/assert! ::gpt/point position)
|
||||
(us/assert! ::nilable-boolean close-click-outside)
|
||||
(us/assert! ::nilable-boolean background-overlay)
|
||||
(us/assert! ::nilable-animation animation)
|
||||
|
||||
(ptk/reify ::open-overlay
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [route (:route state)
|
||||
qparams (:query-params route)
|
||||
page-id (:page-id qparams)
|
||||
frames (get-in state [:viewer :pages page-id :all-frames])
|
||||
frames (dm/get-in state [:viewer :pages page-id :all-frames])
|
||||
frame (d/seek #(= (:id %) frame-id) frames)
|
||||
overlays (get-in state [:viewer-local :overlays])]
|
||||
overlays (:viewer-overlays state)]
|
||||
(if-not (some #(= (:frame %) frame) overlays)
|
||||
(do-open-overlay state
|
||||
frame
|
||||
position
|
||||
close-click-outside
|
||||
background-overlay
|
||||
animation)
|
||||
(open-overlay* state
|
||||
frame
|
||||
position
|
||||
close-click-outside
|
||||
background-overlay
|
||||
animation)
|
||||
state)))))
|
||||
|
||||
|
||||
(defn toggle-overlay
|
||||
[frame-id position close-click-outside background-overlay animation]
|
||||
(us/verify ::us/uuid frame-id)
|
||||
(us/verify ::gpt/point position)
|
||||
(us/verify (s/nilable ::us/boolean) close-click-outside)
|
||||
(us/verify (s/nilable ::us/boolean) background-overlay)
|
||||
(us/verify (s/nilable ::ctsi/animation) animation)
|
||||
(us/assert! ::us/uuid frame-id)
|
||||
(us/assert! ::gpt/point position)
|
||||
(us/assert! ::nilable-boolean close-click-outside)
|
||||
(us/assert! ::nilable-boolean background-overlay)
|
||||
(us/assert! ::nilable-animation animation)
|
||||
|
||||
(ptk/reify ::toggle-overlay
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -539,29 +549,30 @@
|
|||
page-id (:page-id qparams)
|
||||
frames (get-in state [:viewer :pages page-id :all-frames])
|
||||
frame (d/seek #(= (:id %) frame-id) frames)
|
||||
overlays (get-in state [:viewer-local :overlays])]
|
||||
overlays (:viewer-overlays state)]
|
||||
(if-not (some #(= (:frame %) frame) overlays)
|
||||
(do-open-overlay state
|
||||
frame
|
||||
position
|
||||
close-click-outside
|
||||
background-overlay
|
||||
animation)
|
||||
(do-close-overlay state
|
||||
(:id frame)
|
||||
(ctsi/invert-direction animation)))))))
|
||||
(open-overlay* state
|
||||
frame
|
||||
position
|
||||
close-click-outside
|
||||
background-overlay
|
||||
animation)
|
||||
(close-overlay* state
|
||||
(:id frame)
|
||||
(ctsi/invert-direction animation)))))))
|
||||
|
||||
(defn close-overlay
|
||||
([frame-id] (close-overlay frame-id nil))
|
||||
([frame-id animation]
|
||||
(us/verify ::us/uuid frame-id)
|
||||
(us/verify (s/nilable ::ctsi/animation) animation)
|
||||
(us/assert! ::us/uuid frame-id)
|
||||
(us/assert! ::nilable-animation animation)
|
||||
|
||||
(ptk/reify ::close-overlay
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(do-close-overlay state
|
||||
frame-id
|
||||
animation)))))
|
||||
(close-overlay* state
|
||||
frame-id
|
||||
animation)))))
|
||||
|
||||
;; --- Objects selection
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue