From decd3e34430e7db30626eab5bcd26d0704a77799 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 26 Mar 2020 08:36:08 +0100 Subject: [PATCH] :fire: changes to effects --- .../main/partials/workspace-libraries.scss | 1 + .../main/ui/components/tab_container.cljs | 4 +-- .../main/ui/workspace/sidebar/libraries.cljs | 32 +++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/frontend/resources/styles/main/partials/workspace-libraries.scss b/frontend/resources/styles/main/partials/workspace-libraries.scss index b48f513ad..9415c2fc3 100644 --- a/frontend/resources/styles/main/partials/workspace-libraries.scss +++ b/frontend/resources/styles/main/partials/workspace-libraries.scss @@ -107,6 +107,7 @@ } .library-tab-libraries { + background-color: #303236; margin: 0.5rem; width: 90%; padding: 0.5rem; diff --git a/frontend/src/uxbox/main/ui/components/tab_container.cljs b/frontend/src/uxbox/main/ui/components/tab_container.cljs index 2c081ccf6..78accbbcc 100644 --- a/frontend/src/uxbox/main/ui/components/tab_container.cljs +++ b/frontend/src/uxbox/main/ui/components/tab_container.cljs @@ -8,7 +8,6 @@ (mf/defc tab-container [{:keys [children selected on-change-tab]}] - (.log js/console (map #(-> % .-props .-title) children)) (let [first-id (-> children first .-props .-id) state (mf/use-state {:selected first-id}) selected (or selected (:selected @state)) @@ -20,7 +19,8 @@ [:div.tab-container-tabs (for [tab children] [:div.tab-container-tab-title - {:on-click (partial handle-select tab) + {:key (str "tab-" (-> tab .-props .-id)) + :on-click (partial handle-select tab) :class (when (= selected (-> tab .-props .-id)) "current")} (-> tab .-props .-title)])] [:div.tab-container-content diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/libraries.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/libraries.cljs index df6884f13..a61463c1d 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/libraries.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/libraries.cljs @@ -41,9 +41,8 @@ (mf/defc icons-tab [{:keys [libraries]}] (when (and libraries (-> libraries count (> 0))) (let [state (mf/use-state {:selected-library (-> libraries first :id)})] - (mf/use-effect {:fn (fn [] - (st/emit! (dlib/retrieve-library-data :icons (:selected-library @state)))) - :deps (mf/deps (:selected-library @state))}) + (mf/use-effect (mf/deps (:selected-library @state)) + #(st/emit! (dlib/retrieve-library-data :icons (:selected-library @state)))) [:div.library-tab.icons-tab [:select.input-select.library-tab-libraries @@ -67,9 +66,8 @@ (mf/defc images-tab [{:keys [libraries]}] (when (and libraries (-> libraries count (> 0))) (let [state (mf/use-state {:selected-library (-> libraries first :id)})] - (mf/use-effect {:fn (fn [] - (st/emit! (dlib/retrieve-library-data :images (:selected-library @state)))) - :deps (mf/deps (:selected-library @state))}) + (mf/use-effect (mf/deps (:selected-library @state)) + #(st/emit! (dlib/retrieve-library-data :images (:selected-library @state)))) [:div.library-tab.images-tab [:select.input-select.library-tab-libraries @@ -91,16 +89,17 @@ [{:keys [key]}] (let [team-id (-> project-ref mf/deref :team-id) locale (i18n/use-locale)] - (mf/use-effect {:fn (fn [] - (st/emit! (dlib/retrieve-libraries :icons)) - (st/emit! (dlib/retrieve-libraries :images))) - :deps (mf/deps key)}) - (mf/use-effect {:fn (fn [] - (when team-id - (do - (st/emit! (dlib/retrieve-libraries :icons team-id)) - (st/emit! (dlib/retrieve-libraries :images team-id))))) - :deps (mf/deps team-id)}) + (mf/use-effect + (mf/deps key) + #(do + (st/emit! (dlib/retrieve-libraries :icons)) + (st/emit! (dlib/retrieve-libraries :images)))) + (mf/use-effect + (mf/deps team-id) + #(when team-id + (do + (st/emit! (dlib/retrieve-libraries :icons team-id)) + (st/emit! (dlib/retrieve-libraries :images team-id))))) [:div#libraries.tool-window [:div.libraries-window-bar [:div.libraries-window-bar-title "Libraries"] @@ -118,3 +117,4 @@ {:id :images :title "Images"} [:& images-tab {:libraries (-> (libraries-ref :images) mf/deref vals flatten)}]]]]])) +