mirror of
https://github.com/penpot/penpot.git
synced 2025-01-29 18:09:19 -05:00
Add copy and move tooltips to icons page.
This commit is contained in:
parent
c2e5e9d92c
commit
191c4943bd
3 changed files with 106 additions and 13 deletions
|
@ -245,6 +245,33 @@
|
||||||
{:pre [(or (uuid? id) (nil? id))]}
|
{:pre [(or (uuid? id) (nil? id))]}
|
||||||
(CreateIcons. id files))
|
(CreateIcons. id files))
|
||||||
|
|
||||||
|
;; --- Icon Updated
|
||||||
|
|
||||||
|
(defrecord IconUpdated [id data]
|
||||||
|
rs/UpdateEvent
|
||||||
|
(-apply-update [_ state]
|
||||||
|
(assoc-in state [:icons-by-id id] data)))
|
||||||
|
|
||||||
|
(defn icon-updated
|
||||||
|
[{:keys [id] :as data}]
|
||||||
|
{:pre [(map? data)]}
|
||||||
|
(IconUpdated. id data))
|
||||||
|
|
||||||
|
;; --- Update Icon
|
||||||
|
|
||||||
|
(defrecord UpdateIcon [id]
|
||||||
|
rs/WatchEvent
|
||||||
|
(-apply-watch [_ state stream]
|
||||||
|
(let [icon (get-in state [:icons-by-id id])]
|
||||||
|
(->> (rp/req :update/icon icon)
|
||||||
|
(rx/map :payload)
|
||||||
|
(rx/map icon-updated)))))
|
||||||
|
|
||||||
|
(defn update-icon
|
||||||
|
[id]
|
||||||
|
{:pre [(uuid? id)]}
|
||||||
|
(UpdateIcon. id))
|
||||||
|
|
||||||
;; --- Icons Fetched
|
;; --- Icons Fetched
|
||||||
|
|
||||||
(defrecord IconsFetched [items]
|
(defrecord IconsFetched [items]
|
||||||
|
@ -315,11 +342,16 @@
|
||||||
(DeselectIcon. id)
|
(DeselectIcon. id)
|
||||||
(SelectIcon. id))))))
|
(SelectIcon. id))))))
|
||||||
|
|
||||||
|
(defn deselect-icon
|
||||||
|
[id]
|
||||||
|
{:pre [(uuid? id)]}
|
||||||
|
(DeselectIcon. id))
|
||||||
|
|
||||||
(defn toggle-icon-selection
|
(defn toggle-icon-selection
|
||||||
[id]
|
[id]
|
||||||
(ToggleIconSelection. id))
|
(ToggleIconSelection. id))
|
||||||
|
|
||||||
;; --- Copy Icon
|
;; --- Copy Selected Icon
|
||||||
|
|
||||||
(defrecord CopySelected [id]
|
(defrecord CopySelected [id]
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
|
@ -338,6 +370,31 @@
|
||||||
{:pre [(or (uuid? id) (nil? id))]}
|
{:pre [(or (uuid? id) (nil? id))]}
|
||||||
(CopySelected. id))
|
(CopySelected. id))
|
||||||
|
|
||||||
|
;; --- Move Selected Icon
|
||||||
|
|
||||||
|
(defrecord MoveSelected [id]
|
||||||
|
rs/UpdateEvent
|
||||||
|
(-apply-update [_ state]
|
||||||
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
|
(reduce (fn [state icon]
|
||||||
|
(assoc-in state [:icons-by-id icon :collection] id))
|
||||||
|
state
|
||||||
|
selected)))
|
||||||
|
|
||||||
|
rs/WatchEvent
|
||||||
|
(-apply-watch [_ state stream]
|
||||||
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
|
(rx/merge
|
||||||
|
(->> (rx/from-coll selected)
|
||||||
|
(rx/map update-icon))
|
||||||
|
(->> (rx/from-coll selected)
|
||||||
|
(rx/map deselect-icon))))))
|
||||||
|
|
||||||
|
(defn move-selected
|
||||||
|
[id]
|
||||||
|
{:pre [(or (uuid? id) (nil? id))]}
|
||||||
|
(MoveSelected. id))
|
||||||
|
|
||||||
;; --- Delete Selected
|
;; --- Delete Selected
|
||||||
|
|
||||||
(defrecord DeleteSelected []
|
(defrecord DeleteSelected []
|
||||||
|
|
|
@ -63,3 +63,11 @@
|
||||||
[_ id]
|
[_ id]
|
||||||
(let [url (str url "/library/icons/" id)]
|
(let [url (str url "/library/icons/" id)]
|
||||||
(send! {:url url :method :delete})))
|
(send! {:url url :method :delete})))
|
||||||
|
|
||||||
|
(defmethod request :update/icon
|
||||||
|
[_ {:keys [id collection] :as body}]
|
||||||
|
(let [params {:url (str url "/library/icons/" id)
|
||||||
|
:method :put
|
||||||
|
:body body}]
|
||||||
|
(send! params)))
|
||||||
|
|
||||||
|
|
|
@ -211,17 +211,41 @@
|
||||||
|
|
||||||
(mx/defc grid-options-copy
|
(mx/defc grid-options-copy
|
||||||
{:mixins [mx/reactive mx/static]}
|
{:mixins [mx/reactive mx/static]}
|
||||||
[colls]
|
[current-coll]
|
||||||
|
{:pre [(uuid? current-coll)]}
|
||||||
(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 %)))
|
||||||
(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)))]
|
(rs/emit! (di/copy-selected id)))]
|
||||||
[:ul.move-list
|
[:ul.move-list
|
||||||
[:li.title "Copy to library"]
|
[:li.title "Copy to library"]
|
||||||
[:li [:a {:href "#" :on-click (partial on-select nil)} "Storage"]]
|
[: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"]]
|
||||||
(for [coll colls
|
(for [coll colls
|
||||||
:let [id (:id coll)
|
:let [id (:id coll)
|
||||||
name (:name coll)]]
|
name (:name coll)]]
|
||||||
|
@ -230,7 +254,7 @@
|
||||||
|
|
||||||
(mx/defcs grid-options
|
(mx/defcs grid-options
|
||||||
{:mixins [(mx/local) mx/static]}
|
{:mixins [(mx/local) mx/static]}
|
||||||
[own {:keys [type] :as coll}]
|
[own {:keys [type id] :as coll}]
|
||||||
(let [editable? (or (= type :own)
|
(let [editable? (or (= type :own)
|
||||||
(nil? coll))
|
(nil? coll))
|
||||||
local (:rum/local own)]
|
local (:rum/local own)]
|
||||||
|
@ -238,25 +262,28 @@
|
||||||
(rs/emit! (di/delete-selected)))
|
(rs/emit! (di/delete-selected)))
|
||||||
(on-delete [event]
|
(on-delete [event]
|
||||||
(udl/open! :confirm {:on-accept delete}))
|
(udl/open! :confirm {:on-accept delete}))
|
||||||
(on-toggle [event]
|
(on-toggle-copy [event]
|
||||||
(swap! local update :show-copy-tooltip not)
|
(swap! local update :show-copy-tooltip not))
|
||||||
(println "on-toggle"))]
|
(on-toggle-move [event]
|
||||||
|
(swap! local update :show-move-tooltip not))]
|
||||||
;; 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 to"}
|
{:on-click on-toggle-move}
|
||||||
i/organize]
|
(when (:show-move-tooltip @local)
|
||||||
|
(grid-options-move id))
|
||||||
|
i/organize]
|
||||||
[:span.delete.tooltip.tooltip-top
|
[:span.delete.tooltip.tooltip-top
|
||||||
{:alt "Delete"
|
{:alt "Delete"
|
||||||
:on-click on-delete}
|
:on-click on-delete}
|
||||||
i/trash]]
|
i/trash]]
|
||||||
[:div.multiselect-nav
|
[:div.multiselect-nav
|
||||||
[:span.move-item.tooltip.tooltip-top
|
[:span.move-item.tooltip.tooltip-top
|
||||||
{:on-click on-toggle}
|
{:on-click on-toggle-copy}
|
||||||
(when (:show-copy-tooltip @local)
|
(when (:show-copy-tooltip @local)
|
||||||
(grid-options-copy))
|
(grid-options-copy id))
|
||||||
i/organize]])])))
|
i/organize]])])))
|
||||||
|
|
||||||
(mx/defc grid-item
|
(mx/defc grid-item
|
||||||
|
@ -267,7 +294,8 @@
|
||||||
(when (kbd/shift? event)
|
(when (kbd/shift? event)
|
||||||
(toggle-selection event)))]
|
(toggle-selection event)))]
|
||||||
[:div.grid-item.small-item.project-th
|
[:div.grid-item.small-item.project-th
|
||||||
{:on-click toggle-selection-shifted}
|
{:on-click toggle-selection-shifted
|
||||||
|
:id (str "grid-item-" id)}
|
||||||
[:div.input-checkbox.check-primary
|
[:div.input-checkbox.check-primary
|
||||||
[:input {:type "checkbox"
|
[:input {:type "checkbox"
|
||||||
:id (:id icon)
|
:id (:id icon)
|
||||||
|
|
Loading…
Add table
Reference in a new issue