@@ -2,12 +2,15 @@ module Lumi.Components.List where
2
2
3
3
import Prelude
4
4
5
+ import Data.Nullable (notNull )
5
6
import Color (cssStringHSLA )
6
7
import Data.Array (mapMaybe )
7
8
import Data.Maybe (Maybe (..))
8
9
import JSS (JSS , jss )
9
- import Lumi.Components.Color (colors )
10
+ import Lumi.Components.Color (colors , colorNames )
11
+ import Lumi.Components.Row (row )
10
12
import Lumi.Components.Size (Size (..))
13
+ import Lumi.Components.Text as T
11
14
import React.Basic (Component , JSX , createComponent , element , makeStateless )
12
15
import React.Basic.DOM as R
13
16
@@ -102,6 +105,64 @@ structuredColumnList = makeStateless structuredColumnListComponent render
102
105
renderRowCell row col =
103
106
col.renderCell row
104
107
108
+ keyValueList
109
+ :: { rightAligned :: Boolean
110
+ , rows ::
111
+ Array
112
+ { label :: String
113
+ , value :: JSX
114
+ }
115
+ , borders :: Boolean
116
+ }
117
+ -> JSX
118
+ keyValueList { rightAligned, rows, borders } =
119
+ let
120
+ lumiKeyValueListElement = element (R .unsafeCreateDOMComponent " lumi-key-value-list" )
121
+ lumiKeyValueListLabelElement = element (R .unsafeCreateDOMComponent " lumi-key-value-list-label" )
122
+ lumiKeyValueListValueElement = element (R .unsafeCreateDOMComponent " lumi-key-value-list-value" )
123
+
124
+ toRows r =
125
+ r <#> \{ label, value } ->
126
+ [ row
127
+ { style: R .css
128
+ { alignItems: " center"
129
+ , justifyContent: " space-between"
130
+ , width: " 100%"
131
+ }
132
+ , children:
133
+ [ lumiKeyValueListLabelElement
134
+ { children:
135
+ [ T .text T .body
136
+ { style = R .css {}
137
+ , color = notNull colorNames.black1
138
+ , children = [ R .text label ]
139
+ }
140
+ ]
141
+ , style: R .css {}
142
+ }
143
+ , lumiKeyValueListValueElement
144
+ { children: [ value ]
145
+ , style: R .css
146
+ { justifyContent: if rightAligned then " flex-end" else " flex-start"
147
+ }
148
+ }
149
+ ]
150
+ }
151
+ ]
152
+ in
153
+ lumiKeyValueListElement
154
+ { children:
155
+ [ if borders
156
+ then list compactList
157
+ { rows = toRows rows
158
+ }
159
+ else borderlessList compactList
160
+ { rows = toRows rows
161
+ }
162
+ ]
163
+ , style: R .css { width: " 100%" }
164
+ }
165
+
105
166
styles :: JSS
106
167
styles = jss
107
168
{ " @global" :
@@ -111,7 +172,6 @@ styles = jss
111
172
, flexFlow: " column"
112
173
, listStyleType: " none"
113
174
, borderBottom: [ " 1px" , " solid" , cssStringHSLA colors.black4 ]
114
-
115
175
, " & > lumi-list-row" :
116
176
{ boxSizing: " border-box"
117
177
, display: " flex"
@@ -120,7 +180,6 @@ styles = jss
120
180
, minHeight: " calc(48px + 1px)"
121
181
, padding: " 6px 0"
122
182
, borderTop: [ " 1px" , " solid" , cssStringHSLA colors.black4 ]
123
-
124
183
, " & > lumi-list-row-cell" :
125
184
{ boxSizing: " border-box"
126
185
, display: " flex"
@@ -130,14 +189,12 @@ styles = jss
130
189
, maxWidth: " 100%"
131
190
}
132
191
}
133
-
134
192
, " &[data-borders=\" false\" ]" :
135
193
{ border: " 0"
136
194
, " & > lumi-list-row" :
137
195
{ border: " 0"
138
196
}
139
197
}
140
-
141
198
, " &[data-size=\" small\" ] > lumi-list-row" :
142
199
{ minHeight: " calc(40px + 1px)"
143
200
, padding: " 2px 0"
@@ -152,13 +209,33 @@ styles = jss
152
209
, justifyContent: " flex-end"
153
210
, alignItems: " center"
154
211
}
155
-
156
212
, " @media (max-width: 448px)" :
157
213
{ " & > lumi-list-row > lumi-list-row-cell" :
158
214
{ alignItems: " flex-end"
159
215
}
160
216
}
161
217
}
162
-
218
+ , " lumi-key-value-list" :
219
+ { " & lumi-key-value-list-label" :
220
+ { " flex" : " 3 5 0%"
221
+ , " padding" : " 8px 0"
222
+ }
223
+ , " & lumi-key-value-list-value" :
224
+ { " display" : " flex"
225
+ , " flexFlow" : " row"
226
+ , " alignItems" : " center"
227
+ , " flex" : " 7 7 0%"
228
+ , " flexWrap" : " wrap"
229
+ }
230
+ , " @media (max-width: 860px)" :
231
+ { " width" : " 100%"
232
+ , " & lumi-key-value-list-label" :
233
+ { " flex" : " initial"
234
+ }
235
+ , " & lumi-key-value-list-value" :
236
+ { " flex" : " initial"
237
+ }
238
+ }
239
+ }
163
240
}
164
241
}
0 commit comments