Skip to content

Commit dd1a675

Browse files
authored
Implement status list item component (#22443)
1 parent a5a0c00 commit dd1a675

File tree

15 files changed

+122
-2
lines changed

15 files changed

+122
-2
lines changed
755 Bytes
Loading
1.07 KB
Loading
-987 Bytes
Binary file not shown.
232 Bytes
Loading
-1.43 KB
Binary file not shown.
372 Bytes
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(ns quo.components.list-items.status-list-item.component-spec
2+
(:require
3+
[quo.components.list-items.status-list-item.view :as status-list-item]
4+
[test-helpers.component :as h]))
5+
6+
(h/describe "Status List Item"
7+
(h/test "With title and description"
8+
(h/render [status-list-item/view
9+
{:status :positive
10+
:title "Account"
11+
:description "This is a description"}])
12+
(h/is-truthy (h/get-by-text "Account"))
13+
(h/is-truthy (h/get-by-text "This is a description"))))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(ns quo.components.list-items.status-list-item.schema)
2+
3+
(def ?schema
4+
[:=>
5+
[:catn
6+
[:props
7+
[:map {:closed true}
8+
[:status [:enum :positive :negative]]
9+
[:title [:maybe string?]]
10+
[:description {:optional true} [:maybe string?]]
11+
[:blur? {:optional true} [:maybe boolean?]]]]]
12+
:any])
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(ns quo.components.list-items.status-list-item.style
2+
(:require [quo.foundations.colors :as colors]))
3+
4+
(def container
5+
{:padding-vertical 5
6+
:padding-horizontal 20
7+
:flex-direction :row})
8+
9+
(defn title
10+
[theme]
11+
{:color (colors/theme-colors colors/neutral-100 colors/white theme)})
12+
13+
(defn description
14+
[theme]
15+
{:color (colors/theme-colors colors/neutral-50 colors/white-opa-40 theme)})
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
(ns quo.components.list-items.status-list-item.view
2+
(:require
3+
[clojure.string :as string]
4+
[quo.components.icon :as quo.icons]
5+
[quo.components.list-items.status-list-item.schema :as component-schema]
6+
[quo.components.list-items.status-list-item.style :as style]
7+
[quo.components.markdown.text :as text]
8+
[quo.context :as quo.context]
9+
[quo.foundations.colors :as colors]
10+
[react-native.core :as rn]
11+
[schema.core :as schema]))
12+
13+
(defn view-internal
14+
[{:keys [status title description]}]
15+
(let [theme (quo.context/use-theme)
16+
positive? (= status :positive)
17+
icon-color (if positive?
18+
(colors/theme-colors colors/success-50 colors/success-60 theme)
19+
(colors/theme-colors colors/danger-50 colors/danger-60 theme))]
20+
[rn/view
21+
{:style style/container
22+
:accessibility-label :status-list-item}
23+
[quo.icons/icon (if positive? :i/correct :i/warning)
24+
{:size 20
25+
:color icon-color
26+
:container-style {:margin-vertical 1}}]
27+
[rn/view
28+
{:style {:flex-direction :column :margin-left 8}}
29+
[text/text
30+
{:weight :regular
31+
:size :paragraph-1
32+
:style (style/title theme)} title]
33+
(when-not (string/blank? description)
34+
[text/text
35+
{:weight :regular
36+
:size :paragraph-2
37+
:style (style/description theme)}
38+
description])]]))
39+
40+
(def view (schema/instrument #'view-internal component-schema/?schema))

0 commit comments

Comments
 (0)