Small enhancements

This commit is contained in:
Andrés Moya 2023-08-25 13:50:21 +02:00
parent ca88314524
commit d8027936b4
2 changed files with 52 additions and 49 deletions

View file

@ -6,8 +6,10 @@
(ns app.main.ui.messages (ns app.main.ui.messages
(:require (:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.messages :as dm] [app.main.data.messages :as dmsg]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
@ -39,8 +41,8 @@
:role role} :role role}
[:span [:span
content content
(for [link links] (for [[index link] (d/enumerate links)]
[:* {:key (uuid/next)} [:* {:key (dm/str "link-" index)}
" " [:a.link {:on-click (:callback link)} " " [:a.link {:on-click (:callback link)}
(:label link)]])] (:label link)]])]
(when (or (= controls :bottom-actions) (= controls :inline-actions)) (when (or (= controls :bottom-actions) (= controls :inline-actions))
@ -55,7 +57,7 @@
(mf/defc notifications (mf/defc notifications
[] []
(let [message (mf/deref refs/message) (let [message (mf/deref refs/message)
on-close #(st/emit! dm/hide)] on-close #(st/emit! dmsg/hide)]
(when message (when message
[:& banner (assoc message [:& banner (assoc message
:position (or (:position message) :fixed) :position (or (:position message) :fixed)

View file

@ -394,20 +394,8 @@
(tr "workspace.libraries.no-shared-libraries-available") (tr "workspace.libraries.no-shared-libraries-available")
(tr "workspace.libraries.no-matches-for" search-term))])])]]))) (tr "workspace.libraries.no-matches-for" search-term))])])]])))
(mf/defc updates-tab (defn- extract-assets
{::mf/wrap-props false} [file-data library summary?]
[{:keys [file-id file-data libraries]}]
(let [summary?* (mf/use-state true)
updating?* (mf/use-state false)
summary? (deref summary?*)
updating? (deref updating?*)
see-all-assets
(fn []
(reset! summary?* false))
extract-assets
(fn [library]
(let [exceeded (volatile! {:components false (let [exceeded (volatile! {:components false
:colors false :colors false
:typographies false}) :typographies false})
@ -448,9 +436,22 @@
:colors colors :colors colors
:typographies typographies}])) :typographies typographies}]))
(mf/defc updates-tab
{::mf/wrap-props false}
[{:keys [file-id file-data libraries]}]
(let [summary?* (mf/use-state true)
updating?* (mf/use-state false)
summary? (deref summary?*)
updating? (deref updating?*)
see-all-assets
(mf/use-fn
(fn []
(reset! summary?* false)))
libs-assets (mf/with-memo [file-data libraries summary?*] libs-assets (mf/with-memo [file-data libraries summary?*]
(->> (vals libraries) (->> (vals libraries)
(map extract-assets) (map #(extract-assets file-data % summary?))
(filter (fn [[_ _ {:keys [components colors typographies]}]] (filter (fn [[_ _ {:keys [components colors typographies]}]]
(or (seq components) (or (seq components)
(seq colors) (seq colors)