-
Notifications
You must be signed in to change notification settings - Fork 986
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: quo2 wallet - Token Value
- Loading branch information
Showing
10 changed files
with
235 additions
and
3 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/quo2/components/list_items/token_value/component_spec.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns quo2.components.list-items.token-value.component-spec | ||
(:require | ||
[quo2.foundations.colors :as colors] | ||
[test-helpers.component :as h] | ||
[quo2.components.list-items.token-value.view :as token-value])) | ||
|
||
(h/describe "List Items: Token Value" | ||
(h/test "Token label renders" | ||
(h/render [token-value/view | ||
{:token :snt | ||
:state :default | ||
:status :empty | ||
:customization-color :blue | ||
:metrics? true | ||
:values {:crypto-value "0.00" | ||
:fiat-value "€0.00" | ||
:percentage-change "0.00" | ||
:fiat-change "€0.00"}}]) | ||
(h/is-truthy (h/get-by-text "Status"))) | ||
|
||
(h/test "Pressed state" | ||
(h/render [token-value/view | ||
{:token :snt | ||
:state :pressed | ||
:status :empty | ||
:customization-color :blue | ||
:metrics? true | ||
:values {:crypto-value "0.00" | ||
:fiat-value "€0.00" | ||
:percentage-change "0.00" | ||
:fiat-change "€0.00"}}]) | ||
(h/has-style (h/get-by-label-text :container) | ||
{:backgroundColor (colors/custom-color-by-theme :blue 50 50 5 5)})) | ||
|
||
(h/test "Active state" | ||
(h/render [token-value/view | ||
{:token :snt | ||
:state :active | ||
:status :empty | ||
:customization-color :blue | ||
:metrics? true | ||
:values {:crypto-value "0.00" | ||
:fiat-value "€0.00" | ||
:percentage-change "0.00" | ||
:fiat-change "€0.00"}}]) | ||
(h/has-style (h/get-by-label-text :container) | ||
{:backgroundColor (colors/custom-color-by-theme :blue 50 50 10 10)})) | ||
|
||
(h/test "Status change" | ||
(h/render [token-value/view | ||
{:token :snt | ||
:state :default | ||
:status :positive | ||
:customization-color :blue | ||
:metrics? true | ||
:values {:crypto-value "0.00" | ||
:fiat-value "€0.00" | ||
:percentage-change "0.00" | ||
:fiat-change "€0.00"}}]) | ||
(h/is-truthy (h/get-by-label-text :arrow-icon)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(ns quo2.components.list-items.token-value.style | ||
(:require [quo2.foundations.colors :as colors])) | ||
|
||
(defn container | ||
[color bg-opacity theme] | ||
{:width 359 | ||
:height 56 | ||
:padding-horizontal 12 | ||
:padding-vertical 8 | ||
:border-radius 12 | ||
:flex-direction :row | ||
:justify-content :space-between | ||
:background-color (colors/custom-color-by-theme color 50 50 bg-opacity bg-opacity theme)}) | ||
|
||
(defn metric-text | ||
[status theme] | ||
{:color (case status | ||
:positive (colors/theme-colors colors/success-50 colors/success-60 theme) | ||
:negative (colors/theme-colors colors/danger-50 colors/danger-60 theme) | ||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))}) | ||
|
||
(defn dot-divider | ||
[status theme] | ||
{:width 2 | ||
:height 2 | ||
:border-radius 2 | ||
:margin-horizontal 4 | ||
:background-color (case status | ||
:positive (colors/theme-colors colors/success-50-opa-40 | ||
colors/success-60-opa-40 | ||
theme) | ||
:negative (colors/theme-colors colors/danger-50-opa-40 | ||
colors/danger-50-opa-40 | ||
theme) | ||
(colors/theme-colors colors/neutral-80-opa-40 colors/neutral-50-opa-40 theme))}) | ||
|
||
(defn arrow-icon | ||
[status theme] | ||
{:size 16 | ||
:color (if (= status :positive) | ||
(colors/theme-colors colors/success-50 colors/success-60 theme) | ||
(colors/theme-colors colors/danger-50 colors/danger-60 theme))}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns quo2.components.list-items.token-value.view | ||
(:require | ||
[clojure.string :as string] | ||
[quo2.components.icon :as icon] | ||
[quo2.components.markdown.text :as text] | ||
[quo2.foundations.colors :as colors] | ||
[quo2.foundations.resources :as resources] | ||
[quo2.theme :as quo.theme] | ||
[react-native.core :as rn] | ||
[quo2.foundations.common :as common] | ||
[quo2.components.list-items.token-value.style :as style])) | ||
|
||
(defn- internal-view | ||
[{:keys [theme customization-color state status token metrics? values]}] | ||
(let [bg-opacity (case state | ||
:active 10 | ||
:pressed 5 | ||
0) | ||
{:keys [crypto-value fiat-value percentage-change fiat-change]} values] | ||
[rn/view | ||
{:style (style/container customization-color bg-opacity theme) | ||
:accessibility-label :container} | ||
[rn/view | ||
{:style {:flex-direction :row | ||
:align-items :center}} | ||
[rn/image | ||
{:source (resources/tokens token) | ||
:style {:width 32 | ||
:height 32}}] | ||
[rn/view {:style {:margin-left 8}} | ||
[text/text {:weight :semi-bold} (common/token-label token)] | ||
[text/text | ||
{:size :paragraph-2 | ||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} | ||
(str crypto-value " " (string/upper-case (clj->js token)))]]] | ||
[rn/view | ||
{:style {:align-items :flex-end | ||
:justify-content :space-between}} | ||
[text/text | ||
{:weight :medium | ||
:size :paragraph-2} fiat-value] | ||
(when metrics? | ||
[rn/view | ||
{:style {:flex-direction :row | ||
:align-items :center}} | ||
[text/text | ||
{:size :paragraph-2 | ||
:style (style/metric-text status theme)} (str percentage-change "%")] | ||
[rn/view {:style (style/dot-divider status theme)}] | ||
[text/text | ||
{:size :paragraph-2 | ||
:style (style/metric-text status theme)} fiat-change] | ||
(when (not= status :empty) | ||
[rn/view | ||
{:style {:margin-left 4} | ||
:accessibility-label :arrow-icon} | ||
[icon/icon (if (= status :positive) :i/positive :i/negative) | ||
(style/arrow-icon status theme)]])])]])) | ||
|
||
(def view (quo.theme/with-theme internal-view)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ | |
(def currency-label | ||
{:eur "€" | ||
:usd "$"}) | ||
|
||
(def token-label | ||
{:eth "Ethereum" | ||
:snt "Status"}) |
57 changes: 57 additions & 0 deletions
57
src/status_im2/contexts/quo_preview/list_items/token_value.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(ns status-im2.contexts.quo-preview.list-items.token-value | ||
(:require | ||
[quo2.core :as quo] | ||
[react-native.core :as rn] | ||
[reagent.core :as reagent] | ||
[status-im2.contexts.quo-preview.preview :as preview])) | ||
|
||
(def descriptor | ||
[{:label "Token:" | ||
:key :token | ||
:type :select | ||
:options [{:key :eth | ||
:value "ETH"} | ||
{:key :snt | ||
:value "SNT"}]} | ||
{:label "State:" | ||
:key :state | ||
:type :select | ||
:options [{:key :default | ||
:value "Default"} | ||
{:key :pressed | ||
:value "Pressed"} | ||
{:key :active | ||
:value "Active"}]} | ||
{:label "Status:" | ||
:key :status | ||
:type :select | ||
:options [{:key :empty | ||
:value "Empty"} | ||
{:key :positive | ||
:value "Positive"} | ||
{:key :negative | ||
:value "Negative"}]} | ||
(preview/customization-color-option) | ||
{:label "Metrics?:" | ||
:key :metrics? | ||
:type :boolean}]) | ||
|
||
(defn preview | ||
[] | ||
(let [state (reagent/atom {:token :snt | ||
:state :default | ||
:status :empty | ||
:customization-color :blue | ||
:metrics? true | ||
:values {:crypto-value "0.00" | ||
:fiat-value "€0.00" | ||
:percentage-change "0.00" | ||
:fiat-change "€0.00"}})] | ||
(fn [] | ||
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!} | ||
[rn/view | ||
{:style {:flex 1}} | ||
[rn/view {:style {:min-height 300}} [preview/customizer state descriptor]] | ||
[rn/view | ||
{:style {:align-items :center | ||
:margin-top 50}} [quo/token-value @state]]]]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters