diff --git a/src/quo2/foundations/colors.cljs b/src/quo2/foundations/colors.cljs index 6ff1d14280..c7ed53e5c5 100644 --- a/src/quo2/foundations/colors.cljs +++ b/src/quo2/foundations/colors.cljs @@ -272,17 +272,17 @@ ([color suffix] (custom-color color suffix nil)) ([color suffix opacity] - (let [hex? (not (keyword? color)) - color (if (hex-string? (get colors-map color)) - (get colors-map color) - (get-in colors-map [color suffix]))] - (cond - (and opacity hex?) (alpha color (/ opacity 100)) - opacity (alpha color (/ opacity 100)) - hex? color - :else color)))))) + (let [hex? (not (keyword? color)) + resolved-color (cond hex? color + (hex-string? (get colors-map color)) (get colors-map color) + :else (get-in colors-map + [color suffix]))] + (if opacity + (alpha resolved-color (/ opacity 100)) + resolved-color)))))) (defn custom-color-by-theme + "(custom-color-by-theme color suffix-light suffix-dark opacity-light opacity-dark) color :primary/:purple/... suffix-light 50/60 @@ -290,6 +290,7 @@ opacity-light 0-100 (optional) opacity-dark 0-100 (optional) theme :light/:dark (optional)" + {:deprecated true :superseded-by "theme/colors"} ([color suffix-light suffix-dark] (custom-color-by-theme color suffix-light suffix-dark nil nil (theme/get-theme))) ([color suffix-light suffix-dark opacity-light opacity-dark] diff --git a/src/quo2/foundations/colors_test.cljs b/src/quo2/foundations/colors_test.cljs new file mode 100644 index 0000000000..1b7826fd8c --- /dev/null +++ b/src/quo2/foundations/colors_test.cljs @@ -0,0 +1,27 @@ +(ns quo2.foundations.colors-test + (:require [cljs.test :refer-macros [deftest testing is]] + [quo2.foundations.colors :as colors])) + +(deftest custom-color-resolver-test + (testing "community color - resolves a hex string and ignores suffix of 50" + (is (= "#fff" (colors/custom-color "#fff" 50)))) + (testing "community color - resolves a hex string and ignores suffix of 60" + (is (= "#fff" (colors/custom-color "#fff" 60)))) + (testing "user/wallet/chat colors - resolves a keyword from the customization map with suffix 50" + (is (= (get-in colors/customization [:blue 50]) (colors/custom-color :blue 50)))) + (testing "user/wallet/chat colors - resolves a keyword from the colors map with suffix 60" + (is (= (get-in colors/customization [:blue 60]) (colors/custom-color :blue 60)))) + (testing "network colors - resolves a keyword with from the networks map which has no suffix" + (is (= (:ethereum colors/networks) (colors/custom-color :ethereum nil))))) + +(deftest custom-color-resolver-with-opacity-test + (testing "community color with 10% opacity- resolves a hex string and ignores suffix of 50" + (is (= "rgba(255,15,NaN,0.1)" (colors/custom-color "#fff" 50 10)))) + (testing "community color with 10% opacity- resolves a hex string and ignores suffix of 50" + (is (= "rgba(255,15,NaN,0.9)" (colors/custom-color "#fff" 50 90)))) + (testing + "user/wallet/chat colors with 10% opacity - resolves a keyword from the colors map with suffix 50" + (is (= "rgba(42,74,245,0.1)" (colors/custom-color :blue 50 10)))) + (testing + "network colors with 10% opacity - resolves a keyword with from the networks map which has no suffix" + (is (= "rgba(117,142,235,0.1)" (colors/custom-color :ethereum nil 10))))) diff --git a/src/status_im2/contexts/shell/jump_to/utils.cljs b/src/status_im2/contexts/shell/jump_to/utils.cljs index 1c19e9f2d4..72dd630e91 100644 --- a/src/status_im2/contexts/shell/jump_to/utils.cljs +++ b/src/status_im2/contexts/shell/jump_to/utils.cljs @@ -126,7 +126,7 @@ (defn change-shell-status-bar-style [] (rf/dispatch [:change-shell-status-bar-style - (if (or (quo.theme/get-theme) + (if (or (= :dark (quo.theme/get-theme)) (not (home-stack-open?))) :light :dark)]))