File tree Expand file tree Collapse file tree 10 files changed +168
-3
lines changed
components/list_items/dapp Expand file tree Collapse file tree 10 files changed +168
-3
lines changed Original file line number Diff line number Diff line change
1
+ (ns quo2.components.list-items.dapp.component-spec
2
+ (:require [quo2.components.list-items.dapp.view :as dapp]
3
+ [test-helpers.component :as h]))
4
+
5
+ (def props
6
+ {:dapp {:avatar nil
7
+ :name " Coingecko"
8
+ :value " coingecko.com" }
9
+ :state :default
10
+ :action :icon
11
+ :blur? false
12
+ :customization-color :blue })
13
+
14
+ (h/describe
15
+ " dApp component test"
16
+ (h/test " default render"
17
+ (h/render [dapp/view props])
18
+ (h/is-truthy (h/get-by-text (:name (:dapp props))))
19
+ (h/is-truthy (h/get-by-text (:value (:dapp props)))))
20
+ (h/test " on-press event"
21
+ (let [mock-fn (h/mock-fn )]
22
+ (h/render [dapp/view (assoc props :on-press-icon mock-fn)])
23
+ (h/fire-event :press (h/get-by-test-id " dapp-component-icon" ))
24
+ (h/was-called mock-fn))))
Original file line number Diff line number Diff line change
1
+ (ns quo2.components.list-items.dapp.style
2
+ (:require [quo2.foundations.colors :as colors]))
3
+
4
+ (defn get-background-color
5
+ [{:keys [pressed? state blur? customization-color theme]}]
6
+ (cond
7
+ (and pressed? (= theme :dark ) blur?) colors/white-opa-5
8
+
9
+ pressed? (colors/theme-colors
10
+ (colors/custom-color customization-color 50 5 )
11
+ (colors/custom-color customization-color 60 5 )
12
+ theme)
13
+
14
+ (and (= state :active ) (= theme :dark ) blur?) colors/white-opa-10
15
+
16
+ (= state :active ) (colors/theme-colors
17
+ (colors/custom-color customization-color 50 10 )
18
+ (colors/custom-color customization-color 60 10 )
19
+ theme)
20
+
21
+ :else :transparent ))
22
+
23
+ (defn container
24
+ [props]
25
+ {:flex 1
26
+ :padding-horizontal 12
27
+ :padding-vertical 8
28
+ :border-radius 12
29
+ :background-color (get-background-color props)
30
+ :flex-direction :row
31
+ :justify-content :space-between
32
+ :align-items :center })
33
+
34
+ (def container-info
35
+ {:flex-direction :row
36
+ :align-items :center })
37
+
38
+ (def user-info
39
+ {:margin-left 8 })
40
+
41
+ (defn style-text-name
42
+ [theme]
43
+ {:color (colors/theme-colors colors/neutral-100 colors/white theme)})
44
+
45
+ (defn style-text-value
46
+ [theme]
47
+ {:color (colors/theme-colors colors/neutral-50 colors/white theme)})
Original file line number Diff line number Diff line change
1
+ (ns quo2.components.list-items.dapp.view
2
+ (:require [quo2.components.icon :as icons]
3
+ [quo2.components.markdown.text :as text]
4
+ [quo2.foundations.colors :as colors]
5
+ [react-native.core :as rn]
6
+ [react-native.fast-image :as fast-image]
7
+ [quo2.components.list-items.dapp.style :as style]
8
+ [quo2.theme :as quo.theme]
9
+ [reagent.core :as reagent]))
10
+
11
+ (defn- view-internal
12
+ []
13
+ (let [pressed? (reagent/atom false )]
14
+ (fn [{:keys [dapp action on-press on-press-icon theme] :as props}]
15
+ [rn/pressable
16
+ {:style (style/container (assoc props :pressed? @pressed?))
17
+ :on-press on-press
18
+ :on-press-in #(reset! pressed? true )
19
+ :on-press-out #(reset! pressed? false )}
20
+ [rn/view {:style style/container-info}
21
+ [fast-image/fast-image
22
+ {:source (:avatar dapp)
23
+ :style {:width 32 :height 32 }}]
24
+ [rn/view {:style style/user-info}
25
+ [text/text
26
+ {:weight :semi-bold
27
+ :size :paragraph-1
28
+ :style (style/style-text-name theme)}
29
+ (:name dapp)]
30
+ [text/text
31
+ {:weight :regular
32
+ :size :paragraph-2
33
+ :style (style/style-text-value theme)}
34
+ (:value dapp)]]]
35
+ (when (= action :icon )
36
+ [rn/pressable
37
+ {:on-press on-press-icon
38
+ :testID " dapp-component-icon" }
39
+ [icons/icon :i/options
40
+ {:color (colors/theme-colors
41
+ colors/neutral-50
42
+ colors/neutral-40
43
+ theme)
44
+ :accessibility-label :icon }]])])))
45
+
46
+ (def view
47
+ (quo.theme/with-theme view-internal))
Original file line number Diff line number Diff line change 62
62
quo2.components.list-items.account-list-card.view
63
63
quo2.components.list-items.channel
64
64
quo2.components.list-items.community.view
65
+ quo2.components.list-items.dapp.view
65
66
quo2.components.list-items.menu-item
66
67
quo2.components.list-items.preview-list
67
68
quo2.components.list-items.token-value.view
110
111
quo2.components.tags.tags
111
112
quo2.components.tags.token-tag
112
113
quo2.components.text-combinations.title.view
113
- quo2.components.wallet.account-overview.view
114
114
quo2.components.wallet.account-card.view
115
+ quo2.components.wallet.account-overview.view
115
116
quo2.components.wallet.keypair.view
116
117
quo2.components.wallet.network-amount.view
117
118
quo2.components.wallet.network-bridge.view
235
236
; ;;; List items
236
237
(def account-list-card quo2.components.list-items.account-list-card.view /view )
237
238
(def channel-list-item quo2.components.list-items.channel /list-item )
239
+ (def dapp quo2.components.list-items.dapp.view /view )
238
240
(def menu-item quo2.components.list-items.menu-item /menu-item )
239
241
(def preview-list quo2.components.list-items.preview-list /preview-list )
240
242
(def user-list quo2.components.list-items.user-list /user-list )
Original file line number Diff line number Diff line change 36
36
[quo2.components.links.url-preview-list.component-spec]
37
37
[quo2.components.links.url-preview.component-spec]
38
38
[quo2.components.list-items.community.component-spec]
39
+ [quo2.components.list-items.dapp.component-spec]
39
40
[quo2.components.list-items.token-value.component-spec]
40
41
[quo2.components.markdown.text-component-spec]
41
42
[quo2.components.markdown.list.component-spec]
55
56
[quo2.components.settings.category.component-spec]
56
57
[quo2.components.share.share-qr-code.component-spec]
57
58
[quo2.components.tags.status-tags-component-spec]
58
- [quo2.components.wallet.account-overview.component-spec]
59
59
[quo2.components.wallet.account-card.component-spec]
60
+ [quo2.components.wallet.account-overview.component-spec]
60
61
[quo2.components.wallet.keypair.component-spec]
61
62
[quo2.components.wallet.network-amount.component-spec]
62
63
[quo2.components.wallet.network-bridge.component-spec]
Original file line number Diff line number Diff line change 52
52
(def mock-images
53
53
{:diamond (js/require " ../resources/images/mock2/diamond.png" )
54
54
:coinbase (js/require " ../resources/images/mock2/coinbase.png" )
55
+ :coin-gecko (js/require " ../resources/images/mock2/coin-gecko.png" )
55
56
:collectible (js/require " ../resources/images/mock2/collectible.png" )
56
57
:contact (js/require " ../resources/images/mock2/contact.png" )
57
58
:community-banner (js/require " ../resources/images/mock2/community-banner.png" )
Original file line number Diff line number Diff line change
1
+ (ns status-im2.contexts.quo-preview.list-items.dapp
2
+ (:require [quo2.core :as quo]
3
+ [react-native.core :as rn]
4
+ [reagent.core :as reagent]
5
+ [status-im2.common.resources :as resources]
6
+ [status-im2.contexts.quo-preview.preview :as preview]))
7
+
8
+ (def descriptor
9
+ [{:key :state
10
+ :type :select
11
+ :options [{:key :default
12
+ :value " Default" }
13
+ {:key :active
14
+ :value " Active" }]}
15
+ {:key :action
16
+ :type :select
17
+ :options [{:key :none
18
+ :value " None" }
19
+ {:key :icon
20
+ :value " Icon" }]}
21
+ {:key :blur?
22
+ :type :boolean }])
23
+
24
+ (defn preview
25
+ []
26
+ (let [state (reagent/atom {:dapp {:avatar (resources/get-mock-image :coin-gecko )
27
+ :name " Coingecko"
28
+ :value " coingecko.com" }
29
+ :state :default
30
+ :action :icon
31
+ :blur? false
32
+ :customization-color :blue
33
+ :on-press-icon (fn [] (js/alert " Button pressed" ))})]
34
+ (fn []
35
+ [preview/preview-container {:state state :descriptor descriptor}
36
+ [rn/view
37
+ {:padding-vertical 60
38
+ :flex-direction :row
39
+ :justify-content :center }
40
+ [quo/dapp @state]]])))
Original file line number Diff line number Diff line change 62
62
[status-im2.contexts.quo-preview.links.link-preview :as link-preview]
63
63
[status-im2.contexts.quo-preview.list-items.account-list-card :as account-list-card]
64
64
[status-im2.contexts.quo-preview.list-items.channel :as channel]
65
+ [status-im2.contexts.quo-preview.list-items.dapp :as dapp]
65
66
[status-im2.contexts.quo-preview.list-items.preview-lists :as preview-lists]
66
67
[status-im2.contexts.quo-preview.list-items.user-list :as user-list]
67
68
[status-im2.contexts.quo-preview.list-items.community-list :as community-list]
111
112
[status-im2.contexts.quo-preview.loaders.skeleton :as skeleton]
112
113
[status-im2.contexts.quo-preview.community.channel-actions :as channel-actions]
113
114
[status-im2.contexts.quo-preview.gradient.gradient-cover :as gradient-cover]
114
- [status-im2.contexts.quo-preview.wallet.account-overview :as account-overview]
115
115
[status-im2.contexts.quo-preview.wallet.account-card :as account-card]
116
+ [status-im2.contexts.quo-preview.wallet.account-overview :as account-overview]
116
117
[status-im2.contexts.quo-preview.wallet.keypair :as keypair]
117
118
[status-im2.contexts.quo-preview.wallet.network-amount :as network-amount]
118
119
[status-im2.contexts.quo-preview.wallet.network-bridge :as network-bridge]
248
249
{:name :community-list
249
250
:options {:insets {:top? true }}
250
251
:component community-list/view}
252
+ {:name :dapp
253
+ :component dapp/preview}
251
254
{:name :preview-lists
252
255
:component preview-lists/preview-preview-lists}
253
256
{:name :user-list
You can’t perform that action at this time.
0 commit comments