Skip to content

Commit 76eea91

Browse files
authored
feat: category quo2 component (#16713)
* feat: category component
1 parent 1b2ad33 commit 76eea91

File tree

7 files changed

+164
-1
lines changed

7 files changed

+164
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(ns quo2.components.settings.category.component-spec
2+
(:require [test-helpers.component :as h]
3+
[quo2.components.settings.category.view :as category]))
4+
5+
(h/describe "category tests"
6+
(h/test "category label renders"
7+
(h/render [category/category
8+
{:label "label"
9+
:data [{:title "Item 1"
10+
:left-icon :i/browser
11+
:chevron? true}]}])
12+
(h/is-truthy (h/get-by-text "label")))
13+
14+
(h/test "category item renders"
15+
(h/render [category/category
16+
{:label "label"
17+
:data [{:title "Item 1"
18+
:left-icon :i/browser
19+
:chevron? true}]}])
20+
(h/is-truthy (h/get-by-text "Item 1"))))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(ns quo2.components.settings.category.style
2+
(:require [quo2.foundations.colors :as colors]))
3+
4+
(def container
5+
{:left 0
6+
:right 0
7+
:padding-horizontal 20
8+
:padding-top 12
9+
:padding-bottom 8})
10+
11+
(defn items
12+
[theme blur?]
13+
{:margin-top 12
14+
:border-radius 16
15+
:background-color (if blur?
16+
colors/white-opa-5
17+
(colors/theme-colors colors/white colors/neutral-95 theme))
18+
:border-width 1
19+
:border-color (if blur?
20+
colors/white-opa-5
21+
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme))})
22+
23+
(defn separator
24+
[theme blur?]
25+
{:height 1
26+
:background-color (if blur?
27+
colors/white-opa-5
28+
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme))})
29+
30+
(defn blur-container
31+
[]
32+
{:position :absolute
33+
:left 0
34+
:right 0
35+
:bottom 0
36+
:top 0
37+
:overflow :hidden})
38+
39+
(defn blur-view
40+
[]
41+
{:style {:flex 1}
42+
:blur-radius 10
43+
:blur-type (colors/theme-colors :light :dark)
44+
:blur-amount 20})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(ns quo2.components.settings.category.view
2+
(:require
3+
[quo2.components.markdown.text :as text]
4+
[quo2.components.settings.settings-list.view :as settings-list]
5+
[quo2.foundations.colors :as colors]
6+
[react-native.blur :as blur]
7+
[react-native.core :as rn]
8+
[quo2.components.settings.category.style :as style]
9+
[quo2.theme :as quo.theme]))
10+
11+
(defn- category-internal
12+
[{:keys [label data blur? theme]}]
13+
[rn/view {:style style/container}
14+
(when blur?
15+
[rn/view (style/blur-container) [blur/view (style/blur-view)]])
16+
[text/text
17+
{:weight :medium
18+
:size :paragraph-2
19+
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
20+
label]
21+
[rn/flat-list
22+
{:data data
23+
:style (style/items theme blur?)
24+
:render-fn (fn [item] [settings-list/settings-list item])
25+
:separator [rn/view {:style (style/separator theme blur?)}]}]])
26+
27+
(def category (quo.theme/with-theme category-internal))

src/quo2/core.cljs

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
quo2.components.settings.privacy-option
8383
quo2.components.settings.reorder-item.view
8484
quo2.components.settings.settings-list.view
85+
quo2.components.settings.category.view
8586
quo2.components.share.qr-code.view
8687
quo2.components.share.share-qr-code.view
8788
quo2.components.tabs.account-selector
@@ -231,6 +232,7 @@
231232
(def account quo2.components.settings.accounts.view/account)
232233
(def settings-list quo2.components.settings.settings-list.view/settings-list)
233234
(def reorder-item quo2.components.settings.reorder-item.view/reorder-item)
235+
(def category quo2.components.settings.category.view/category)
234236

235237
;;;; SHARE
236238
(def qr-code quo2.components.share.qr-code.view/qr-code)

src/quo2/core_spec.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
[quo2.components.selectors.selectors.component-spec]
3838
[quo2.components.settings.reorder-item.component-spec]
3939
[quo2.components.settings.settings-list.component-spec]
40+
[quo2.components.settings.category.component-spec]
4041
[quo2.components.share.share-qr-code.component-spec]
4142
[quo2.components.tags.--tests--.status-tags-component-spec]))

