mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 07:29:08 -05:00
Port copy & move tooltips to icons page.
This commit is contained in:
parent
6b85b459d7
commit
eae616b823
3 changed files with 46 additions and 47 deletions
|
@ -356,14 +356,17 @@
|
||||||
(defrecord CopySelected [id]
|
(defrecord CopySelected [id]
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(-apply-watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :icons :selected])
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
selected (map #(get-in state [:icons %]) selected)]
|
(rx/merge
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
|
(rx/map #(get-in state [:icons %]))
|
||||||
(rx/map #(dissoc % :id))
|
(rx/map #(dissoc % :id))
|
||||||
(rx/map #(assoc % :collection id))
|
(rx/map #(assoc % :collection id))
|
||||||
(rx/flat-map #(rp/req :create/icon %))
|
(rx/flat-map #(rp/req :create/icon %))
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map icon-created)))))
|
(rx/map icon-created))
|
||||||
|
(->> (rx/from-coll selected)
|
||||||
|
(rx/map deselect-icon))))))
|
||||||
|
|
||||||
(defn copy-selected
|
(defn copy-selected
|
||||||
[id]
|
[id]
|
||||||
|
|
|
@ -64,11 +64,6 @@
|
||||||
(-> (l/key :icons)
|
(-> (l/key :icons)
|
||||||
(l/derive st/state)))
|
(l/derive st/state)))
|
||||||
|
|
||||||
;; (defn- focus-collection
|
|
||||||
;; [id]
|
|
||||||
;; (-> (l/key id)
|
|
||||||
;; (l/derive collections-map-ref)))
|
|
||||||
|
|
||||||
;; --- Page Title
|
;; --- Page Title
|
||||||
|
|
||||||
(mx/defcs page-title
|
(mx/defcs page-title
|
||||||
|
@ -210,42 +205,23 @@
|
||||||
:type "file"
|
:type "file"
|
||||||
:on-change on-file-selected}]]))
|
:on-change on-file-selected}]]))
|
||||||
|
|
||||||
(mx/defc grid-options-copy
|
(mx/defc grid-options-tooltip
|
||||||
{:mixins [mx/reactive mx/static]}
|
{:mixins [mx/reactive mx/static]}
|
||||||
[current-coll]
|
[& {:keys [selected on-select title]}]
|
||||||
{:pre [(uuid? current-coll)]}
|
{:pre [(uuid? selected)
|
||||||
|
(fn? on-select)
|
||||||
|
(string? title)]}
|
||||||
(let [colls (mx/react collections-ref)
|
(let [colls (mx/react collections-ref)
|
||||||
colls (->> (vals colls)
|
colls (->> (vals colls)
|
||||||
(filter #(= :own (:type %)))
|
(filter #(= :own (:type %)))
|
||||||
(remove #(= current-coll (:id %)))
|
(remove #(= selected (:id %)))
|
||||||
(sort-by :name colls))
|
(sort-by :name colls))
|
||||||
on-select (fn [event id]
|
on-select (fn [event id]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (di/copy-selected id)))]
|
(dom/stop-propagation event)
|
||||||
|
(on-select id))]
|
||||||
[:ul.move-list
|
[:ul.move-list
|
||||||
[:li.title "Copy to library"]
|
[:li.title title]
|
||||||
[:li [:a {:href "#" :on-click #(on-select % nil)} "Storage"]]
|
|
||||||
(for [coll colls
|
|
||||||
:let [id (:id coll)
|
|
||||||
name (:name coll)]]
|
|
||||||
[:li {:key (str id)}
|
|
||||||
[:a {:on-click #(on-select % id)} name]])]))
|
|
||||||
|
|
||||||
(mx/defc grid-options-move
|
|
||||||
{:mixins [mx/reactive mx/static]}
|
|
||||||
[current-coll]
|
|
||||||
{:pre [(uuid? current-coll)]}
|
|
||||||
(let [colls (mx/react collections-ref)
|
|
||||||
colls (->> (vals colls)
|
|
||||||
(filter #(= :own (:type %)))
|
|
||||||
(remove #(= current-coll (:id %)))
|
|
||||||
(sort-by :name colls))
|
|
||||||
on-select (fn [event id]
|
|
||||||
(println "on-select" event id)
|
|
||||||
(dom/prevent-default event)
|
|
||||||
(rs/emit! (di/move-selected id)))]
|
|
||||||
[:ul.move-list
|
|
||||||
[:li.title "Move to library"]
|
|
||||||
[:li [:a {:href "#" :on-click #(on-select % nil)} "Storage"]]
|
[:li [:a {:href "#" :on-click #(on-select % nil)} "Storage"]]
|
||||||
(for [coll colls
|
(for [coll colls
|
||||||
:let [id (:id coll)
|
:let [id (:id coll)
|
||||||
|
@ -266,15 +242,35 @@
|
||||||
(on-toggle-copy [event]
|
(on-toggle-copy [event]
|
||||||
(swap! local update :show-copy-tooltip not))
|
(swap! local update :show-copy-tooltip not))
|
||||||
(on-toggle-move [event]
|
(on-toggle-move [event]
|
||||||
(swap! local update :show-move-tooltip not))]
|
(swap! local update :show-move-tooltip not))
|
||||||
|
(on-copy [selected]
|
||||||
|
(println "copy from" id "to" selected)
|
||||||
|
(swap! local assoc
|
||||||
|
:show-move-tooltip false
|
||||||
|
:show-copy-tooltip false)
|
||||||
|
(rs/emit! (di/copy-selected selected)))
|
||||||
|
(on-move [selected]
|
||||||
|
(swap! local assoc
|
||||||
|
:show-move-tooltip false
|
||||||
|
:show-copy-tooltip false)
|
||||||
|
(rs/emit! (di/move-selected selected)))]
|
||||||
;; MULTISELECT OPTIONS BAR
|
;; MULTISELECT OPTIONS BAR
|
||||||
[:div.multiselect-bar
|
[:div.multiselect-bar
|
||||||
(if editable?
|
(if editable?
|
||||||
[:div.multiselect-nav
|
[:div.multiselect-nav
|
||||||
[:span.move-item.tooltip.tooltip-top
|
[:span.move-item.tooltip.tooltip-top
|
||||||
{:alt "Move items" :on-click on-toggle-move}
|
{:on-click on-toggle-copy :alt "Copy"}
|
||||||
|
(when (:show-copy-tooltip @local)
|
||||||
|
(grid-options-tooltip :selected id
|
||||||
|
:title "Copy to library"
|
||||||
|
:on-select on-copy))
|
||||||
|
i/organize]
|
||||||
|
[:span.move-item.tooltip.tooltip-top
|
||||||
|
{:on-click on-toggle-move :alt "Move"}
|
||||||
(when (:show-move-tooltip @local)
|
(when (:show-move-tooltip @local)
|
||||||
(grid-options-move id))
|
(grid-options-tooltip :selected id
|
||||||
|
:title "Move to library"
|
||||||
|
:on-select on-move))
|
||||||
i/organize]
|
i/organize]
|
||||||
[:span.move-item.tooltip.tooltip-top
|
[:span.move-item.tooltip.tooltip-top
|
||||||
{:alt "Rename"}
|
{:alt "Rename"}
|
||||||
|
@ -287,7 +283,9 @@
|
||||||
[:span.move-item.tooltip.tooltip-top
|
[:span.move-item.tooltip.tooltip-top
|
||||||
{:on-click on-toggle-copy}
|
{:on-click on-toggle-copy}
|
||||||
(when (:show-copy-tooltip @local)
|
(when (:show-copy-tooltip @local)
|
||||||
(grid-options-copy id))
|
(grid-options-tooltip :selected id
|
||||||
|
:title "Copy to library"
|
||||||
|
:on-select on-copy))
|
||||||
i/organize]])])))
|
i/organize]])])))
|
||||||
|
|
||||||
(mx/defc grid-item
|
(mx/defc grid-item
|
||||||
|
|
|
@ -211,7 +211,6 @@
|
||||||
:type "file"
|
:type "file"
|
||||||
:on-change on-file-selected}]])))
|
:on-change on-file-selected}]])))
|
||||||
|
|
||||||
|
|
||||||
(mx/defc grid-options-tooltip
|
(mx/defc grid-options-tooltip
|
||||||
{:mixins [mx/reactive mx/static]}
|
{:mixins [mx/reactive mx/static]}
|
||||||
[& {:keys [selected on-select title]}]
|
[& {:keys [selected on-select title]}]
|
||||||
|
@ -250,7 +249,6 @@
|
||||||
(on-toggle-move [event]
|
(on-toggle-move [event]
|
||||||
(swap! local update :show-move-tooltip not))
|
(swap! local update :show-move-tooltip not))
|
||||||
(on-copy [selected]
|
(on-copy [selected]
|
||||||
(println "copy from" id "to" selected)
|
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
|
|
Loading…
Add table
Reference in a new issue