-
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.
quo2 documentation drawer component (#15674)
- Loading branch information
1 parent
d7db401
commit 0226a92
Showing
9 changed files
with
240 additions
and
5 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/quo2/components/drawers/documentation_drawers/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,30 @@ | ||
(ns quo2.components.drawers.documentation-drawers.component-spec | ||
(:require [quo2.components.drawers.documentation-drawers.view :as documentation-drawers] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "Documentation drawers component" | ||
(h/test "render component without button" | ||
(h/render [documentation-drawers/view {:title "Documentation"} "Content"]) | ||
(-> (h/expect (h/get-by-label-text :documentation-drawer-title)) | ||
(.toBeTruthy)) | ||
(-> (h/expect (h/get-by-label-text :documentation-drawer-content)) | ||
(.toBeTruthy))) | ||
(h/test "render component with button" | ||
(h/render [documentation-drawers/view | ||
{:title "Documentation" :show-button? true :button-label "Read more"} "Content"]) | ||
(-> (h/expect (h/get-by-label-text :documentation-drawer-title)) | ||
(.toBeTruthy)) | ||
(-> (h/expect (h/get-by-label-text :documentation-drawer-content)) | ||
(.toBeTruthy)) | ||
(-> (h/expect (h/get-by-label-text :documentation-drawer-button)) | ||
(.toBeTruthy))) | ||
(h/test "button is pressed" | ||
(let [event (h/mock-fn)] | ||
(h/render | ||
[documentation-drawers/view | ||
{:title "Documentation" :show-button? true :button-label "Read more" :on-press-button event} | ||
"Content"]) | ||
(h/fire-event :press (h/get-by-label-text :documentation-drawer-button)) | ||
(-> (h/expect event) | ||
(.toHaveBeenCalled))))) | ||
|
10 changes: 10 additions & 0 deletions
10
src/quo2/components/drawers/documentation_drawers/style.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,10 @@ | ||
(ns quo2.components.drawers.documentation-drawers.style) | ||
|
||
(def container | ||
{:align-items :flex-start | ||
:padding 20}) | ||
|
||
(def content | ||
{:margin-top 12 | ||
:margin-bottom 16}) | ||
|
40 changes: 40 additions & 0 deletions
40
src/quo2/components/drawers/documentation_drawers/view.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,40 @@ | ||
(ns quo2.components.drawers.documentation-drawers.view | ||
(:require [quo2.components.markdown.text :as text] | ||
[quo2.components.drawers.documentation-drawers.style :as style] | ||
[react-native.core :as rn] | ||
[react-native.gesture :as gesture] | ||
[quo2.components.buttons.button :as button] | ||
[quo2.foundations.colors :as colors])) | ||
|
||
(defn view | ||
"Options | ||
- `title` Title text | ||
- `show-button?` Show button | ||
- `button-label` button label | ||
- `button-icon` button icon | ||
- `on-press-button` On press handler for the button | ||
- `shell?` use shell theme | ||
`content` Content of the drawer | ||
" | ||
[{:keys [title show-button? on-press-button button-label button-icon shell?]} content] | ||
[gesture/scroll-view | ||
[rn/view {:style style/container} | ||
[text/text | ||
{:size :heading-2 | ||
:accessibility-label :documentation-drawer-title | ||
:style {:color (colors/theme-colors colors/neutral-100 | ||
colors/white | ||
(when shell? :dark))} | ||
:weight :semi-bold} title] | ||
[rn/view {:style style/content :accessibility-label :documentation-drawer-content} | ||
content] | ||
(when show-button? | ||
[button/button | ||
(merge {:size 24 | ||
:type (if shell? :blur-bg-outline :outline) | ||
:on-press on-press-button | ||
:accessibility-label :documentation-drawer-button | ||
:after button-icon} | ||
(when shell? {:override-theme :dark})) button-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
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
132 changes: 132 additions & 0 deletions
132
src/status_im2/contexts/quo_preview/drawers/documentation_drawers.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,132 @@ | ||
(ns status-im2.contexts.quo-preview.drawers.documentation-drawers | ||
(:require [quo2.core :as quo] | ||
[quo2.foundations.colors :as colors] | ||
[react-native.core :as rn] | ||
[reagent.core :as reagent] | ||
[utils.re-frame :as rf] | ||
[status-im2.contexts.quo-preview.preview :as preview])) | ||
|
||
(def descriptor | ||
[{:label "Title" | ||
:key :title | ||
:type :text} | ||
{:label "Show button" | ||
:key :show-button? | ||
:type :boolean} | ||
{:label "Button label" | ||
:key :button-label | ||
:type :text} | ||
{:label "Shell" | ||
:key :shell? | ||
:type :boolean}]) | ||
|
||
(defn documentation-content | ||
[override-theme] | ||
[quo/text {:style {:color (colors/theme-colors colors/neutral-100 colors/white override-theme)}} | ||
"Group chats are conversations of more than two people. To invite someone to a group chat, you need to have them on your Status contact list."]) | ||
|
||
(defn documentation-content-full | ||
[override-theme] | ||
(let [text-color (colors/theme-colors colors/neutral-100 colors/white override-theme) | ||
text-style {:color text-color :margin-bottom 10}] | ||
[rn/view | ||
[quo/text {:style text-style} | ||
"Group chats are conversations of more than two people. To invite someone to a group chat, you need to have them on your Status contact list."] | ||
[quo/text {:style text-style} | ||
"Group chats are different to communities, as they're meant to unite smaller groups of people or be centred around specific topics. For more information about group chats, see Understand group chats."] | ||
[quo/text {:size :paragraph-1 :weight :semi-bold :style {:margin-top 16 :color text-color}} | ||
"What to expect"] | ||
[quo/text {:style text-style} | ||
"You can invite up to 20 members to your group chat. If you need more, consider creating a community."] | ||
[quo/text {:style text-style} | ||
"Once you create your group chat, you can customize it and add members, as well as remove them."] | ||
[quo/text {:style text-style} | ||
"Group chats are always end-to-end encrypted with secure cryptographic keys. Only the group chat members will have access to the messages in it. Status doesn't have the keys and can't access any messages by design."] | ||
[quo/text {:size :paragraph-1 :weight :semi-bold :style {:margin-top 16 :color text-color}} | ||
"What to expect"] | ||
[quo/text {:style text-style} | ||
"You can invite up to 20 members to your group chat. If you need more, consider creating a community."] | ||
[quo/text {:style text-style} | ||
"Once you create your group chat, you can customize it and add members, as well as remove them."] | ||
[quo/text {:style text-style} | ||
"Group chats are always end-to-end encrypted with secure cryptographic keys. Only the group chat members will have access to the messages in it. Status doesn't have the keys and can't access any messages by design."] | ||
[quo/text {:size :paragraph-1 :weight :semi-bold :style {:margin-top 16 :color text-color}} | ||
"What to expect"] | ||
[quo/text {:style text-style} | ||
"You can invite up to 20 members to your group chat. If you need more, consider creating a community."] | ||
[quo/text {:style text-style} | ||
"Once you create your group chat, you can customize it and add members, as well as remove them."] | ||
[quo/text {:style text-style} | ||
"Group chats are always end-to-end encrypted with secure cryptographic keys. Only the group chat members will have access to the messages in it. Status doesn't have the keys and can't access any messages by design."] | ||
[quo/text {:size :paragraph-1 :weight :semi-bold :style {:margin-top 16 :color text-color}} | ||
"What to expect"] | ||
[quo/text {:style text-style} | ||
"You can invite up to 20 members to your group chat. If you need more, consider creating a community."] | ||
[quo/text {:style text-style} | ||
"Once you create your group chat, you can customize it and add members, as well as remove them."] | ||
[quo/text {:style text-style} | ||
"Group chats are always end-to-end encrypted with secure cryptographic keys. Only the group chat members will have access to the messages in it. Status doesn't have the keys and can't access any messages by design."] | ||
[quo/text {:size :paragraph-1 :weight :semi-bold :style {:margin-top 16 :color text-color}} | ||
"What to expect"] | ||
[quo/text {:style text-style} | ||
"You can invite up to 20 members to your group chat. If you need more, consider creating a community."] | ||
[quo/text {:style text-style} | ||
"Once you create your group chat, you can customize it and add members, as well as remove them."] | ||
[quo/text {:style text-style} | ||
"Group chats are always end-to-end encrypted with secure cryptographic keys. Only the group chat members will have access to the messages in it. Status doesn't have the keys and can't access any messages by design."]])) | ||
|
||
(defn render-documenation-drawer | ||
[title show-button? button-label expanded? shell?] | ||
[quo/documentation-drawers | ||
{:title title | ||
:show-button? (and show-button? (not @expanded?)) | ||
:button-label button-label | ||
:button-icon :info | ||
:shell? shell? | ||
:on-press-button #(swap! expanded? not)} | ||
(if @expanded? | ||
[documentation-content-full (when shell? :dark)] | ||
[documentation-content (when shell? :dark)])]) | ||
|
||
(defn cool-preview | ||
[] | ||
(let | ||
[state | ||
(reagent/atom | ||
{:title "Create a group chat" | ||
:button-label "Read more"}) | ||
title (reagent/cursor state [:title]) | ||
show-button? (reagent/cursor state [:show-button?]) | ||
button-label (reagent/cursor state [:button-label]) | ||
shell? (reagent/cursor state [:shell?]) | ||
expanded? (reagent/atom 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} | ||
[quo/button | ||
{:style {:margin-horizontal 40} | ||
:on-press #(rf/dispatch [:show-bottom-sheet | ||
{:content (constantly [render-documenation-drawer @title | ||
@show-button? | ||
@button-label expanded? @shell?]) | ||
:expandable? @show-button? | ||
:shell? @shell? | ||
:expanded? @expanded?}])} | ||
"Open drawer"] | ||
[render-documenation-drawer @title @show-button? @button-label expanded?]]]]))) | ||
|
||
(defn preview-documenation-drawers | ||
[] | ||
[rn/view | ||
{:background-color (colors/theme-colors | ||
colors/white | ||
colors/neutral-95) | ||
: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