mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 17:01:40 +02:00
🎉 Add interaction flows
This commit is contained in:
parent
f3bb5c55f5
commit
0159eea526
22 changed files with 856 additions and 257 deletions
|
@ -10,6 +10,7 @@
|
|||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.types.page-options :as cto]
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.viewer :as dv]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -99,6 +100,38 @@
|
|||
:view-box (:vbox size)}]]]]))
|
||||
|
||||
|
||||
(mf/defc flows-menu
|
||||
{::mf/wrap [mf/memo]}
|
||||
[{:keys [page index]}]
|
||||
(let [flows (get-in page [:options :flows])
|
||||
frames (:frames page)
|
||||
frame (get frames index)
|
||||
current-flow (cto/get-frame-flow flows (:id frame))
|
||||
|
||||
show-dropdown? (mf/use-state false)
|
||||
toggle-dropdown (mf/use-fn #(swap! show-dropdown? not))
|
||||
hide-dropdown (mf/use-fn #(reset! show-dropdown? false))
|
||||
|
||||
select-flow
|
||||
(mf/use-callback
|
||||
(fn [flow]
|
||||
(st/emit! (dv/go-to-frame (:starting-frame flow)))))]
|
||||
|
||||
(when (seq flows)
|
||||
[:div.view-options {:on-click toggle-dropdown}
|
||||
[:span.icon i/play]
|
||||
[:span.label (:name current-flow)]
|
||||
[:span.icon i/arrow-down]
|
||||
[:& dropdown {:show @show-dropdown?
|
||||
:on-close hide-dropdown}
|
||||
[:ul.dropdown.with-check
|
||||
(for [flow flows]
|
||||
[:li {:class (dom/classnames :selected (= (:id flow) (:id current-flow)))
|
||||
:on-click #(select-flow flow)}
|
||||
[:span.icon i/tick]
|
||||
[:span.label (:name flow)]])]]])))
|
||||
|
||||
|
||||
(mf/defc interactions-menu
|
||||
[]
|
||||
(let [local (mf/deref refs/viewer-local)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue