-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve #15696 Signed-off-by: yqrashawn <namy.19@gmail.com>
- Loading branch information
Showing
7 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/quo2/components/counter/step/__tests__/step_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,19 @@ | ||
(ns quo2.components.counter.step.--tests--.step-component-spec | ||
(:require [quo2.components.counter.step.view :as step] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "step component" | ||
(h/test "default render of step component" | ||
(h/render [step/step {} nil]) | ||
(-> (h/expect (h/get-by-test-id :step-component)) | ||
(h/is-truthy))) | ||
|
||
(h/test "renders step with a string value" | ||
(h/render [step/step {} "1"]) | ||
(-> (h/expect (h/get-by-text "1")) | ||
(h/is-truthy))) | ||
|
||
(h/test "renders step with an integer value" | ||
(h/render [step/step {} 1]) | ||
(-> (h/expect (h/get-by-text "1")) | ||
(h/is-truthy)))) |
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,41 @@ | ||
(ns quo2.components.counter.step.style | ||
(:require | ||
[quo2.foundations.colors :as colors])) | ||
|
||
(def container-base | ||
{:align-items :center | ||
:justify-content :center | ||
:border-radius 6 | ||
:height 20}) | ||
|
||
(defn neutral-border-color | ||
[in-blur-view? override-theme] | ||
(if in-blur-view? | ||
(colors/theme-colors colors/white-opa-10 colors/neutral-80-opa-5 override-theme) | ||
(colors/theme-colors colors/neutral-20 colors/neutral-80 override-theme))) | ||
|
||
(def active-background-color (colors/custom-color :blue 50 10)) | ||
(def complete-background-color (colors/custom-color :blue 50)) | ||
|
||
(defn container | ||
[size type in-blur-view? override-theme] | ||
(cond-> container-base | ||
(#{1 2} size) (assoc :width 20) | ||
(= size 3) (assoc :width 28) | ||
|
||
(= type :neutral) | ||
(assoc :border-width 1 | ||
:border-color (neutral-border-color in-blur-view? override-theme)) | ||
|
||
(= type :active) | ||
(assoc :background-color active-background-color) | ||
|
||
(= type :complete) | ||
(assoc :background-color complete-background-color))) | ||
|
||
(defn text-color | ||
([type] (text-color type nil)) | ||
([type override-theme] | ||
(case type | ||
(:neutral :active) (colors/theme-colors colors/neutral-100-opa-100 colors/white override-theme) | ||
:complete colors/white))) |
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,23 @@ | ||
(ns quo2.components.counter.step.view | ||
(:require | ||
[quo2.components.counter.step.style :as style] | ||
[quo2.components.markdown.text :as text] | ||
[react-native.core :as rn] | ||
[utils.number :as utils-number])) | ||
|
||
(defn step | ||
[{:keys [type accessibility-label override-theme in-blur-view?]} value] | ||
(let [type (or type :neutral) | ||
value (utils-number/parse-int value) | ||
label (str value) | ||
size (count label) | ||
accessibility-label (or accessibility-label (keyword (str "step-" label)))] | ||
[rn/view | ||
{:test-ID :step-component | ||
:accessible true | ||
:accessibility-label accessibility-label | ||
:style (style/container size type in-blur-view? override-theme)} | ||
[text/text | ||
{:weight :medium | ||
:size :label | ||
:style {:color (style/text-color type override-theme)}} label]])) |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(ns status-im2.contexts.quo-preview.counter.step | ||
(:require [quo2.components.counter.step.view :as quo2] | ||
[quo2.foundations.colors :as colors] | ||
[react-native.core :as rn] | ||
[reagent.core :as reagent] | ||
[status-im2.contexts.quo-preview.preview :as preview])) | ||
|
||
(def descriptor | ||
[{:label "Type:" | ||
:key :type | ||
:type :select | ||
:options [{:key :neutral | ||
:value "Neutral (default)"} | ||
{:key :active | ||
:value "Active"} | ||
{:key :complete | ||
:value "Complete"}]} | ||
{:label "In blur view?" | ||
:key :in-blur-view? | ||
:type :boolean} | ||
{:label "Value" | ||
:key :value | ||
:type :text}]) | ||
|
||
(defn cool-preview | ||
[] | ||
(let [state (reagent/atom {:value 5 :type :neutral :in-blur-view? false})] | ||
(fn [] | ||
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!} | ||
[rn/view {:padding-bottom 150} | ||
[preview/customizer state descriptor] | ||
[rn/view | ||
{:padding-vertical 60 | ||
:align-items :center} | ||
[quo2/step @state (:value @state)]]]]))) | ||
|
||
(defn preview-step | ||
[] | ||
[rn/view | ||
{:background-color (colors/theme-colors colors/white colors/neutral-90) | ||
:flex 1} | ||
[rn/flat-list | ||
{:flex 1 | ||
:keyboard-should-persist-taps :always | ||
:header [cool-preview] | ||
:key-fn str}]]) |
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