Skip to content

Commit f86fde2

Browse files
authored
Merge branch 'develop' into 17433-composer-expanded-on-cancel
2 parents 99250ea + 0eef520 commit f86fde2

File tree

26 files changed

+205
-161
lines changed

26 files changed

+205
-161
lines changed

src/quo/components/avatars/wallet_user_avatar.cljs

-68
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(ns quo.components.avatars.wallet-user-avatar.component-spec
2+
(:require [quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
3+
[test-helpers.component :as h]))
4+
5+
(h/describe "wallet user avatar"
6+
(h/describe "View internal"
7+
(h/test "Renders by default even with no input parameters"
8+
(h/render
9+
[wallet-user-avatar/wallet-user-avatar {}])
10+
(h/is-truthy (h/query-by-label-text :wallet-user-avatar)))
11+
12+
(h/test "Renders user’s initials when full name is provided"
13+
(h/render
14+
[wallet-user-avatar/wallet-user-avatar {:full-name "Jane Smith"}])
15+
(h/is-truthy (h/get-by-text "JS")))))
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(ns quo.components.avatars.wallet-user-avatar.style
2+
(:require [quo.foundations.colors :as colors]))
3+
4+
(defn- circle-color
5+
[customization-color]
6+
(colors/custom-color customization-color 50 20))
7+
8+
(defn- text-color
9+
[customization-color theme]
10+
(colors/theme-colors
11+
(colors/custom-color customization-color 50)
12+
(colors/custom-color customization-color 60)
13+
theme))
14+
15+
(defn container
16+
[circle-size customization-color]
17+
{:width circle-size
18+
:height circle-size
19+
:border-radius circle-size
20+
:text-align :center
21+
:justify-content :center
22+
:align-items :center
23+
:background-color (circle-color customization-color)})
24+
25+
(defn text
26+
[customization-color theme]
27+
{:color (text-color customization-color theme)})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
(ns quo.components.avatars.wallet-user-avatar.view
2+
(:require [quo.components.avatars.wallet-user-avatar.style :as style]
3+
[quo.components.markdown.text :as text]
4+
[quo.theme :as quo.theme]
5+
[react-native.core :as rn]
6+
utils.string))
7+
8+
(def properties
9+
{:size-20 {:size 20
10+
:font-size :label
11+
:font-weight :medium}
12+
:size-24 {:size 24
13+
:font-size :label
14+
:font-weight :semi-bold}
15+
:size-32 {:size 32
16+
:font-size :paragraph-2
17+
:font-weight :semi-bold}
18+
:size-48 {:size 48
19+
:font-size :paragraph-1
20+
:font-weight :semi-bold}
21+
:size-64 {:size 64
22+
:font-size :paragraph-1
23+
:font-weight :medium}
24+
:size-80 {:size 80
25+
:font-size :heading-1
26+
:font-weight :medium}})
27+
28+
(def smallest-possible (first (keys properties)))
29+
(def second-smallest-possible (second (keys properties)))
30+
(defn check-if-size-small
31+
[size]
32+
(or (= size smallest-possible)
33+
(= size second-smallest-possible)))
34+
(def biggest-possible (last (keys properties)))
35+
36+
(defn- view-internal
37+
"Options:
38+
39+
:full-name - string (default: nil) - used to generate initials
40+
:customization-color - keyword (default: nil) - color of the avatar
41+
:size - keyword (default: last element of properties object) - size of the
42+
avatar
43+
:monospace? - boolean (default: false) - use monospace font"
44+
[{:keys [full-name customization-color size theme monospace?]
45+
:or {size biggest-possible}}]
46+
(let [circle-size (:size (size properties))
47+
small? (check-if-size-small size)]
48+
[rn/view
49+
{:style (style/container circle-size customization-color)}
50+
[text/text
51+
{:accessibility-label :wallet-user-avatar
52+
:size (:font-size (size properties))
53+
:weight (if monospace? :monospace (:font-weight (size properties)))
54+
:style (style/text customization-color theme)}
55+
(utils.string/get-initials full-name (if small? 1 2))]]))
56+
57+
(def wallet-user-avatar (quo.theme/with-theme view-internal))

src/quo/components/list_items/address/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns quo.components.list-items.address.view
22
(:require
33
[clojure.string :as string]
4-
[quo.components.avatars.wallet-user-avatar :as wallet-user-avatar]
4+
[quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
55
[quo.components.list-items.address.style :as style]
66
[quo.components.markdown.text :as text]
77
[quo.foundations.colors :as colors]

src/quo/components/list_items/saved_address/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns quo.components.list-items.saved-address.view
22
(:require
33
[clojure.string :as string]
4-
[quo.components.avatars.wallet-user-avatar :as wallet-user-avatar]
4+
[quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
55
[quo.components.icon :as icon]
66
[quo.components.list-items.saved-address.style :as style]
77
[quo.components.markdown.text :as text]

src/quo/components/list_items/user_list.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
{:size 20
2828
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}]
2929
:checkbox
30-
[selectors/checkbox
31-
{:checked? checked?
30+
[selectors/view
31+
{:type :checkbox
32+
:checked? checked?
3233
:accessibility-label :user-list-toggle-check
3334
:disabled? disabled?
3435
:on-change (when on-check on-check)}]

src/quo/components/selectors/disclaimer/view.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
{:on-press on-change
1212
:accessibility-label :disclaimer-touchable-opacity}
1313
[rn/view {:style (merge container-style (style/container blur?))}
14-
[selectors/checkbox
15-
{:accessibility-label accessibility-label
14+
[selectors/view
15+
{:type :checkbox
16+
:accessibility-label accessibility-label
1617
:blur? blur?
1718
:checked? checked?
1819
:on-change on-change}]

src/quo/components/selectors/selectors/component_spec.cljs

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66

77
(defn render-toggle
88
([]
9-
(render-toggle {}))
9+
(render-toggle {:type :toggle}))
1010
([opts]
11-
(h/render (reagent/as-element [selectors/toggle opts]))))
11+
(h/render (reagent/as-element [selectors/view (assoc opts :type :toggle)]))))
1212

1313
(defn render-checkbox
1414
([]
15-
(render-checkbox {}))
15+
(render-checkbox {:type :checkbox}))
1616
([opts]
17-
(h/render (reagent/as-element [selectors/checkbox opts]))))
17+
(h/render (reagent/as-element [selectors/view (assoc opts :type :checkbox)]))))
1818

19-
(defn render-checkbox-prefill
19+
(defn render-filled-checkbox
2020
([]
21-
(render-checkbox-prefill {}))
21+
(render-filled-checkbox {:type :filled-checkbox}))
2222
([opts]
23-
(h/render (reagent/as-element [selectors/checkbox-prefill opts]))))
23+
(h/render (reagent/as-element [selectors/view (assoc opts :type :filled-checkbox)]))))
2424

2525
(defn render-radio
2626
([]
27-
(render-radio {}))
27+
(render-radio {:type :radio}))
2828
([opts]
29-
(h/render (reagent/as-element [selectors/radio opts]))))
29+
(h/render (reagent/as-element [selectors/view (assoc opts :type :radio)]))))
3030

