mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 07:31:36 +02:00
♻️ Refactor: shape data structure, dashboard data loading...
This commit is contained in:
parent
9f8936ea40
commit
1e058463b2
56 changed files with 1785 additions and 2316 deletions
|
@ -64,60 +64,6 @@
|
|||
files
|
||||
(filter #(contains-term? (:name %) term) files)))
|
||||
|
||||
;; --- Menu (Filter & Sort)
|
||||
|
||||
(mf/defc menu
|
||||
[{:keys [id opts files] :as props}]
|
||||
(let [ordering (:order opts :modified)
|
||||
filtering (:filter opts "")
|
||||
|
||||
on-term-change
|
||||
(fn [event]
|
||||
(let [term (-> (dom/get-target event)
|
||||
(dom/get-value))]
|
||||
(st/emit! (udp/update-opts :filter term))))
|
||||
|
||||
on-order-change
|
||||
(fn [event]
|
||||
(let [value (dom/event->value event)
|
||||
value (read-string value)]
|
||||
(st/emit! (udp/update-opts :order value))))
|
||||
|
||||
on-clear
|
||||
(fn [event]
|
||||
(st/emit! (udp/update-opts :filter "")))]
|
||||
|
||||
[:section.dashboard-bar.library-gap
|
||||
[:div.dashboard-info
|
||||
|
||||
;; Counter
|
||||
[:span.dashboard-images (tr "ds.num-files" (t/c (count files)))]
|
||||
|
||||
[:div
|
||||
;; Sorting
|
||||
;; TODO: convert to separate component?
|
||||
(when id
|
||||
[:*
|
||||
[:span (tr "ds.ordering")]
|
||||
[:select.input-select {:on-change on-order-change
|
||||
:value (pr-str ordering)}
|
||||
(for [[key value] (seq +ordering-options+)]
|
||||
(let [key (pr-str key)]
|
||||
[:option {:key key :value key} (tr value)]))]])]
|
||||
|
||||
;; Search
|
||||
;; TODO: convert to separate component?
|
||||
; [:form.dashboard-search
|
||||
; [:input.input-text
|
||||
; {:key :images-search-box
|
||||
; :type "text"
|
||||
; :on-change on-term-change
|
||||
; :auto-focus true
|
||||
; :placeholder (tr "ds.search.placeholder")
|
||||
; :value (or filtering "")}]
|
||||
; [:div.clear-search {:on-click on-clear} i/close]]
|
||||
]]))
|
||||
|
||||
;; --- Grid Item Thumbnail
|
||||
|
||||
(mf/defc grid-item-thumbnail
|
||||
|
@ -164,9 +110,9 @@
|
|||
;; [:div.project-th-icon.pages
|
||||
;; i/page
|
||||
;; #_[:span (:total-pages project)]]
|
||||
#_[:div.project-th-icon.comments
|
||||
i/chat
|
||||
[:span "0"]]
|
||||
;; [:div.project-th-icon.comments
|
||||
;; i/chat
|
||||
;; [:span "0"]]
|
||||
[:div.project-th-icon.edit
|
||||
{:on-click on-edit}
|
||||
i/pencil]
|
||||
|
@ -177,7 +123,7 @@
|
|||
;; --- Grid
|
||||
|
||||
(mf/defc grid
|
||||
[{:keys [opts files] :as props}]
|
||||
[{:keys [id opts files] :as props}]
|
||||
(let [order (:order opts :modified)
|
||||
filter (:filter opts "")
|
||||
files (->> files
|
||||
|
@ -185,15 +131,13 @@
|
|||
(sort-by order))
|
||||
on-click #(do
|
||||
(dom/prevent-default %)
|
||||
#_(modal/show! create-project-dialog {})
|
||||
#_(udl/open! :create-project))
|
||||
]
|
||||
(st/emit! (udp/create-file {:project-id id})))]
|
||||
[:section.dashboard-grid
|
||||
;; [:h2 (tr "ds.projects.file-name")]
|
||||
[:div.dashboard-grid-content
|
||||
[:div.dashboard-grid-row
|
||||
[:div.grid-item.add-project #_{:on-click on-click}
|
||||
[:span (tr "ds.new-file")]]
|
||||
(when id
|
||||
[:div.grid-item.add-project {:on-click on-click}
|
||||
[:span (tr "ds.new-file")]])
|
||||
(for [item files]
|
||||
[:& grid-item {:file item :key (:id item)}])]]]))
|
||||
|
||||
|
@ -245,10 +189,6 @@
|
|||
:placeholder (tr "ds.search.placeholder")}]
|
||||
[:div.clear-search i/close]]
|
||||
[:ul.library-elements
|
||||
; [:li
|
||||
; [:a.btn-primary #_{:on-click #(st/emit! di/create-collection)}
|
||||
; "new project +"]]
|
||||
|
||||
[:li.recent-projects {:on-click #(st/emit! (udp/go-to-project nil))
|
||||
:class-name (when (nil? id) "current")}
|
||||
[:span.element-title "Recent"]]
|
||||
|
@ -280,10 +220,8 @@
|
|||
[{:keys [id] :as props}]
|
||||
(let [opts (mf/deref opts-iref)
|
||||
files (mf/deref files-ref)]
|
||||
[:*
|
||||
#_[:& menu {:id id :opts opts :files files}]
|
||||
[:section.dashboard-grid.library
|
||||
[:& grid {:id id :opts opts :files files}]]]))
|
||||
[:section.dashboard-grid.library
|
||||
[:& grid {:id id :opts opts :files files}]]))
|
||||
|
||||
;; --- Projects Page
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue