Skip to content

Commit 8e95da2

Browse files
committed
refactor to prevent breaking change
1 parent a95efeb commit 8e95da2

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

docs/Examples/List.example.purs

Lines changed: 3 additions & 4 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 (list, listComponent, borderlessList, compactList, defaultList, structuredColumnList)
1212
import Lumi.Components.Lockup (lockup)
1313
import Lumi.Components.Row (row_)
1414
import Lumi.Components.Size (Size(..))
@@ -29,12 +29,11 @@ docs =
2929
}
3030
]
3131

32-
, h2_ "Basic List w/ no Borders"
32+
, h2_ "Borderless List"
3333
, example
3434
$ columnSelfStretch
35-
[ list defaultList
35+
[ listComponent borderlessList
3636
{ rows = simpleListData
37-
, borders = false
3837
}
3938
]
4039

src/Lumi/Components/List.purs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ 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 CommonListProps rest =
1515
{ size :: Maybe Size
1616
, rightAligned :: Boolean
1717
, rows :: Array (Array JSX)
18-
, borders :: Boolean
18+
| rest
1919
}
2020

21+
type ListProps = CommonListProps
22+
( borders :: Boolean
23+
)
24+
2125
component :: Component ListProps
2226
component = createComponent "List"
2327

24-
list :: ListProps -> JSX
25-
list = makeStateless component $ lumiList <<< mapProps
28+
listComponent :: ListProps -> JSX
29+
listComponent = makeStateless component $ lumiList <<< mapProps
2630
where
2731
mapProps props =
2832
{ className: "lumi"
@@ -45,20 +49,35 @@ list = makeStateless component $ lumiList <<< mapProps
4549
lumiListRow = element (R.unsafeCreateDOMComponent "lumi-list-row")
4650
lumiListRowCell = element (R.unsafeCreateDOMComponent "lumi-list-row-cell")
4751

48-
defaultList :: ListProps
52+
list :: CommonListProps () -> JSX
53+
list props =
54+
listComponent
55+
{ size: props.size
56+
, rightAligned: props.rightAligned
57+
, rows: props.rows
58+
, borders: true
59+
}
60+
61+
defaultList :: CommonListProps ()
4962
defaultList =
5063
{ size: Just $ Medium
5164
, rightAligned: false
5265
, rows: []
53-
, borders: true
5466
}
5567

56-
compactList :: ListProps
68+
compactList :: CommonListProps ()
5769
compactList =
5870
{ size: Just $ Small
5971
, rightAligned: false
6072
, rows: []
61-
, borders: true
73+
}
74+
75+
borderlessList :: ListProps
76+
borderlessList =
77+
{ size: Just $ Medium
78+
, rightAligned: false
79+
, rows: []
80+
, borders: false
6281
}
6382

6483
type StructuredColumnListProps row =
@@ -80,7 +99,6 @@ structuredColumnList = makeStateless structuredColumnListComponent render
8099
{ size: Just $ Large
81100
, rightAligned: props.rightAligned
82101
, rows: map renderRow props.rows
83-
, borders: true
84102
}
85103
where
86104
renderRow row =

0 commit comments

Comments
 (0)