mirror of
https://github.com/penpot/penpot.git
synced 2025-02-26 16:56:11 -05:00
Use new components macros on clipboard ns.
This commit is contained in:
parent
20e89cb8a7
commit
271a305cc0
1 changed files with 19 additions and 33 deletions
|
@ -6,9 +6,7 @@
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.clipboard
|
(ns uxbox.main.ui.workspace.clipboard
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [lentes.core :as l]
|
||||||
[rum.core :as rum]
|
|
||||||
[lentes.core :as l]
|
|
||||||
[uxbox.util.rstore :as rs]
|
[uxbox.util.rstore :as rs]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.main.state :as st]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
|
@ -19,40 +17,28 @@
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.datetime :as dt]))
|
[uxbox.util.datetime :as dt]))
|
||||||
|
|
||||||
;; --- Lenses
|
|
||||||
|
|
||||||
(def ^:private clipboard-ref
|
(def ^:private clipboard-ref
|
||||||
(-> (l/key :clipboard)
|
(-> (l/key :clipboard)
|
||||||
(l/derive st/state)))
|
(l/derive st/state)))
|
||||||
|
|
||||||
;; --- Clipboard Dialog Component
|
(mx/defc clipboard-dialog
|
||||||
|
{:mixins [mx/static mx/reactive]}
|
||||||
(defn- on-paste
|
[]
|
||||||
[item]
|
(letfn [(on-paste [item]
|
||||||
(rs/emit! (udw/paste-from-clipboard (:id item)))
|
(rs/emit! (udw/paste-from-clipboard (:id item)))
|
||||||
(udl/close!))
|
(udl/close!))
|
||||||
|
(on-close [event]
|
||||||
(defn- clipboard-dialog-render
|
(dom/prevent-default event)
|
||||||
[own]
|
(udl/close!))]
|
||||||
(let [clipboard (mx/react clipboard-ref)]
|
|
||||||
(html
|
|
||||||
[:div.lightbox-body.clipboard
|
[:div.lightbox-body.clipboard
|
||||||
[:div.clipboard-list
|
[:div.clipboard-list
|
||||||
(for [item clipboard]
|
(for [item (mx/react clipboard-ref)]
|
||||||
[:div.clipboard-item
|
[:div.clipboard-item
|
||||||
{:key (str (:id item))
|
{:key (str (:id item))
|
||||||
:on-click (partial on-paste item)}
|
:on-click (partial on-paste item)}
|
||||||
[:span.clipboard-icon i/box]
|
[:span.clipboard-icon i/box]
|
||||||
[:span (str "Copied (" (dt/timeago (:created-at item)) ")")]])]
|
[:span (str "Copied (" (dt/timeago (:created-at item)) ")")]])]
|
||||||
[:a.close {:href "#"
|
[:a.close {:href "#" :on-click on-close} i/close]]))
|
||||||
:on-click #(do (dom/prevent-default %)
|
|
||||||
(udl/close!))} i/close]])))
|
|
||||||
|
|
||||||
(def clipboard-dialog
|
|
||||||
(mx/component
|
|
||||||
{:render clipboard-dialog-render
|
|
||||||
:name "clipboard-dialog"
|
|
||||||
:mixins [mx/static mx/reactive]}))
|
|
||||||
|
|
||||||
(defmethod lbx/render-lightbox :clipboard
|
(defmethod lbx/render-lightbox :clipboard
|
||||||
[_]
|
[_]
|
||||||
|
|
Loading…
Add table
Reference in a new issue