mirror of
https://github.com/penpot/penpot.git
synced 2025-06-15 11:01:38 +02:00
🐛 Fixes counters in libraries popup
This commit is contained in:
parent
51697c63dd
commit
3a1618451c
1 changed files with 20 additions and 20 deletions
|
@ -9,6 +9,7 @@
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
|
[okulary.core :as l]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [t tr]]
|
[app.util.i18n :as i18n :refer [t tr]]
|
||||||
[app.util.data :refer [classnames matches-search]]
|
[app.util.data :refer [classnames matches-search]]
|
||||||
|
@ -18,6 +19,9 @@
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.modal :as modal]))
|
[app.main.ui.modal :as modal]))
|
||||||
|
|
||||||
|
(def workspace-file
|
||||||
|
(l/derived :workspace-file st/state))
|
||||||
|
|
||||||
(mf/defc libraries-tab
|
(mf/defc libraries-tab
|
||||||
[{:keys [file libraries shared-files] :as props}]
|
[{:keys [file libraries shared-files] :as props}]
|
||||||
(let [search-term (mf/use-state "")
|
(let [search-term (mf/use-state "")
|
||||||
|
@ -50,7 +54,9 @@
|
||||||
(mf/use-callback (mf/deps file) #(st/emit! (dw/unlink-file-from-library (:id file) %)))
|
(mf/use-callback (mf/deps file) #(st/emit! (dw/unlink-file-from-library (:id file) %)))
|
||||||
|
|
||||||
contents-str
|
contents-str
|
||||||
(fn [library graphics-count colors-count]
|
(fn [library]
|
||||||
|
(let [graphics-count (count (get-in library [:data :media] []))
|
||||||
|
colors-count (count (get-in library [:data :colors] []))]
|
||||||
;; Include a so this block has always some content
|
;; Include a so this block has always some content
|
||||||
(str
|
(str
|
||||||
(str/join " · "
|
(str/join " · "
|
||||||
|
@ -60,22 +66,18 @@
|
||||||
|
|
||||||
(< 0 colors-count)
|
(< 0 colors-count)
|
||||||
(conj (tr "workspace.libraries.colors" colors-count))))
|
(conj (tr "workspace.libraries.colors" colors-count))))
|
||||||
"\u00A0"))]
|
"\u00A0")))]
|
||||||
[:*
|
[:*
|
||||||
[:div.section
|
[:div.section
|
||||||
[:div.section-title (tr "workspace.libraries.in-this-file")]
|
[:div.section-title (tr "workspace.libraries.in-this-file")]
|
||||||
[:div.section-list
|
[:div.section-list
|
||||||
[:div.section-list-item
|
[:div.section-list-item
|
||||||
[:div.item-name (tr "workspace.libraries.file-library")]
|
[:div.item-name (tr "workspace.libraries.file-library")]
|
||||||
[:div.item-contents (contents-str file
|
[:div.item-contents (contents-str file)]]
|
||||||
(count (:media-objects file))
|
|
||||||
(count (:colors file)))]]
|
|
||||||
(for [library sorted-libraries]
|
(for [library sorted-libraries]
|
||||||
[:div.section-list-item {:key (:id library)}
|
[:div.section-list-item {:key (:id library)}
|
||||||
[:div.item-name (:name library)]
|
[:div.item-name (:name library)]
|
||||||
[:div.item-contents (contents-str library
|
[:div.item-contents (contents-str library)]
|
||||||
(count (:media-objects library))
|
|
||||||
(count (:colors library)))]
|
|
||||||
[:input.item-button {:type "button"
|
[:input.item-button {:type "button"
|
||||||
:value (tr "workspace.libraries.remove")
|
:value (tr "workspace.libraries.remove")
|
||||||
:on-click #(unlink-library (:id library))}]])
|
:on-click #(unlink-library (:id library))}]])
|
||||||
|
@ -99,9 +101,7 @@
|
||||||
(for [file filtered-files]
|
(for [file filtered-files]
|
||||||
[:div.section-list-item {:key (:id file)}
|
[:div.section-list-item {:key (:id file)}
|
||||||
[:div.item-name (:name file)]
|
[:div.item-name (:name file)]
|
||||||
[:div.item-contents (contents-str file
|
[:div.item-contents (contents-str file)]
|
||||||
(:graphics-count file)
|
|
||||||
(:colors-count file))]
|
|
||||||
[:input.item-button {:type "button"
|
[:input.item-button {:type "button"
|
||||||
:value (tr "workspace.libraries.add")
|
:value (tr "workspace.libraries.add")
|
||||||
:on-click #(link-library (:id file))}]])]
|
:on-click #(link-library (:id file))}]])]
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
|
|
||||||
locale (mf/deref i18n/locale)
|
locale (mf/deref i18n/locale)
|
||||||
project (mf/deref refs/workspace-project)
|
project (mf/deref refs/workspace-project)
|
||||||
file (mf/deref refs/workspace-file)
|
file (mf/deref workspace-file)
|
||||||
libraries (mf/deref refs/workspace-libraries)
|
libraries (mf/deref refs/workspace-libraries)
|
||||||
shared-files (mf/deref refs/workspace-shared-files)
|
shared-files (mf/deref refs/workspace-shared-files)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue