Skip to content

Commit 4a2e3a8

Browse files
committed
init keyValueList
1 parent e4e89fd commit 4a2e3a8

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

docs/App.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const componentLoaders = [
6363
"Images",
6464
"Input",
6565
"InputGroup",
66+
"KeyValueList",
6667
"LabeledField",
6768
"Layouts",
6869
"Link",
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
module Lumi.Components.Examples.KeyValueList where
2+
3+
import Prelude
4+
5+
import Data.Array (intercalate)
6+
import Data.Maybe (Maybe(..))
7+
import Data.Nullable (toNullable)
8+
import Lumi.Components.Size (Size(..))
9+
import Lumi.Components.Button (ButtonState(..), button, defaults, primary, secondary, linkStyle, iconButton, iconButtonDefaults)
10+
import Lumi.Components.Color (colorNames)
11+
import Lumi.Components.Column (column_)
12+
import Lumi.Components.Icon (IconType(..))
13+
import Lumi.Components.Images (avatar_, productThumb_)
14+
import Lumi.Components.KeyValueList (keyValueList)
15+
import Lumi.Components.Lockup (lockup)
16+
import Lumi.Components.Text as T
17+
import Lumi.Components.Example (example)
18+
import React.Basic (JSX)
19+
import React.Basic.DOM (css)
20+
import React.Basic.DOM as R
21+
22+
docs :: JSX
23+
docs =
24+
column_ $
25+
[ example
26+
$ keyValueList
27+
{ rightAligned: true
28+
, rows: r
29+
, borders: true
30+
}
31+
, example
32+
$ keyValueList
33+
{ rightAligned: false
34+
, rows: r
35+
, borders: true
36+
}
37+
, example
38+
$ keyValueList
39+
{ rightAligned: true
40+
, rows: r
41+
, borders: false
42+
}
43+
, example
44+
$ keyValueList
45+
{ rightAligned: false
46+
, rows: r
47+
, borders: false
48+
}
49+
]
50+
51+
where
52+
r =
53+
[ { label: "Name"
54+
, value: T.body_ "Flexo"
55+
}
56+
, { label: "Email"
57+
, value: T.body_ "[email protected]"
58+
}
59+
, { label: ""
60+
, value: lockup
61+
{ title: R.text "Flexo R."
62+
, subtitle: Just $ R.text "Lumi"
63+
, image: Just $ avatar_
64+
{ size: Large
65+
, image:
66+
R.img
67+
{ src: "https://s3.amazonaws.com/lumi-flapjack-staging/mockups/9e7f08b801e6bb3a428ef72e93c49fe5.jpg"
68+
}
69+
}
70+
}
71+
}
72+
]

src/Lumi/Components/KeyValueList.purs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
module Lumi.Components.KeyValueList where
2+
3+
import Prelude
4+
5+
import Data.Nullable (notNull)
6+
import JSS (JSS, jss)
7+
import Lumi.Components.Color (colorNames)
8+
import Lumi.Components.List as List
9+
import Lumi.Components.Row (row)
10+
import Lumi.Components.Text as T
11+
import React.Basic (JSX, element)
12+
import React.Basic.DOM as R
13+
14+
15+
keyValueList
16+
:: { rightAligned :: Boolean
17+
, rows ::
18+
Array
19+
{ label :: String
20+
, value :: JSX
21+
}
22+
, borders :: Boolean
23+
}
24+
-> JSX
25+
keyValueList { rightAligned, rows, borders } =
26+
let
27+
lumiKeyValueListElement = element (R.unsafeCreateDOMComponent "lumi-key-value-list")
28+
29+
toRows r =
30+
r <#> \{ label, value } ->
31+
[ row
32+
{ style: R.css
33+
{ alignItems: "center"
34+
}
35+
, children:
36+
[ T.text T.body
37+
{ style = R.css
38+
{ flex: "3 5 0%"
39+
, padding: "8px 0"
40+
}
41+
, color = notNull colorNames.black1
42+
, children = [ R.text label ]
43+
}
44+
, row
45+
{ style: R.css
46+
{ alignItems: "center"
47+
, flex: "7 7 0%"
48+
, flexWrap: "wrap"
49+
, justifyContent: if rightAligned then "flex-end" else "flex-start"
50+
}
51+
, children: [ value ]
52+
}
53+
]
54+
}
55+
]
56+
in
57+
lumiKeyValueListElement
58+
{ children:
59+
[ if borders
60+
then List.list List.compactList
61+
{ rows = toRows rows
62+
}
63+
else List.borderlessList List.compactList
64+
{ rows = toRows rows
65+
}
66+
]
67+
, style: R.css { width: "100%" }
68+
}
69+
70+
styles :: JSS
71+
styles = jss
72+
{ "@global":
73+
{ "lumi-key-value-list":
74+
{
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)