src/status_im2/contexts/quo_preview/main.cljs

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
[status-im2.contexts.quo-preview.wallet.network-amount :as network-amount]
9696
[status-im2.contexts.quo-preview.wallet.network-breakdown :as network-breakdown]
9797
[status-im2.contexts.quo-preview.wallet.token-overview :as token-overview]
98+
[status-im2.contexts.quo-preview.settings.category :as category]
9899
[status-im2.contexts.quo-preview.keycard.keycard :as keycard]
99100
[status-im2.contexts.quo-preview.loaders.skeleton :as skeleton]
100101
[status-im2.contexts.quo-preview.community.channel-actions :as channel-actions]))
@@ -330,7 +331,10 @@
330331
:component settings-list/preview-settings-list}
331332
{:name :reorder-item
332333
:options {:topBar {:visible true}}
333-
:component reorder-item/preview-reorder-item}]
334+
:component reorder-item/preview-reorder-item}
335+
{:name :category
336+
:options {:topBar {:visible true}}
337+
:component category/preview}]
334338
:share [{:name :qr-code
335339
:options {:topBar {:visible true}}
336340
:component qr-code/preview-qr-code}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
(ns status-im2.contexts.quo-preview.settings.category
2+
(:require
3+
[quo2.core :as quo]
4+
[quo2.foundations.colors :as colors]
5+
[quo2.theme :as theme]
6+
[react-native.core :as rn]
7+
[react-native.fast-image :as fast-image]
8+
[reagent.core :as reagent]
9+
[status-im2.contexts.quo-preview.preview :as preview]))
10+
11+
(def item
12+
{:title "Item 1"
13+
:left-icon :i/browser
14+
:chevron? true})
15+
16+
(def descriptor
17+
[{:label "Category label:"
18+
:key :label
19+
:type :text}
20+
{:label "Category size:"
21+
:key :size
22+
:type :text}
23+
{:label "Blur:"
24+
:key :blur?
25+
:type :boolean}])
26+
27+
(def image-uri
28+
"https://4kwallpapers.com/images/wallpapers/giau-pass-mountain-pass-italy-dolomites-landscape-mountain-750x1334-4282.jpg")
29+
30+
(def label "Label")
31+
32+
(defn preview
33+
[]
34+
(let [state (reagent/atom {:label "Label"
35+
:size "5"
36+
:blur? false})
37+
{:keys [width height]} (rn/get-window)]
38+
[:f>
39+
(fn []
40+
(let [data (repeat (js/parseInt (:size @state)) item)]
41+
(rn/use-effect (fn []
42+
(if (:blur? @state)
43+
(theme/set-theme :dark)
44+
(theme/set-theme :light)))
45+
[(:blur? @state)])
46+
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
47+
[rn/view
48+
{:style {:flex 1
49+
:padding-bottom 150
50+
:margin-bottom 50
51+
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-95)}}
52+
[rn/view
53+
{:style {:min-height 180
54+
:z-index 1}} [preview/customizer state descriptor]]
55+
(when (:blur? @state)
56+
[fast-image/fast-image
57+
{:source {:uri image-uri}
58+
:style {:width width
59+
:height height
60+
:position :absolute}}])
61+
[rn/view
62+
{:style {:background-color (if (:blur? @state)
63+
colors/neutral-80-opa-80
64+
(colors/theme-colors colors/neutral-5 colors/neutral-95))}}
65+
[quo/category {:label (:label @state) :data data :blur? (:blur? @state)}]]]]))]))

0 commit comments

Comments
 (0)