-
Notifications
You must be signed in to change notification settings - Fork 986
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tags - network tags component to quo2
Co-authored-by: andresceballosm <ceballosmarandres@gmail.com>
- Loading branch information
1 parent
a218499
commit 2e63ee8
Showing
8 changed files
with
151 additions
and
9 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
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.tags.network-tags.component-spec | ||
(:require [quo2.components.tags.network-tags.view :as network-tags] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "network-tags component" | ||
(h/test "renders network tags with single network" | ||
(h/render [network-tags/view | ||
{:title "Network Tags" | ||
:networks [{:source "network-icon.png"}]}]) | ||
(h/is-truthy (h/get-by-text "Network Tags"))) | ||
|
||
(h/test "renders network tags with multiple networks" | ||
(h/render [network-tags/view | ||
{:title "Multiple Networks" | ||
:networks [{:source "network-icon1.png"} | ||
{:source "network-icon2.png"} | ||
{:source "network-icon3.png"}] | ||
:size :size/s-32}]) | ||
(h/is-truthy (h/get-by-text "Multiple Networks")))) |
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.tags.network-tags.style | ||
(:require [quo2.foundations.colors :as colors])) | ||
|
||
(defn container | ||
[{:keys [status theme blur?]}] | ||
{:flex-direction :row | ||
:align-self :flex-start | ||
:background-color (when (= status :error) | ||
(colors/theme-colors | ||
(colors/custom-color :danger 50 10) | ||
(colors/custom-color :danger 60 10) | ||
theme)) | ||
:border-width 1 | ||
:border-color (cond (= status :error) | ||
(colors/theme-colors | ||
(colors/custom-color :danger 50 20) | ||
(colors/custom-color :danger 60 20) | ||
theme) | ||
(and blur? (= status :default)) (colors/theme-colors | ||
colors/neutral-80-opa-5 | ||
colors/white-opa-5 | ||
theme) | ||
:else (colors/theme-colors | ||
colors/neutral-20 | ||
colors/neutral-80 | ||
theme)) | ||
:border-radius 8 | ||
:padding-left 5 | ||
:padding-right 5 | ||
:padding-top 3 | ||
:padding-bottom 2}) | ||
|
||
(defn title-style | ||
[{:keys [status theme]}] | ||
{:padding-left 4 | ||
:margin-top -1 | ||
:color (when (= status :error) | ||
(colors/theme-colors | ||
(colors/custom-color :danger 50) | ||
(colors/custom-color :danger 60) | ||
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,25 @@ | ||
(ns quo2.components.tags.network-tags.view | ||
(:require [quo2.components.list-items.preview-list.view :as preview-list] | ||
[quo2.components.tags.network-tags.style :as style] | ||
[quo2.components.markdown.text :as text] | ||
[react-native.core :as rn] | ||
[quo2.theme :as quo.theme])) | ||
|
||
(defn- view-internal | ||
[{:keys [title networks status theme blur?] :or {status :default}}] | ||
[rn/view | ||
{:style (style/container {:status status | ||
:theme theme | ||
:blur? blur?})} | ||
[preview-list/view | ||
{:type :network | ||
:number (count networks) | ||
:size :size/s-16} networks] | ||
[text/text | ||
{:weight :medium | ||
:size :paragraph-2 | ||
:style (style/title-style {:status status | ||
:theme theme})} | ||
title]]) | ||
|
||
(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
51 changes: 51 additions & 0 deletions
51
src/status_im2/contexts/quo_preview/tags/network_tags.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,51 @@ | ||
(ns status-im2.contexts.quo-preview.tags.network-tags | ||
(:require [quo2.core :as quo] | ||
[quo2.foundations.resources :as resources] | ||
[status-im2.contexts.quo-preview.preview :as preview] | ||
[react-native.core :as rn] | ||
[reagent.core :as reagent])) | ||
|
||
(def community-networks | ||
[[{:source (resources/get-network :ethereum)}] | ||
[{:source (resources/get-network :arbitrum)} | ||
{:source (resources/get-network :ethereum)}] | ||
[{:source (resources/get-network :arbitrum)} | ||
{:source (resources/get-network :optimism)} | ||
{:source (resources/get-network :ethereum)}]]) | ||
|
||
(def descriptor | ||
[{:type :select | ||
:key :status | ||
:options [{:key :error} | ||
{:key :default}]} | ||
{:type :text | ||
:key :title} | ||
{:type :select | ||
:key :networks | ||
:options [{:key 1} | ||
{:key 2} | ||
{:key 3}]} | ||
{:type :boolean | ||
:key :blur?}]) | ||
|
||
|
||
(defn preview | ||
[] | ||
(let [state (reagent/atom {:title "Tag" | ||
:status :default | ||
:networks 3})] | ||
(fn [] | ||
[preview/preview-container | ||
{:state state | ||
:descriptor descriptor | ||
:blur? (:blur? @state) | ||
:show-blur-background? true} | ||
[rn/view | ||
{:style {:align-self :center | ||
:justify-content :center | ||
:flex 1}} | ||
[quo/network-tags | ||
{:networks (nth community-networks (dec (:networks @state))) | ||
:status (:status @state) | ||
:title (:title @state) | ||
:blur? (:blur? @state)}]]]))) |