-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement transaction progress component (#17933)
* copy codes * refactor preview * refactor deprecated codes in view * change condition structure in view-internal * comment unused codes * refactor title * fix title style * fix icon style * fix context tag * fix icon and row * refactor icon-internal * rename network-state and network-type * fix progress-container style * fix progress-box-container style * fix progress container naming and style * change progress-bar component * fix progress box component * convert to functional component and bring back the animation * fix progress box for arbitrum-optimism network * fix text-steps * fix status-row * refactor code style * refactor get-network-text * resolve comment * add translations * remove btn-title prop * fix dark mode border color * fix dark mode icon color * move interval to preview * add tests ns * add tests * fix lint issues * fix rendering issue * fix lint issue * add arbitrum and optimism as separate networks * create const for progress percentage * fix progress bar component and preview * refactor text-steps * refactor names * fix lint issues * rename arbitrum-progress-percentage and optimism-progress-percentage * update tests * convert hard-coded color to customization-color * fix progress_bar tests * separate state for each network * add progress percentage for each network and refactor params of functions * separate epoch number for each network * update tests * fix lint issues * refactor codes * fix lint issues * resolve comments * add confirmation progress * use confirmation-progress component in transaction-progress * fix preview * add tests * fix lint issue * resolve comment * refactor networks * change sending state style * update tests * fix lint issues * remove unused code * add helper for calculate counter step * add assoc-props to view-networks * change text-internal props order * fix colors/resolve-color usage * refactor view codes * add get-networks to preview * add max-value to progress bar style * remove threading macros in the previews * remove inline functional components in the previews * remove optimism-arbitrum checks in the view * fix lint issues * add max-progress and min-progress to confirmation-progress * refactor text-steps * fix counter structure in transaction-progress * fix counter structure in confirmation-progress * fix resolve-color usage * fix lint issue * fix tests * resolve comments * fix color issue * fix margins * fix lint issue
- Loading branch information
Showing
18 changed files
with
909 additions
and
22 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.
99 changes: 99 additions & 0 deletions
99
src/quo/components/wallet/confirmation_progress/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,99 @@ | ||
(ns quo.components.wallet.confirmation-progress.component-spec | ||
(:require [quo.core :as quo] | ||
[reagent.core :as reagent] | ||
[test-helpers.component :as h])) | ||
|
||
(defn- get-test-data | ||
[{:keys [state network] | ||
:or {state :pending network :mainnet}}] | ||
{:counter (reagent/atom 0) | ||
:total-box 85 | ||
:progress-value "10" | ||
:network network | ||
:state state | ||
:customization-color :blue}) | ||
|
||
(h/describe "Confirmation Progress" | ||
(h/test "component renders when state is sending and network is optimism" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :sending | ||
:network :optimism})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is confirmed and network is optimism" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :confirmed | ||
:network :optimism})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is finalising and network is optimism" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :finalising | ||
:network :optimism})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is finalized and network is optimism" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :finalized | ||
:network :optimism})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is error and network is optimism" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :error | ||
:network :optimism})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is sending and network is arbitrum" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :sending | ||
:network :arbitrum})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is confirmed and network is arbitrum" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :confirmed | ||
:network :arbitrum})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is finalising and network is arbitrum" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :finalising | ||
:network :arbitrum})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is finalized and network is arbitrum" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :finalized | ||
:network :arbitrum})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is error and network is arbitrum" | ||
(h/render [quo/confirmation-propgress | ||
(get-test-data {:state :error | ||
:network :arbitrum})]) | ||
(h/is-truthy (h/get-by-label-text :progress-box))) | ||
|
||
(h/test "component renders when state is pending and network is mainnet" | ||
(h/render [quo/confirmation-propgress (get-test-data {})]) | ||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) | ||
|
||
(h/test "component renders when state is sending and network is mainnet" | ||
(h/render [quo/confirmation-propgress (get-test-data {:state :sending})]) | ||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) | ||
|
||
(h/test "component renders when state is confirmed and network is mainnet" | ||
(h/render [quo/confirmation-propgress (get-test-data {:state :confirmed})]) | ||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) | ||
|
||
(h/test "component renders when state is finalising and network is mainnet" | ||
(h/render [quo/confirmation-propgress (get-test-data {:state :finalising})]) | ||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) | ||
|
||
(h/test "component renders when state is finalized and network is mainnet" | ||
(h/render [quo/confirmation-propgress (get-test-data {:state :finalized})]) | ||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box))) | ||
|
||
(h/test "component renders when state is error and network is mainnet" | ||
(h/render [quo/confirmation-propgress (get-test-data {:state :error})]) | ||
(h/is-truthy (h/get-by-label-text :mainnet-progress-box)))) |
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,9 @@ | ||
(ns quo.components.wallet.confirmation-progress.style) | ||
|
||
(def progress-box-container | ||
{:flex-direction :row | ||
:align-items :center | ||
:padding-horizontal 12 | ||
:padding-bottom 10 | ||
:padding-top 4 | ||
:flex-wrap :wrap}) |
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,69 @@ | ||
(ns quo.components.wallet.confirmation-progress.view | ||
(:require [quo.components.wallet.confirmation-progress.style :as style] | ||
[quo.components.wallet.progress-bar.view :as progress-box] | ||
[quo.theme :as quo.theme] | ||
[react-native.core :as rn])) | ||
|
||
(def ^:private max-progress 100) | ||
(def ^:private min-progress 0) | ||
|
||
(defn- calculate-box-state | ||
[state counter index] | ||
(cond | ||
(and (= state :sending) (>= counter index) (< index 3)) :confirmed | ||
(and (= state :confirmed) (>= counter index) (< index 5)) :confirmed | ||
(and (= state :finalising) (>= counter index) (< index 5)) :confirmed | ||
(and (= state :finalising) (>= counter index) (> index 4) (< index 20)) :finalized | ||
(and (= state :finalized) (>= counter index) (< index 5)) :confirmed | ||
(and (= state :finalized) (>= counter index) (> index 4)) :finalized | ||
(and (= state :error) (>= counter index) (< index 2)) :error | ||
:else :pending)) | ||
|
||
(defn- calculate-box-state-sidenet | ||
[state] | ||
(case state | ||
:error :error | ||
(:confirmed :finalising :finalized) :finalized | ||
:pending)) | ||
|
||
(defn- calculate-progressed-value | ||
[state progress-value] | ||
(case state | ||
:finalising progress-value | ||
:finalized max-progress | ||
min-progress)) | ||
|
||
(defn- progress-boxes-mainnet | ||
[{:keys [state counter total-box]}] | ||
[rn/view | ||
{:accessibility-label :mainnet-progress-box | ||
:style style/progress-box-container} | ||
(let [numbers (range 1 total-box)] | ||
(doall (for [n numbers] | ||
[progress-box/view | ||
{:state (calculate-box-state state counter n) | ||
:customization-color :blue | ||
:key n}])))]) | ||
|
||
(defn- progress-boxes-sidenet | ||
[{:keys [state progress-value]}] | ||
[rn/view | ||
{:accessibility-label :progress-box | ||
:style style/progress-box-container} | ||
[progress-box/view | ||
{:state (calculate-box-state-sidenet state) | ||
:customization-color :success}] | ||
[progress-box/view | ||
{:state (calculate-box-state-sidenet state) | ||
:full-width? true | ||
:progressed-value (calculate-progressed-value state progress-value) | ||
:customization-color :blue}]]) | ||
|
||
(defn- view-internal | ||
[{:keys [network] :as props}] | ||
(case network | ||
:mainnet [progress-boxes-mainnet props] | ||
(:arbitrum :optimism) [progress-boxes-sidenet props] | ||
nil)) | ||
|
||
(def view (quo.theme/with-theme view-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
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
Oops, something went wrong.