|
| 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.text :as text])) |
| 7 | + |
| 8 | +(def themes {:light {:background-color colors/neutral-20} |
| 9 | + :dark {:background-color colors/neutral-80}}) |
| 10 | + |
| 11 | +(defn get-value-from-size [size, big-option, small-option] |
| 12 | + (if (= size :big) big-option small-option)) |
| 13 | + |
| 14 | +(defn style-container [size border-color is-required] |
| 15 | + (merge {:height 32 |
| 16 | + :min-width (get-value-from-size size 94 76) |
| 17 | + :align-items :center |
| 18 | + :flex-direction :row |
| 19 | + :left 0 |
| 20 | + :border-radius 100 |
| 21 | + :padding-right 10} |
| 22 | + (if is-required {:border-color border-color |
| 23 | + :border-width 1} {}))) |
| 24 | + |
| 25 | +(defn token-tag |
| 26 | + "[token-tag opts \"label\"] |
| 27 | + opts |
| 28 | + { |
| 29 | + :token string |
| 30 | + :value string |
| 31 | + :size :small/:big |
| 32 | + :icon-name :icon-name |
| 33 | + :border-color :color |
| 34 | + :is-required true/false |
| 35 | + :is-purchasable true/false |
| 36 | + }" |
| 37 | + [_ _] |
| 38 | + (fn [{:keys [token value size icon-name border-color is-required is-purchasable] :or {size :small}}] |
| 39 | + [rn/view {:style (merge (style-container size border-color is-required) (get-in themes [(theme/get-theme)]))} |
| 40 | + |
| 41 | + [rn/view {:style {:margin-left 2 |
| 42 | + :margin-right (get-value-from-size size 8 6)}} |
| 43 | + [icons/icon icon-name {:no-color true |
| 44 | + :size 24}]] |
| 45 | + |
| 46 | + [text/text {:weight :medium |
| 47 | + :number-of-lines 1 |
| 48 | + :size (get-value-from-size size :paragraph-2 :label) |
| 49 | + :padding 2 |
| 50 | + :padding-top 12 |
| 51 | + :margin-right (get-value-from-size size 12 10)} value " " token] |
| 52 | + (when (or is-required is-purchasable) [rn/view {:style {:display :flex |
| 53 | + :align-items :center |
| 54 | + :justify-content :center |
| 55 | + :position :absolute |
| 56 | + :background-color (if is-required border-color colors/neutral-50) |
| 57 | + :border-radius 100 |
| 58 | + :border-color (if (= (theme/get-theme) :dark) colors/black colors/white) |
| 59 | + :border-width 1 |
| 60 | + :right -20 |
| 61 | + :bottom 16 |
| 62 | + :margin-left 2 |
| 63 | + :margin-right (get-value-from-size size 8 6)}} |
| 64 | + |
| 65 | + (when is-required [icons/icon :main-icons2/checkmark {:color colors/white |
| 66 | + :size 4}]) |
| 67 | + (when is-purchasable [icons/icon :main-icons2/add {:color colors/white |
| 68 | + :size 4}])])])) |
0 commit comments