mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 08:11:30 -05:00
Initial work on state management logic for clipboard.
This commit is contained in:
parent
e26de8ce3b
commit
296da1df0b
2 changed files with 16 additions and 15 deletions
16
src/uxbox/state/clipboard.cljs
Normal file
16
src/uxbox/state/clipboard.cljs
Normal file
|
@ -0,0 +1,16 @@
|
|||
(ns uxbox.state.clipboard)
|
||||
|
||||
(defonce ^:private ^:const +max-items+ 5)
|
||||
|
||||
(defn conj-item
|
||||
[state item]
|
||||
(if-let [project (get-in state [:workspace :project])]
|
||||
(let [queue (get-in state [:clipboard project] #queue [])
|
||||
queue (conj queue item)]
|
||||
(assoc-in state [:clipboard project]
|
||||
(if (> (count queue) +max-items+)
|
||||
(pop queue)
|
||||
queue)))
|
||||
(do
|
||||
(js/console.warn "no active project for manage clipboard.")
|
||||
state)))
|
|
@ -3,21 +3,6 @@
|
|||
[uxbox.ui.mixins :as mx]
|
||||
[uxbox.ui.lightbox :as lightbox]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; State
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defonce ^:private state (atom #queue []))
|
||||
(defonce ^:private ^:const +max-items+ 5)
|
||||
|
||||
(defn add
|
||||
[item]
|
||||
(swap! state (fn [v]
|
||||
(let [v (conj v item)]
|
||||
(if (> (count v) +max-items+)
|
||||
(pop v)
|
||||
v)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Component
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
Loading…
Add table
Reference in a new issue