@@ -2,12 +2,15 @@ module Lumi.Components.List where
22
33import Prelude
44
5+ import Data.Nullable (notNull )
56import Color (cssStringHSLA )
67import Data.Array (mapMaybe )
78import Data.Maybe (Maybe (..))
89import JSS (JSS , jss )
9- import Lumi.Components.Color (colors )
10+ import Lumi.Components.Color (colors , colorNames )
11+ import Lumi.Components.Row (row )
1012import Lumi.Components.Size (Size (..))
13+ import Lumi.Components.Text as T
1114import React.Basic (Component , JSX , createComponent , element , makeStateless )
1215import React.Basic.DOM as R
1316
@@ -102,6 +105,64 @@ structuredColumnList = makeStateless structuredColumnListComponent render
102105 renderRowCell row col =
103106 col.renderCell row
104107
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+
105166styles :: JSS
106167styles = jss
107168 { " @global" :
@@ -111,7 +172,6 @@ styles = jss
111172 , flexFlow: " column"
112173 , listStyleType: " none"
113174 , borderBottom: [ " 1px" , " solid" , cssStringHSLA colors.black4 ]
114-
115175 , " & > lumi-list-row" :
116176 { boxSizing: " border-box"
117177 , display: " flex"
@@ -120,7 +180,6 @@ styles = jss
120180 , minHeight: " calc(48px + 1px)"
121181 , padding: " 6px 0"
122182 , borderTop: [ " 1px" , " solid" , cssStringHSLA colors.black4 ]
123-
124183 , " & > lumi-list-row-cell" :
125184 { boxSizing: " border-box"
126185 , display: " flex"
@@ -130,14 +189,12 @@ styles = jss
130189 , maxWidth: " 100%"
131190 }
132191 }
133-
134192 , " &[data-borders=\" false\" ]" :
135193 { border: " 0"
136194 , " & > lumi-list-row" :
137195 { border: " 0"
138196 }
139197 }
140-
141198 , " &[data-size=\" small\" ] > lumi-list-row" :
142199 { minHeight: " calc(40px + 1px)"
143200 , padding: " 2px 0"
@@ -152,13 +209,33 @@ styles = jss
152209 , justifyContent: " flex-end"
153210 , alignItems: " center"
154211 }
155-
156212 , " @media (max-width: 448px)" :
157213 { " & > lumi-list-row > lumi-list-row-cell" :
158214 { alignItems: " flex-end"
159215 }
160216 }
161217 }
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+ }
163240 }
164241 }
0 commit comments