mirror of
https://github.com/penpot/penpot.git
synced 2026-07-31 18:36:18 +00:00
🎉 Show tokens in library summaries
This commit is contained in:
parent
47bc0c6600
commit
545ec183fd
@ -14,6 +14,7 @@
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.files.migrations :as fmg]
|
||||
[app.common.files.stats :as cfs]
|
||||
[app.common.files.tokens :as cfo]
|
||||
[app.common.logging :as l]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.schema.desc-js-like :as-alias smdj]
|
||||
@ -21,6 +22,7 @@
|
||||
[app.common.transit :as t]
|
||||
[app.common.types.components-list :as ctkl]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[app.common.uri :as uri]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
@ -494,12 +496,20 @@
|
||||
|
||||
components-sample
|
||||
(-> (sample-assets components 4)
|
||||
(update :sample load-objects))]
|
||||
(update :sample load-objects))
|
||||
|
||||
tokens-lib (cfo/get-tokens-lib data)
|
||||
tokens-count (if (some? tokens-lib) (count (ctob/get-all-tokens tokens-lib)) 0)
|
||||
token-sets-count (if (some? tokens-lib) (count (ctob/get-sets tokens-lib)) 0)
|
||||
token-themes-count (if (some? tokens-lib) (count (ctob/get-themes tokens-lib)) 0)]
|
||||
|
||||
{:components components-sample
|
||||
:variants {:count (count variant-ids)}
|
||||
:colors (sample-assets (:colors data) 3)
|
||||
:typographies (sample-assets (:typographies data) 3)}))
|
||||
:typographies (sample-assets (:typographies data) 3)
|
||||
:tokens-count tokens-count
|
||||
:token-sets-count token-sets-count
|
||||
:token-themes-count token-themes-count}))
|
||||
|
||||
(def ^:private file-summary-cache-key-ttl
|
||||
(ct/duration {:days 30}))
|
||||
|
||||
@ -58,16 +58,27 @@
|
||||
typographies (count (:typographies data))
|
||||
components (count (->> (ctkl/components-seq data)
|
||||
(remove #(cfv/is-secondary-variant? % data))))
|
||||
tokens-lib (cfo/get-tokens-lib data)
|
||||
tokens (if (some? tokens-lib) (count (ctob/get-all-tokens tokens-lib)) 0)
|
||||
token-sets (if (some? tokens-lib) (count (ctob/get-sets tokens-lib)) 0)
|
||||
token-themes (if (some? tokens-lib) (count (ctob/get-themes tokens-lib)) 0)
|
||||
|
||||
empty? (and (zero? components)
|
||||
(zero? graphics)
|
||||
(zero? colors)
|
||||
(zero? typographies))]
|
||||
(zero? typographies)
|
||||
(zero? tokens)
|
||||
(zero? token-sets)
|
||||
(zero? token-themes))]
|
||||
|
||||
{:is-empty empty?
|
||||
:colors colors
|
||||
:graphics graphics
|
||||
:typographies typographies
|
||||
:components components}))
|
||||
:components components
|
||||
:tokens tokens
|
||||
:token-sets token-sets
|
||||
:token-themes token-themes}))
|
||||
|
||||
(defn- adapt-backend-summary
|
||||
[summary]
|
||||
@ -75,16 +86,25 @@
|
||||
graphics (or (-> summary :media :count) 0)
|
||||
typographies (or (-> summary :typographies :count) 0)
|
||||
colors (or (-> summary :colors :count) 0)
|
||||
tokens (or (-> summary :tokens-count) 0)
|
||||
token-sets (or (-> summary :token-sets-count) 0)
|
||||
token-themes (or (-> summary :token-themes-count) 0)
|
||||
|
||||
empty? (and (zero? components)
|
||||
(zero? graphics)
|
||||
(zero? colors)
|
||||
(zero? typographies))]
|
||||
{:is-empty empty?
|
||||
:components components
|
||||
:graphics graphics
|
||||
(zero? typographies)
|
||||
(zero? tokens)
|
||||
(zero? token-sets)
|
||||
(zero? token-themes))]
|
||||
{:is-empty empty?
|
||||
:components components
|
||||
:graphics graphics
|
||||
:typographies typographies
|
||||
:colors colors}))
|
||||
:colors colors
|
||||
:tokens tokens
|
||||
:token-sets token-sets
|
||||
:token-themes token-themes}))
|
||||
|
||||
(defn- describe-library
|
||||
[components-count graphics-count colors-count typography-count]
|
||||
@ -111,10 +131,13 @@
|
||||
(mf/defc library-description*
|
||||
{::mf/private true}
|
||||
[{:keys [summary]}]
|
||||
(let [components-count (get summary :components)
|
||||
graphics-count (get summary :graphics)
|
||||
typography-count (get summary :typographies)
|
||||
colors-count (get summary :colors)]
|
||||
(let [components-count (get summary :components)
|
||||
graphics-count (get summary :graphics)
|
||||
typography-count (get summary :typographies)
|
||||
colors-count (get summary :colors)
|
||||
tokens-count (get summary :tokens)
|
||||
token-sets-count (get summary :token-sets)
|
||||
token-themes-count (get summary :token-themes)]
|
||||
|
||||
[:*
|
||||
(when (pos? components-count)
|
||||
@ -131,7 +154,19 @@
|
||||
|
||||
(when (pos? typography-count)
|
||||
[:li {:class (stl/css :element-count)}
|
||||
(tr "workspace.libraries.typography" (c typography-count))])]))
|
||||
(tr "workspace.libraries.typography" (c typography-count))])
|
||||
|
||||
(when (pos? tokens-count)
|
||||
[:li {:class (stl/css :element-count)}
|
||||
(tr "workspace.libraries.tokens" (c tokens-count))])
|
||||
|
||||
(when (pos? token-sets-count)
|
||||
[:li {:class (stl/css :element-count)}
|
||||
(tr "workspace.libraries.token-sets" (c token-sets-count))])
|
||||
|
||||
(when (pos? token-themes-count)
|
||||
[:li {:class (stl/css :element-count)}
|
||||
(tr "workspace.libraries.token-themes" (c token-themes-count))])]))
|
||||
|
||||
(mf/defc sample-library-entry*
|
||||
{::mf/private true}
|
||||
|
||||
@ -7349,6 +7349,24 @@ msgid_plural "workspace.libraries.typography"
|
||||
msgstr[0] "1 typography"
|
||||
msgstr[1] "%s typographies"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:106, src/app/main/ui/workspace/libraries.cljs:150
|
||||
msgid "workspace.libraries.tokens"
|
||||
msgid_plural "workspace.libraries.tokens"
|
||||
msgstr[0] "1 token"
|
||||
msgstr[1] "%s tokens"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:106, src/app/main/ui/workspace/libraries.cljs:150
|
||||
msgid "workspace.libraries.token-sets"
|
||||
msgid_plural "workspace.libraries.token-sets"
|
||||
msgstr[0] "1 set"
|
||||
msgstr[1] "%s sets"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:106, src/app/main/ui/workspace/libraries.cljs:150
|
||||
msgid "workspace.libraries.token-themes"
|
||||
msgid_plural "workspace.libraries.token-themes"
|
||||
msgstr[0] "1 theme"
|
||||
msgstr[1] "%s themes"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:381
|
||||
msgid "workspace.libraries.unlink-library-btn"
|
||||
msgstr "Disconnect library"
|
||||
|
||||
@ -7177,6 +7177,24 @@ msgid_plural "workspace.libraries.typography"
|
||||
msgstr[0] "1 tipografía"
|
||||
msgstr[1] "%s tipografías"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:106, src/app/main/ui/workspace/libraries.cljs:150
|
||||
msgid "workspace.libraries.tokens"
|
||||
msgid_plural "workspace.libraries.tokens"
|
||||
msgstr[0] "1 token"
|
||||
msgstr[1] "%s tokens"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:106, src/app/main/ui/workspace/libraries.cljs:150
|
||||
msgid "workspace.libraries.token-sets"
|
||||
msgid_plural "workspace.libraries.token-sets"
|
||||
msgstr[0] "1 token set"
|
||||
msgstr[1] "%s token sets"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:106, src/app/main/ui/workspace/libraries.cljs:150
|
||||
msgid "workspace.libraries.token-themes"
|
||||
msgid_plural "workspace.libraries.token-themes"
|
||||
msgstr[0] "1 token theme"
|
||||
msgstr[1] "%s token themes"
|
||||
|
||||
#: src/app/main/ui/workspace/libraries.cljs:381
|
||||
msgid "workspace.libraries.unlink-library-btn"
|
||||
msgstr "Desconectar biblioteca"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user