Skip to content

Commit 1317222

Browse files
committed
code review
1 parent 063f95f commit 1317222

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

docs/Examples/List.example.purs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Lumi.Components.Color (colorNames)
88
import Lumi.Components.Column (columnSelfStretch, column_)
99
import Lumi.Components.Images (avatar, avatar_)
1010
import Lumi.Components.Link (link, defaults)
11-
import Lumi.Components.List (list, structuredColumnList, defaultList, compactList)
11+
import Lumi.Components.List (borderlessList, compactList, defaultList, list, structuredColumnList)
1212
import Lumi.Components.Lockup (lockup)
1313
import Lumi.Components.Row (row_)
1414
import Lumi.Components.Size (Size(..))
@@ -32,9 +32,8 @@ docs =
3232
, h2_ "Basic List w/ no Borders"
3333
, example
3434
$ columnSelfStretch
35-
[ list defaultList
35+
[ borderlessList defaultList
3636
{ rows = simpleListData
37-
, borders = false
3837
}
3938
]
4039

src/Lumi/Components/List.purs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ import Lumi.Components.Size (Size(..))
1111
import React.Basic (Component, JSX, createComponent, element, makeStateless)
1212
import React.Basic.DOM as R
1313

14-
type ListProps =
14+
type ListProps r =
1515
{ size :: Maybe Size
1616
, rightAligned :: Boolean
1717
, rows :: Array (Array JSX)
18-
, borders :: Boolean
18+
| r
1919
}
2020

21-
component :: Component ListProps
22-
component = createComponent "List"
23-
24-
list :: ListProps -> JSX
25-
list = makeStateless component $ lumiList <<< mapProps
21+
listComponent :: ListProps (borders :: Boolean) -> JSX
22+
listComponent = makeStateless (createComponent "List") $ lumiList <<< mapProps
2623
where
2724
mapProps props =
2825
{ className: "lumi"
@@ -45,20 +42,36 @@ list = makeStateless component $ lumiList <<< mapProps
4542
lumiListRow = element (R.unsafeCreateDOMComponent "lumi-list-row")
4643
lumiListRowCell = element (R.unsafeCreateDOMComponent "lumi-list-row-cell")
4744

48-
defaultList :: ListProps
45+
list :: ListProps () -> JSX
46+
list props =
47+
listComponent
48+
{ size: props.size
49+
, rightAligned: props.rightAligned
50+
, rows: props.rows
51+
, borders: true
52+
}
53+
54+
borderlessList :: ListProps () -> JSX
55+
borderlessList props =
56+
listComponent
57+
{ size: props.size
58+
, rightAligned: props.rightAligned
59+
, rows: props.rows
60+
, borders: false
61+
}
62+
63+
defaultList :: ListProps ()
4964
defaultList =
5065
{ size: Just $ Medium
5166
, rightAligned: false
5267
, rows: []
53-
, borders: true
5468
}
5569

56-
compactList :: ListProps
70+
compactList :: ListProps ()
5771
compactList =
5872
{ size: Just $ Small
5973
, rightAligned: false
6074
, rows: []
61-
, borders: true
6275
}
6376

6477
type StructuredColumnListProps row =
@@ -80,7 +93,6 @@ structuredColumnList = makeStateless structuredColumnListComponent render
8093
{ size: Just $ Large
8194
, rightAligned: props.rightAligned
8295
, rows: map renderRow props.rows
83-
, borders: true
8496
}
8597
where
8698
renderRow row =

0 commit comments

Comments
 (0)