File tree 8 files changed +182
-0
lines changed
8 files changed +182
-0
lines changed Original file line number Diff line number Diff line change
1
+ (ns quo2.components.tag
2
+ (:require [quo.react-native :as rn]
3
+ [quo2.foundations.colors :as colors]
4
+ [quo.theme :as theme]
5
+ [quo2.components.text :as text]))
6
+
7
+ (def themes {:light {:background-color colors/neutral-20}
8
+ :dark {:background-color colors/neutral-80}})
9
+
10
+ (defn get-value-from-size [size big-option small-option]
11
+ (if (= size :big ) big-option small-option))
12
+
13
+ (defn tag-container [size]
14
+ {:height (get-value-from-size size 32 24 )
15
+ :align-items :center
16
+ :flex-direction :row
17
+ :border-radius 20 })
18
+
19
+ (defn tag " [tag opts \" label\" ]]
20
+ opts
21
+ {
22
+ :size :small/:big
23
+ :token-img-src :token-img-src
24
+ :token-img-style {}
25
+ :border-color :color
26
+ :overlay child-elements
27
+ }"
28
+ [_ _]
29
+ (fn [{:keys [size token-img-src token-img-style border-color overlay]
30
+ :or {size :small }} label]
31
+ [rn/view
32
+ {:style (when border-color
33
+ {:border-color border-color
34
+ :border-radius 20
35
+ :border-width 1 })}
36
+ [rn/view
37
+ {:style (merge (tag-container size) (get themes (theme/get-theme )))}
38
+ [rn/image
39
+ {:source token-img-src
40
+ :style (merge
41
+ {:height (get-value-from-size size 28 20 )
42
+ :width (get-value-from-size size 28 20 )
43
+ :margin-left 2
44
+ :margin-right (get-value-from-size size 8 6 )} token-img-style)}]
45
+ [text/text
46
+ {:weight :medium
47
+ :number-of-lines 1
48
+ :style
49
+ {:margin-right (get-value-from-size size 12 11 )}
50
+ :size (get-value-from-size size :paragraph-2 :label )} label]
51
+ overlay]]))
Original file line number Diff line number Diff line change
1
+ (ns quo2.components.token-tag
2
+ (:require [quo2.foundations.colors :as colors]
3
+ [quo.react-native :as rn]
4
+ [quo.theme :as theme]
5
+ [status-im.ui.components.icons.icons :as icons]
6
+ [quo2.components.tag :as tag]))
7
+
8
+ (defn get-value-from-size [size big-option small-option]
9
+ (if (= size :big ) big-option small-option))
10
+
11
+ (def icon-container-styles
12
+ {:display :flex
13
+ :align-items :center
14
+ :justify-content :center
15
+ :position :absolute
16
+ :border-radius 20
17
+ :margin-left 2 })
18
+
19
+ (defn token-tag
20
+ " [token-tag opts]
21
+ opts
22
+ {
23
+ :token string
24
+ :value string
25
+ :size :small/:big
26
+ :token-img-src :token-img-src
27
+ :border-color :color
28
+ :is-required true/false
29
+ :is-purchasable true/false
30
+ }"
31
+ [_ _]
32
+ (fn [{:keys [token value size token-img-src border-color is-required is-purchasable]
33
+ :or
34
+ {size :small border-color (if (= (theme/get-theme ) :dark ) colors/purple-60 colors/purple-50)}}]
35
+
36
+ [tag/tag {:size size
37
+ :token-img-src token-img-src
38
+ :border-color (when is-required border-color)
39
+ :overlay
40
+ (when (or is-required is-purchasable)
41
+ [rn/view
42
+ {:style (merge icon-container-styles
43
+ {:width 15.5
44
+ :height 15.5
45
+ :background-color border-color
46
+ :border-color (if (= (theme/get-theme ) :dark ) colors/black colors/white)
47
+ :border-width 1
48
+ :right (get-value-from-size size -3.75 -5.75 )
49
+ :bottom (get-value-from-size size (- 32 7.75 4 ) (- 24 7.75 2 )) ; (- height (icon-height/2) spacing)
50
+ })}
51
+ [icons/icon (if is-required :main-icons2/required-checkmark12 :main-icons2/purchasable12 )
52
+ {:no-color true
53
+ :width 13.5
54
+ :height 13.5 }]])}
55
+ (str value " " token)]))
Original file line number Diff line number Diff line change 12
12
[quo2.screens.user-avatar :as user-avatar]
13
13
[quo2.screens.group-avatar :as group-avatar]
14
14
[quo2.screens.activity-logs :as activity-logs]
15
+ [quo2.screens.token-tag :as token-tag]
15
16
[quo2.screens.counter :as counter]
16
17
[quo2.screens.segmented :as segmented]
17
18
[quo2.screens.info-message :as info-message]
43
44
{:name :quo2-tabs
44
45
:insets {:top false }
45
46
:component tabs/preview-tabs}
47
+ <<<<<<< HEAD
46
48
{:name :quo2-user-avatar
47
49
:insets {:top false }
48
50
:component user-avatar/preview-user-avatar}
51
+ =======
52
+ {:name :quo2-token-tag
53
+ :insets {:top false }
54
+ :component token-tag/preview-token-tag}
55
+ >>>>>>> 47 a31ae0a (feat: add token tag component (#13599 ) (#13644 ))
49
56
{:name :quo2-segmented
50
57
:insets {:top false }
51
58
:component segmented/preview-segmented}
Original file line number Diff line number Diff line change
1
+ (ns quo2.screens.token-tag
2
+ (:require [quo.react-native :as rn]
3
+ [quo.previews.preview :as preview]
4
+ [reagent.core :as reagent]
5
+ [quo2.components.token-tag :as quo2]
6
+ [quo.design-system.colors :as colors]))
7
+
8
+ (def descriptor [{:label " Size:"
9
+ :key :size
10
+ :type :select
11
+ :options [{:key :big
12
+ :value " big" }
13
+ {:key :small
14
+ :value " small" }]}
15
+ {:label " Value:"
16
+ :key :value
17
+ :type :select
18
+ :options [{:key 0
19
+ :value " 0" }
20
+ {:key 10
21
+ :value " 10" }
22
+ {:key 100
23
+ :value " 100" }
24
+ {:key 1000
25
+ :value " 1000" }
26
+ {:key 10000
27
+ :value " 10000" }]}
28
+
29
+ {:label " Community Color:"
30
+ :key :border-color
31
+ :type :select
32
+ :options [{:key " #00a191"
33
+ :value " green" }
34
+ {:key " red"
35
+ :value " red" }]}
36
+ {:label " Is Required:"
37
+ :key :is-required
38
+ :type :boolean }
39
+ {:label " Is Purchasable:"
40
+ :key :is-purchasable
41
+ :type :boolean }
42
+ {:label " Token:"
43
+ :key :token
44
+ :type :select
45
+ :options [{:key " ETH"
46
+ :value " ETH" }
47
+ {:key " SNT"
48
+ :value " SNT" }]}])
49
+
50
+ (def eth-token (js/require " ../resources/images/tokens/mainnet/ETH.png" ))
51
+ (def snt-token (js/require " ../resources/images/tokens/mainnet/SNT.png" ))
52
+
53
+ (defn cool-preview []
54
+ (let [state (reagent/atom {:size :big :value 10 :token " ETH" :is-required true :is-purchasable false })]
55
+ (fn []
56
+ [rn/view {:margin-bottom 50
57
+ :padding 16 }
58
+ [preview/customizer state descriptor]
59
+ [rn/view {:padding-vertical 60
60
+ :align-items :center }
61
+ [quo2/token-tag (merge @state {:token-img-src (if (= (get-in @state [:token ]) " ETH" ) eth-token snt-token)})]]])))
62
+
63
+ (defn preview-token-tag []
64
+ [rn/view {:background-color (:ui-background @colors/theme)
65
+ :flex 1 }
66
+ [rn/flat-list {:flex 1
67
+ :keyboardShouldPersistTaps :always
68
+ :header [cool-preview]
69
+ :key-fn str}]])
You can’t perform that action at this time.
0 commit comments