-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
132 additions
and
27 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 39 additions & 1 deletion
40
src/quo2/components/wallet/network_bridge/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 |
---|---|---|
@@ -1 +1,39 @@ | ||
(ns quo2.components.wallet.network-bridge.component-spec) | ||
(ns quo2.components.wallet.network-bridge.component-spec | ||
(:require [test-helpers.component :as h] | ||
[quo2.components.wallet.network-bridge.view :as network-bridge])) | ||
|
||
(h/describe "Wallet: Network Bridge" | ||
(h/test "Amount renders" | ||
(h/render [network-bridge/network-bridge | ||
{:amount "50 SNT" | ||
:network :ethereum | ||
:state :default}]) | ||
(h/is-truthy (h/get-by-text "50 SNT"))) | ||
|
||
(h/test "Network label renders" | ||
(h/render [network-bridge/network-bridge | ||
{:amount "50 SNT" | ||
:network :optimism | ||
:state :default}]) | ||
(h/is-truthy (h/get-by-text "Optimism"))) | ||
|
||
(h/test "Locked state" | ||
(h/render [network-bridge/network-bridge | ||
{:amount "50 SNT" | ||
:network :optimism | ||
:state :locked}]) | ||
(h/is-truthy (h/get-by-label-text :lock))) | ||
|
||
(h/test "Loading state" | ||
(h/render [network-bridge/network-bridge | ||
{:amount "50 SNT" | ||
:network :optimism | ||
:state :loading}]) | ||
(h/is-truthy (h/get-by-label-text :loading))) | ||
|
||
(h/test "Disabled state" | ||
(h/render [network-bridge/network-bridge | ||
{:amount "50 SNT" | ||
:network :optimism | ||
:state :disabled}]) | ||
(h/has-style (h/get-by-label-text :container) {:opacity 0.3}))) |
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 |
---|---|---|
@@ -1 +1,26 @@ | ||
(ns quo2.components.wallet.network-bridge.style) | ||
(ns quo2.components.wallet.network-bridge.style | ||
(:require [quo2.foundations.colors :as colors])) | ||
|
||
(defn container | ||
[network state] | ||
{:width 136 | ||
:height 44 | ||
:border-width 1 | ||
:border-radius 12 | ||
:padding-vertical 5 | ||
:padding-horizontal 8 | ||
:border-color (get colors/networks network) | ||
:opacity (when (= state :disabled) 0.3)}) | ||
|
||
(defn loading-skeleton | ||
[theme] | ||
{:width 32 | ||
:height 10 | ||
:border-radius 3 | ||
:margin-vertical 4 | ||
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-90 theme)}) | ||
|
||
(def network-icon | ||
{:width 12 | ||
:height 12 | ||
:margin-right 4}) |
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 |
---|---|---|
@@ -1,22 +1,45 @@ | ||
(ns quo2.components.wallet.network-bridge.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])) | ||
|
||
|
||
[react-native.core :as rn] | ||
[quo2.components.wallet.network-bridge.style :as style])) | ||
|
||
(defn network-bridge-internal | ||
[] | ||
(let [network :ethereum] | ||
[rn/view {:style {:width 136 | ||
:height 44 | ||
:border-width 1 | ||
:border-radius 12 | ||
:padding-vertical 5 | ||
:padding-horizontal 8 | ||
:border-color (get colors/networks network)}} [text/text {:size :paragraph-2 | ||
:weight :medium} "50 SNT"]])) | ||
[{:keys [theme network state amount]}] | ||
(let [network-text (if (= network :ethereum) "Mainnet" (string/capitalize (name network)))] | ||
[rn/view | ||
{:style (style/container network state) | ||
:accessibility-label :container} | ||
(if (= state :loading) | ||
[rn/view | ||
{:style (style/loading-skeleton theme) | ||
:accessibility-label :loading}] | ||
[rn/view | ||
{:style {:flex-direction :row | ||
:justify-content :space-between}} | ||
[text/text | ||
{:size :paragraph-2 | ||
:weight :medium} amount] | ||
(when (= state :locked) | ||
[icon/icon :i/locked | ||
{:size 12 | ||
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme) | ||
:accessibility-label :lock}])]) | ||
[rn/view | ||
{:style {:flex-direction :row | ||
:align-items :center}} | ||
[rn/image | ||
{:source (resources/networks network) | ||
:style style/network-icon}] | ||
[text/text | ||
{:size :label | ||
:weight :medium | ||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} | ||
network-text]]])) | ||
|
||
(def network-bridge (quo.theme/with-theme network-bridge-internal)) |
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