3131
(h/test "default render of toggle component"
3232
(render-toggle)
@@ -58,12 +58,12 @@
5858
(h/fire-event :press (h/get-by-test-id "checkbox-component"))
5959
(h/was-called mock-fn)))
6060

61-
(h/test "default render of checkbox-prefill component"
62-
(render-checkbox-prefill)
63-
(h/is-truthy (h/get-by-test-id "checkbox-prefill-component")))
61+
(h/test "default render of filled-checkbox component"
62+
(render-filled-checkbox)
63+
(h/is-truthy (h/get-by-test-id "filled-checkbox-component")))
6464

65-
(h/test "checkbox-prefill component on change is working"
65+
(h/test "filled-checkbox component on change is working"
6666
(let [mock-fn (h/mock-fn)]
67-
(render-checkbox-prefill {:on-change mock-fn})
68-
(h/fire-event :press (h/get-by-test-id "checkbox-prefill-component"))
67+
(render-filled-checkbox {:on-change mock-fn})
68+
(h/fire-event :press (h/get-by-test-id "filled-checkbox-component"))
6969
(h/was-called mock-fn)))

src/quo/components/selectors/selectors/style.cljs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[customization-color theme]
77
{:normal {:checked (colors/resolve-color customization-color theme)
88
:unchecked (colors/theme-colors colors/neutral-30 colors/neutral-80 theme)}
9-
:blur {:checked (colors/theme-colors (colors/custom-color customization-color 50)
9+
:blur {:checked (colors/theme-colors (colors/resolve-color customization-color theme)
1010
colors/white-opa-70
1111
theme)
1212
:unchecked (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-10 theme)}})
@@ -15,7 +15,7 @@
1515
[customization-color theme]
1616
{:normal {:checked (colors/resolve-color customization-color theme)
1717
:unchecked (colors/theme-colors colors/neutral-30 colors/neutral-70 theme)}
18-
:blur {:checked (colors/theme-colors (colors/custom-color customization-color 50)
18+
:blur {:checked (colors/theme-colors (colors/resolve-color customization-color theme)
1919
colors/white
2020
theme)
2121
:unchecked (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-40 theme)}})
@@ -29,7 +29,7 @@
2929
[customization-color theme]
3030
{:normal {:checked (colors/resolve-color customization-color theme)
3131
:unchecked (colors/theme-colors colors/white-opa-40 colors/neutral-80-opa-40 theme)}
32-
:blur {:checked (colors/theme-colors (colors/custom-color customization-color 50)
32+
:blur {:checked (colors/theme-colors (colors/resolve-color customization-color theme)
3333
colors/white)
3434
:unchecked colors/white-opa-5}})
3535

@@ -38,7 +38,7 @@
3838
{:normal (colors/theme-colors colors/neutral-30 colors/neutral-70 theme)
3939
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-40 theme)})
4040

41-
(defn- checkbox-prefill-background-color
41+
(defn- filled-checkbox-background-color
4242
[theme]
4343
{:normal (colors/theme-colors colors/neutral-30 colors/neutral-80 theme)
4444
:blur (colors/theme-colors colors/neutral-80-opa-10 colors/white-opa-10 theme)})
@@ -119,16 +119,16 @@
119119
(colors/theme-colors colors/white colors/neutral-100 theme)
120120
colors/white)})
121121

122-
(defn checkbox-prefill
122+
(defn filled-checkbox
123123
[{:keys [disabled? blur? container-style theme]}]
124124
(assoc container-style
125125
:height 21
126126
:width 21
127127
:border-radius 6
128128
:opacity (if disabled? 0.3 1)
129-
:background-color (get-color (checkbox-prefill-background-color theme) blur?)))
129+
:background-color (get-color (filled-checkbox-background-color theme) blur?)))
130130

131-
(defn checkbox-prefill-check
131+
(defn filled-checkbox-check
132132
[checked? _blur? theme]
133133
{:size 20
134134
:color (when checked? (colors/theme-colors colors/neutral-100 colors/white theme))})

0 commit comments

Comments
 (0)