-
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.
Quo2: add tags/ tiny tag component (#17613)
Co-authored-by: Rende11 <artamonovn@gmail.com>
- Loading branch information
Showing
6 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
(ns quo2.components.tags.tiny-tag.component-spec | ||
(:require [quo2.components.tags.tiny-tag.view :as tiny-tag] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "Tiny tag component test" | ||
(h/test "1,000 SNT render" | ||
(h/render [tiny-tag/view | ||
{:label "1,000 SNT" | ||
:blur? false}]) | ||
(h/is-truthy (h/get-by-text "1,000 SNT"))) | ||
(h/test "2,000 SNT render with blur" | ||
(h/render [tiny-tag/view | ||
{:label "2,000 SNT" | ||
:blur? true}]) | ||
(h/is-truthy (h/get-by-text "2,000 SNT")))) |
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,33 @@ | ||
(ns quo2.components.tags.tiny-tag.style | ||
(:require [quo2.foundations.colors :as colors])) | ||
|
||
(defn get-border-color | ||
[blur? theme] | ||
(if blur? | ||
(colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-10 theme) | ||
(colors/theme-colors colors/neutral-20 colors/neutral-80 theme))) | ||
|
||
(defn get-label-color | ||
[blur? theme] | ||
(if blur? | ||
(colors/theme-colors colors/neutral-80-opa-70 colors/white-opa-70 theme) | ||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))) | ||
|
||
(def main | ||
{:justify-content :center | ||
:align-items :center | ||
:height 16}) | ||
|
||
(defn inner | ||
[{:keys [blur? theme]}] | ||
{:border-width 1 | ||
:border-radius 6 | ||
:border-color (get-border-color blur? theme) | ||
:justify-content :center | ||
:align-items :center | ||
:padding-left 2 | ||
:padding-right 3}) | ||
|
||
(defn label | ||
[{:keys [blur? theme]}] | ||
{:color (get-label-color blur? 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,17 @@ | ||
(ns quo2.components.tags.tiny-tag.view | ||
(:require [quo2.components.markdown.text :as text] | ||
[quo2.theme :as quo.theme] | ||
[quo2.components.tags.tiny-tag.style :as style] | ||
[react-native.core :as rn])) | ||
|
||
(defn- view-internal | ||
[{:keys [label] :as props}] | ||
[rn/view {:style style/main} | ||
[rn/view {:style (style/inner props)} | ||
[text/text | ||
{:style (style/label props) | ||
:weight :medium | ||
:size :label | ||
:align :center} label]]]) | ||
|
||
(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(ns status-im2.contexts.quo-preview.tags.tiny-tag | ||
(: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 "Blur?" | ||
:key :blur? | ||
:type :boolean} | ||
{:label "Label" | ||
:key :label | ||
:type :text}]) | ||
|
||
(defn preview-tiny-tag | ||
[] | ||
(let [state (reagent/atom {:blur? false | ||
:label "1,000 SNT"})] | ||
(fn [] | ||
[preview/preview-container | ||
{:state state | ||
:descriptor descriptor | ||
:blur? (:blur? @state) | ||
:show-blur-background? true} | ||
[rn/view {:style {:align-items :center}} | ||
[quo/tiny-tag @state]]]))) |