From 545ec183fd020e7a63b191baaa9a9b498434861e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Tue, 28 Jul 2026 10:36:26 +0200 Subject: [PATCH] :tada: Show tokens in library summaries --- backend/src/app/rpc/commands/files.clj | 14 ++++- .../src/app/main/ui/workspace/libraries.cljs | 59 +++++++++++++++---- frontend/translations/en.po | 18 ++++++ frontend/translations/es.po | 18 ++++++ 4 files changed, 95 insertions(+), 14 deletions(-) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index e10c85a7bd..395cc101b3 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -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})) diff --git a/frontend/src/app/main/ui/workspace/libraries.cljs b/frontend/src/app/main/ui/workspace/libraries.cljs index 7c2707111e..b572421e6e 100644 --- a/frontend/src/app/main/ui/workspace/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/libraries.cljs @@ -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} diff --git a/frontend/translations/en.po b/frontend/translations/en.po index 64773cd7f4..687007dd45 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -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" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index ab9a1d5598..29a98d66ba 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -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"