-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement "Drawer top" component #17196
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fe06696
draft - add details
mmilad75 19e04d3
complete component
mmilad75 e51a42c
add on-press to button
mmilad75 09b4a15
add tests
mmilad75 3a13161
fix lint issues
mmilad75 7e3bcb3
remove comment
mmilad75 80ba2ac
resolve comments
mmilad75 c69623d
rename account-avatar-customization-color to customization-color
mmilad75 80f6d3c
break down subtitle function
mmilad75 e58d097
fix lint issues
mmilad75 b26e5f3
fix keycard icon
mmilad75 5f59f4d
fix default keypair user avatar
mmilad75 c2a9f51
move profile-picture to component
mmilad75 2ee7942
fix lint issues
mmilad75 91e30a9
Revert "move profile-picture to component"
mmilad75 ab389b9
fix lint issues
mmilad75 825fe39
fix bullet char
mmilad75 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/quo2/components/drawers/drawer_top/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,98 @@ | ||
(ns quo2.components.drawers.drawer-top.component-spec | ||
(:require [test-helpers.component :as h] | ||
[quo2.core :as quo])) | ||
|
||
(h/describe "drawer top tests" | ||
(h/test "component renders in default type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:type :default}]) | ||
(h/is-truthy (h/get-by-text "Title"))) | ||
|
||
(h/test "component renders in default + description type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:type :default | ||
:description "Description"}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-text "Description"))) | ||
|
||
(h/test "component renders in info type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:type :info}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-label-text :info-icon))) | ||
|
||
(h/test "component renders in info + description type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:description "Description" | ||
:type :info}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-text "Description")) | ||
(h/is-truthy (h/get-by-label-text :info-icon))) | ||
|
||
(h/test "component renders in context-tag type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:type :context-tag | ||
:community-name "Coinbase"}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-label-text :context-tag-wrapper))) | ||
|
||
(h/test "component renders in context-tag + button type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:type :context-tag | ||
:button-icon :i/placeholder | ||
:community-name "Coinbase"}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-label-text :button-icon)) | ||
(h/is-truthy (h/get-by-label-text :context-tag-wrapper))) | ||
|
||
(h/test "component renders in account type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:type :account | ||
:account-avatar-emoji "🍿" | ||
:networks [:ethereum] | ||
:description "0x62b...0a5" | ||
:customization-color :purple}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-text "0x62b...0a5")) | ||
(h/is-truthy (h/get-by-label-text :account-avatar))) | ||
|
||
(h/test "component renders in keypair type when keycard? is false" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:keycard? false | ||
:icon-avatar :i/placeholder | ||
:type :keypair}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(-> (h/expect (h/get-by-translation-text :on-device)) | ||
(.toBeTruthy))) | ||
|
||
(h/test "component renders in keypair type when keycard? is true" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:keycard? true | ||
:icon-avatar :i/placeholder | ||
:type :keypair}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(-> (h/expect (h/get-by-translation-text :on-keycard)) | ||
(.toBeTruthy))) | ||
|
||
(h/test "component renders in default-keypair type" | ||
(h/render [quo/drawer-top | ||
{:title "Title" | ||
:description "0x62b...0a5" | ||
:type :default-keypair}]) | ||
(h/is-truthy (h/get-by-text "Title")) | ||
(h/is-truthy (h/get-by-label-text :default-keypair-text))) | ||
|
||
(h/test "component renders in label type" | ||
(h/render [quo/drawer-top | ||
{:label "label" | ||
:type :label}]) | ||
(h/is-truthy (h/get-by-text "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(ns quo2.components.drawers.drawer-top.style | ||
(:require [quo2.foundations.colors :as colors])) | ||
|
||
(def container | ||
{:padding-horizontal 20 | ||
:padding-bottom 12 | ||
:flex-direction :row}) | ||
|
||
(def body-container | ||
{:flex 1}) | ||
|
||
(defn description | ||
[theme blur?] | ||
{:color (if blur? | ||
colors/white-opa-40 | ||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))}) | ||
|
||
(def left-container | ||
{:margin-right 8 | ||
:justify-content :center}) | ||
|
||
(defn network-text-color | ||
[network] | ||
{:color (colors/custom-color network)}) | ||
|
||
(def row | ||
{:flex-direction :row | ||
:align-items :center}) | ||
|
||
(def keycard-icon | ||
{:margin-left 4}) |
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,204 @@ | ||
(ns quo2.components.drawers.drawer-top.view | ||
(:require [quo2.theme :as quo.theme] | ||
[quo2.components.markdown.text :as text] | ||
[quo2.components.drawers.drawer-top.style :as style] | ||
[quo2.components.buttons.button.view :as button] | ||
[quo2.components.tags.context-tag.view :as context-tag] | ||
[react-native.core :as rn] | ||
[quo2.components.icon :as icons] | ||
[quo2.components.avatars.account-avatar.view :as account-avatar] | ||
[quo2.components.avatars.icon-avatar :as icon-avatar] | ||
[quo2.components.avatars.user-avatar.view :as user-avatar] | ||
[quo2.foundations.colors :as colors] | ||
[utils.i18n :as i18n])) | ||
|
||
(defn- left-image | ||
[{:keys [type customization-color account-avatar-emoji icon-avatar profile-picture]}] | ||
(case type | ||
:account [account-avatar/view | ||
{:customization-color customization-color | ||
:size 32 | ||
:emoji account-avatar-emoji | ||
:type :default}] | ||
:keypair [icon-avatar/icon-avatar | ||
{:icon icon-avatar | ||
:border? true | ||
:color :neutral}] | ||
|
||
:default-keypair [user-avatar/user-avatar | ||
{:size :small | ||
:status-indicator? false | ||
:profile-picture profile-picture}] | ||
nil)) | ||
|
||
(defn- network-view | ||
[network] | ||
[text/text | ||
{:size :paragraph-2 | ||
:weight :regular | ||
:style (style/network-text-color network)} | ||
(str (subs (name network) 0 3) ":")]) | ||
|
||
(defn- keypair-subtitle | ||
[{:keys [theme blur? keycard?]}] | ||
[rn/view {:style style/row} | ||
[text/text | ||
{:size :paragraph-2 | ||
:weight :regular | ||
:style (style/description theme blur?)} | ||
(if keycard? | ||
(i18n/label :t/on-keycard) | ||
(i18n/label :t/on-device))] | ||
(when keycard? | ||
[icons/icon | ||
:i/keycard-card | ||
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme) | ||
:size 16 | ||
:container-style style/keycard-icon}])]) | ||
|
||
(defn- acocunt-subtitle | ||
[{:keys [networks theme blur? description]}] | ||
[rn/view {:style style/row} | ||
(for [network networks] | ||
^{:key (str network)} | ||
[network-view network]) | ||
[text/text | ||
{:size :paragraph-2 | ||
:weight :regular | ||
:style (style/description theme blur?)} | ||
description]]) | ||
|
||
(defn- default-keypair-subtitle | ||
[{:keys [description theme blur?]}] | ||
[text/text | ||
{:accessibility-label :default-keypair-text | ||
:size :paragraph-2 | ||
:weight :regular | ||
:style (style/description theme blur?)} | ||
(str description " · " (i18n/label :t/on-device))]) | ||
|
||
(defn- context-tag-subtitle | ||
[{:keys [community-logo community-name]}] | ||
[rn/view | ||
{:accessibility-label :context-tag-wrapper | ||
:style {:flex-wrap :wrap}} | ||
[context-tag/view | ||
{:type :community | ||
:community-name community-name | ||
:community-logo community-logo | ||
:size 24}]]) | ||
|
||
(defn- description-subtitle | ||
[{:keys [theme blur? description]}] | ||
[text/text | ||
{:size :paragraph-1 | ||
:weight :regular | ||
:style (style/description theme blur?)} | ||
description]) | ||
|
||
(defn- subtitle | ||
[{:keys [type theme blur? keycard? networks description community-name community-logo]}] | ||
(cond | ||
(= :keypair type) | ||
[keypair-subtitle | ||
{:theme theme | ||
:blur? blur? | ||
:keycard? keycard?}] | ||
|
||
(= :account type) | ||
[acocunt-subtitle | ||
{:networks networks | ||
:theme theme | ||
:blur? blur? | ||
:description description}] | ||
|
||
(= :default-keypair type) | ||
[default-keypair-subtitle | ||
{:description description | ||
:theme theme | ||
:blur? blur?}] | ||
|
||
(= :context-tag type) | ||
[context-tag-subtitle | ||
{:community-logo community-logo | ||
:community-name community-name}] | ||
|
||
(and (not= :label type) description) | ||
[description-subtitle | ||
{:theme theme | ||
:blur? blur? | ||
:description description}])) | ||
|
||
(defn- right-icon | ||
[{:keys [theme type on-button-press on-button-long-press button-disabled? button-icon]}] | ||
(cond | ||
(= :info type) | ||
[icons/icon | ||
:i/info | ||
{:accessibility-label :info-icon | ||
:size 20 | ||
:color (colors/theme-colors colors/neutral-50 | ||
colors/neutral-40 | ||
theme)}] | ||
(and (= :context-tag type) button-icon) | ||
[button/button | ||
{:accessibility-label :button-icon | ||
:on-press on-button-press | ||
:on-long-press on-button-long-press | ||
:disabled? button-disabled? | ||
:type :primary | ||
:size 24 | ||
:icon-only? true} | ||
button-icon])) | ||
|
||
(defn- left-title | ||
[{:keys [type label title theme blur?]}] | ||
(case type | ||
:label [text/text | ||
{:weight :medium | ||
:size :paragraph-2 | ||
:style (style/description theme blur?)} | ||
label] | ||
[text/text | ||
{:size :heading-2 | ||
:weight :semi-bold} | ||
title])) | ||
|
||
(defn- view-internal | ||
[{:keys [title type theme description blur? community-name community-logo button-icon on-button-press | ||
on-button-long-press | ||
button-disabled? account-avatar-emoji customization-color icon-avatar | ||
profile-picture keycard? networks label]}] | ||
[rn/view {:style style/container} | ||
[rn/view {:style style/left-container} | ||
[left-image | ||
{:type type | ||
:customization-color customization-color | ||
:account-avatar-emoji account-avatar-emoji | ||
:icon-avatar icon-avatar | ||
:profile-picture profile-picture}]] | ||
[rn/view {:style style/body-container} | ||
[left-title | ||
{:type type | ||
:label label | ||
:title title | ||
:theme theme | ||
:blur? blur?}] | ||
[subtitle | ||
{:type type | ||
:theme theme | ||
:blur? blur? | ||
:keycard? keycard? | ||
:networks networks | ||
:description description | ||
:community-name community-name | ||
:community-logo community-logo}]] | ||
[right-icon | ||
{:theme theme | ||
:type type | ||
:on-button-press on-button-press | ||
:on-button-long-press on-button-long-press | ||
:button-disabled? button-disabled? | ||
:button-icon button-icon}]]) | ||
|
||
(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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component can be broken up into smaller components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done