mirror of
https://github.com/status-im/status-react.git
synced 2025-02-09 09:34:55 +00:00
fix issue 2
This commit is contained in:
parent
876d9d8eeb
commit
02a1544005
@ -10,29 +10,32 @@
|
|||||||
(defn alpha
|
(defn alpha
|
||||||
[value opacity]
|
[value opacity]
|
||||||
(when value
|
(when value
|
||||||
(if (string/starts-with? value "#")
|
;; https://github.com/status-im/status-mobile/pull/20950#issuecomment-2328228947
|
||||||
(let [hex (string/replace value #"#" "")
|
(let [opacity (if (zero? opacity) 0.002 opacity)]
|
||||||
r (js/parseInt (subs hex 0 2) 16)
|
(if (string/starts-with? value "#")
|
||||||
g (js/parseInt (subs hex 2 4) 16)
|
(let [hex (string/replace value #"#" "")
|
||||||
b (js/parseInt (subs hex 4 6) 16)]
|
r (js/parseInt (subs hex 0 2) 16)
|
||||||
(str "rgba(" r "," g "," b "," opacity ")"))
|
g (js/parseInt (subs hex 2 4) 16)
|
||||||
(let [rgb (string/split value #",")]
|
b (js/parseInt (subs hex 4 6) 16)]
|
||||||
(str (string/join "," (butlast rgb)) "," opacity ")")))))
|
(str "rgba(" r "," g "," b "," opacity ")"))
|
||||||
|
(let [rgb (string/split value #",")]
|
||||||
|
(str (string/join "," (butlast rgb)) "," opacity ")"))))))
|
||||||
|
|
||||||
(defn- alpha-opaque
|
(defn- alpha-opaque
|
||||||
[value opacity]
|
[value opacity]
|
||||||
(when value
|
(when value
|
||||||
(if (string/starts-with? value "#")
|
(let [opacity (if (zero? opacity) 0.002 opacity)]
|
||||||
(let [hex (string/replace value #"#" "")
|
(if (string/starts-with? value "#")
|
||||||
r (- 255 (* opacity (- 255 (js/parseInt (subs hex 0 2) 16))))
|
(let [hex (string/replace value #"#" "")
|
||||||
g (- 255 (* opacity (- 255 (js/parseInt (subs hex 2 4) 16))))
|
r (- 255 (* opacity (- 255 (js/parseInt (subs hex 0 2) 16))))
|
||||||
b (- 255 (* opacity (- 255 (js/parseInt (subs hex 4 6) 16))))]
|
g (- 255 (* opacity (- 255 (js/parseInt (subs hex 2 4) 16))))
|
||||||
(str "rgb(" r "," g "," b ")"))
|
b (- 255 (* opacity (- 255 (js/parseInt (subs hex 4 6) 16))))]
|
||||||
(let [rgb (string/split value #",")
|
(str "rgb(" r "," g "," b ")"))
|
||||||
r (- 255 (* opacity (- 255 (get rgb 0))))
|
(let [rgb (string/split value #",")
|
||||||
g (- 255 (* opacity (- 255 (get rgb 1))))
|
r (- 255 (* opacity (- 255 (get rgb 0))))
|
||||||
b (- 255 (* opacity (- 255 (get rgb 2))))]
|
g (- 255 (* opacity (- 255 (get rgb 1))))
|
||||||
(str "rgb(" r "," g "," b ")")))))
|
b (- 255 (* opacity (- 255 (get rgb 2))))]
|
||||||
|
(str "rgb(" r "," g "," b ")"))))))
|
||||||
|
|
||||||
(def theme-alpha
|
(def theme-alpha
|
||||||
(memoize
|
(memoize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user