mirror of
https://github.com/penpot/penpot.git
synced 2025-03-05 20:31:20 -05:00
✨ Display tokens contextual menu in body through portal
This commit is contained in:
parent
5c53de8e76
commit
9da6c50cbe
4 changed files with 23 additions and 17 deletions
|
@ -6,10 +6,11 @@
|
|||
|
||||
(ns app.main.ui.components.portal
|
||||
(:require
|
||||
[app.util.dom :as dom]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(mf/defc portal-on-document*
|
||||
[{:keys [children]}]
|
||||
(mf/portal
|
||||
(mf/html [:* children])
|
||||
(.-body js/document)))
|
||||
(dom/get-body)))
|
||||
|
|
|
@ -86,4 +86,4 @@
|
|||
(when-let [modal (mf/deref ref:modal)]
|
||||
(mf/portal
|
||||
(mf/html [:> modal-wrapper* {:data modal :key (dm/str (:id modal))}])
|
||||
(.-body js/document))))
|
||||
(dom/get-body))))
|
||||
|
|
|
@ -446,17 +446,22 @@
|
|||
(mf/set-ref-val! dropdown-direction-change* (inc (mf/ref-val dropdown-direction-change*)))))))
|
||||
|
||||
;; FIXME: perf optimization
|
||||
[:& dropdown {:show is-open?
|
||||
:on-close #(st/emit! (dt/assign-token-context-menu nil))}
|
||||
[:div {:class (stl/css :token-context-menu)
|
||||
:data-testid "tokens-context-menu-for-token"
|
||||
:ref dropdown-ref
|
||||
:data-direction dropdown-direction
|
||||
:style {:--bottom (if (= dropdown-direction "up")
|
||||
"40px"
|
||||
"unset")
|
||||
:--top (dm/str top "px")
|
||||
:left (dm/str left "px")}
|
||||
:on-context-menu prevent-default}
|
||||
(when mdata
|
||||
[:& token-context-menu-tree (assoc mdata :width @width :direction dropdown-direction)])]]))
|
||||
|
||||
(when is-open?
|
||||
(mf/portal
|
||||
(mf/html
|
||||
[:& dropdown {:show is-open?
|
||||
:on-close #(st/emit! (dt/assign-token-context-menu nil))}
|
||||
[:div {:class (stl/css :token-context-menu)
|
||||
:data-testid "tokens-context-menu-for-token"
|
||||
:ref dropdown-ref
|
||||
:data-direction dropdown-direction
|
||||
:style {:--bottom (if (= dropdown-direction "up")
|
||||
"40px"
|
||||
"unset")
|
||||
:--top (dm/str top "px")
|
||||
:left (dm/str left "px")}
|
||||
:on-context-menu prevent-default}
|
||||
(when mdata
|
||||
[:& token-context-menu-tree (assoc mdata :width @width :direction dropdown-direction)])]])
|
||||
(dom/get-body)))))
|
||||
|
|
|
@ -139,4 +139,4 @@
|
|||
[:& theme-options {:active-theme-paths active-theme-paths
|
||||
:themes themes
|
||||
:on-close on-close-dropdown}]]])
|
||||
(.-body js/document)))]))
|
||||
(dom/get-body)))]))
|
||||
|
|
Loading…
Add table
Reference in a new issue