Skip to content

Commit

Permalink
Merge branch 'develop' into 17996-cl-biometry-login
Browse files Browse the repository at this point in the history
  • Loading branch information
clauxx authored Dec 6, 2023
2 parents ed5b192 + 390bbdb commit 5f1a7e5
Show file tree
Hide file tree
Showing 30 changed files with 979 additions and 41 deletions.
10 changes: 1 addition & 9 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,7 @@
;; https://github.com/borkdude/clj-kondo/issues/867
:unresolved-symbol {:exclude [PersistentPriorityMap.EMPTY
number
status-im.test-helpers/restore-app-db

;; When the namespace
;; matcher-combinators.test is loaded, it
;; extends cljs.test/is macro with
;; directives `match?` and
;; `thrown-match?`.
match?
thrown-match?]}
status-im.test-helpers/restore-app-db]}
:unresolved-var {:level :error}
:unsorted-required-namespaces {:level :error}
:unused-alias {:level :warning}
Expand Down
4 changes: 4 additions & 0 deletions .clj-kondo/nubank/matcher-combinators/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:linters
{:unresolved-symbol
{:exclude [(cljs.test/is [match? thrown-match?])
(clojure.test/is [match? thrown-match?])]}}}
Binary file added resources/images/icons2/16x16/diamond@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/icons2/16x16/diamond@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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))))
9 changes: 9 additions & 0 deletions src/quo/components/wallet/confirmation_progress/style.cljs
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})
69 changes: 69 additions & 0 deletions src/quo/components/wallet/confirmation_progress/view.cljs
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))
12 changes: 6 additions & 6 deletions src/quo/components/wallet/progress_bar/component_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
:width 8
:borderRadius 3
:borderColor colors/neutral-80-opa-5
:backgroundColor (colors/custom-color (:customization-color props) 50)})))
:backgroundColor (colors/resolve-color (:customization-color props) theme)})))

(h/test "finalized state with customtization-color blue in dark mode"
(let [theme :dark
Expand All @@ -51,7 +51,7 @@
:width 8
:borderRadius 3
:borderColor colors/neutral-80-opa-5
:backgroundColor (colors/custom-color (:customization-color props) 60)})))
:backgroundColor (colors/resolve-color (:customization-color props) theme)})))

(h/test "finalized state with customtization-color army in light mode"
(let [theme :light
Expand All @@ -63,7 +63,7 @@
:width 8
:borderRadius 3
:borderColor colors/neutral-80-opa-5
:backgroundColor (colors/custom-color (:customization-color props) 50)})))
:backgroundColor (colors/resolve-color (:customization-color props) theme)})))

(h/test "confirmed state in light mode"
(let [theme :light
Expand All @@ -75,7 +75,7 @@
:width 8
:borderRadius 3
:borderColor colors/neutral-80-opa-5
:backgroundColor colors/success-50})))
:backgroundColor (colors/resolve-color :success theme)})))

(h/test "confirmed state in dark mode"
(let [theme :dark
Expand All @@ -99,7 +99,7 @@
:width 8
:borderRadius 3
:borderColor colors/neutral-80-opa-5
:backgroundColor colors/danger-50})))
:backgroundColor (colors/resolve-color :danger theme)})))

(h/test "error state in dark mode"
(let [theme :dark
Expand All @@ -111,4 +111,4 @@
:width 8
:borderRadius 3
:borderColor colors/white-opa-5
:backgroundColor colors/danger-60}))))
:backgroundColor (colors/resolve-color :danger theme)}))))
43 changes: 30 additions & 13 deletions src/quo/components/wallet/progress_bar/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,48 @@
[quo.foundations.colors :as colors]))

(defn- border-and-background-color
[customization-color]
[customization-color theme]
{:light {:pending {:border-color colors/neutral-80-opa-5
:background-color colors/neutral-5}
:confirmed {:border-color colors/neutral-80-opa-5
:background-color (colors/custom-color :success 50)}
:background-color (colors/resolve-color :success theme)}
:finalized {:border-color colors/neutral-80-opa-5
:background-color (colors/custom-color customization-color 50)}
:background-color (colors/resolve-color customization-color theme)}
:error {:border-color colors/neutral-80-opa-5
:background-color (colors/custom-color :danger 50)}}
:background-color (colors/resolve-color :danger theme)}}
:dark {:pending {:border-color colors/neutral-70
:background-color colors/neutral-80}
:confirmed {:border-color colors/white-opa-5
:background-color (colors/custom-color :success 60)}
:background-color (colors/resolve-color :success theme)}
:finalized {:border-color colors/neutral-80-opa-5
:background-color (colors/custom-color customization-color 60)}
:background-color (colors/resolve-color customization-color theme)}
:error {:border-color colors/white-opa-5
:background-color (colors/custom-color :danger 60)}}})
:background-color (colors/resolve-color :danger theme)}}})

(def max-value 100)

(defn root-container
[{:keys [customization-color state theme]}]
(let [{:keys [background-color border-color]} (get-in (border-and-background-color customization-color)
[theme state])]
[{:keys [customization-color state theme full-width?]}]
(let [{:keys [background-color border-color]} (get-in (border-and-background-color customization-color
theme)
[theme (if full-width? :pending state)])]
{:height 12
:flex (when full-width? 1)
:width (when (not full-width?) 8)
:border-radius 3
:border-width 1
:border-color border-color
:background-color background-color
:margin-horizontal 1
:margin-vertical 2}))

(defn progressed-bar
[{:keys [customization-color state theme progressed-value]}]
(let [{:keys [background-color]} (get-in (border-and-background-color customization-color theme)
[theme state])
progress (if (> progressed-value max-value) max-value progressed-value)]
{:height 12
:width 8
:margin-top -1
:width (str progress "%")
:border-radius 3
:border-width 1
:border-color border-color
:background-color background-color}))
6 changes: 4 additions & 2 deletions src/quo/components/wallet/progress_bar/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
[react-native.core :as rn]))

(defn- view-internal
[props]
[{:keys [full-width?] :as props}]
[rn/view
{:accessibility-label :progress-bar
:style (style/root-container props)}])
:style (style/root-container props)}
(when full-width?
[rn/view {:style (style/progressed-bar props)}])])

(def view (quo.theme/with-theme view-internal))
Loading

0 comments on commit 5f1a7e5

Please sign in to comment.