-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2fb6c7
commit 6defa2c
Showing
7 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/quo/components/avatars/dapp_avatar/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,14 @@ | ||
(ns quo.components.avatars.dapp-avatar.component-spec | ||
(:require [quo.components.avatars.dapp-avatar.view :as dapp-avatar] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "Avatars: dApp Avatar" | ||
(h/test "should render correctly without context" | ||
(h/render-with-theme-provider | ||
[dapp-avatar/view {:image "mock-image"}]) | ||
(h/is-truthy (h/get-by-label-text :dapp-avatar))) | ||
|
||
(h/test "should render correctly with context" | ||
(h/render-with-theme-provider | ||
[dapp-avatar/view {:image "mock-image" :network-image "mock-image" :context? true}]) | ||
(h/is-truthy (h/get-by-label-text :dapp-avatar)))) |
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 quo.components.avatars.dapp-avatar.style) | ||
|
||
(def ^:const size 32) | ||
|
||
(def container | ||
{:height size | ||
:width size}) | ||
|
||
(def hole-view | ||
{:width size | ||
:height size}) | ||
|
||
(def context | ||
{:width 16 | ||
:height 16 | ||
:border-radius 8 | ||
:position :absolute | ||
:right -4 | ||
:bottom -4}) | ||
|
||
(def image | ||
{:width size | ||
:height size}) |
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,42 @@ | ||
(ns quo.components.avatars.dapp-avatar.view | ||
(:require [quo.components.avatars.dapp-avatar.style :as style] | ||
[react-native.core :as rn] | ||
[react-native.hole-view :as hole-view] | ||
[react-native.platform :as platform] | ||
[schema.core :as schema])) | ||
|
||
(def ?schema | ||
[:=> | ||
[:catn | ||
[:props | ||
[:map {:closed true} | ||
[:context? {:optional true} [:maybe :boolean]] | ||
[:image :schema.common/image-source] | ||
[:network-image {:optional true} [:maybe :schema.common/image-source]] | ||
[:container-style {:optional true} [:maybe :map]]]]] | ||
:any]) | ||
|
||
(defn- view-internal | ||
[{:keys [context? image network-image container-style]}] | ||
[rn/view | ||
{:style (merge style/container container-style) | ||
:accessibility-label :dapp-avatar} | ||
[hole-view/hole-view | ||
(cond-> {:holes (if context? | ||
[{:x 19 | ||
:y 19 | ||
:width 18 | ||
:height 18 | ||
:borderRadius 9}] | ||
[]) | ||
:style style/hole-view} | ||
platform/android? (assoc :key context?)) | ||
[rn/image | ||
{:source image | ||
:style style/image}]] | ||
(when context? | ||
[rn/image | ||
{:source network-image | ||
:style style/context}])]) | ||
|
||
(def view (schema/instrument #'view-internal ?schema)) |
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
22 changes: 22 additions & 0 deletions
22
src/status_im/contexts/preview/quo/avatars/dapp_avatar.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,22 @@ | ||
(ns status-im.contexts.preview.quo.avatars.dapp-avatar | ||
(:require | ||
[quo.core :as quo] | ||
[quo.foundations.resources :as resources] | ||
[react-native.core :as rn] | ||
[status-im.contexts.preview.quo.preview :as preview])) | ||
|
||
(def descriptor | ||
[{:type :boolean | ||
:key :context?}]) | ||
|
||
(defn view | ||
[] | ||
(let [[state set-state] (rn/use-state {:context? false})] | ||
[preview/preview-container | ||
{:state state | ||
:set-state set-state | ||
:descriptor descriptor} | ||
[quo/dapp-avatar | ||
(assoc state | ||
:network-image (resources/get-network :ethereum) | ||
:image (resources/get-dapp :coingecko))]])) |
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