0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 14:12:36 -05:00

remove unused prop and some optimizations

This commit is contained in:
Akshay Gupta 2024-08-20 20:55:02 +05:30
parent 463ab3c866
commit 5b1eaf4b8f
No known key found for this signature in database
2 changed files with 6 additions and 11 deletions

View file

@ -53,7 +53,7 @@
(assoc state :selected-set-id set-id)))) (assoc state :selected-set-id set-id))))
(mf/defc sets-tree (mf/defc sets-tree
[{:keys [selected-set-id set-id toggle-visibility]}] [{:keys [selected-set-id set-id]}]
(let [set (get sets set-id)] (let [set (get sets set-id)]
(when set (when set
(let [{:keys [type name children]} set (let [{:keys [type name children]} set
@ -90,16 +90,12 @@
(when (and children (not @collapsed?)) (when (and children (not @collapsed?))
[:div {:class (stl/css :set-children)} [:div {:class (stl/css :set-children)}
(for [child-id children] (for [child-id children]
(do [:& sets-tree {:key child-id :set-id child-id :selected-set-id selected-set-id}])])]))))
^{:key (str child-id)} [:& sets-tree {:key (str child-id) :set-id child-id :selected-set-id selected-set-id :toggle-visibility toggle-visibility}]))])]))))
(mf/defc sets-list (mf/defc sets-list
[{:keys [selected-set-id]}] [{:keys [selected-set-id]}]
(let [toggle-visibility (fn [set-id]
(if (contains? active-sets set-id)
(swap! active-sets disj set-id)
(swap! active-sets conj set-id)))]
[:ul {:class (stl/css :sets-list)} [:ul {:class (stl/css :sets-list)}
(for [set-id sets-root-order] (for [set-id sets-root-order]
^{:key (str set-id)} [:& sets-tree {:key set-id
[:& sets-tree {:key (str set-id) :set-id set-id :selected-set-id selected-set-id}])])) :set-id set-id
:selected-set-id selected-set-id}])])

View file

@ -175,8 +175,7 @@
[] []
(let [selected-set-id (mf/deref selected-set-id) (let [selected-set-id (mf/deref selected-set-id)
open? (mf/use-state true)] open? (mf/use-state true)]
[:div {:key (str "sidebar-" selected-set-id) [:div {:class (stl/css :sets-sidebar)}
:class (stl/css :sets-sidebar)}
[:div {:class (stl/css :sidebar-header)} [:div {:class (stl/css :sidebar-header)}
[:& title-bar {:collapsable true [:& title-bar {:collapsable true
:collapsed (not @open?) :collapsed (not @open?)