Skip to content

Commit 1eb164c

Browse files
authored
Merge pull request #33 from lumihq/kimi/borderless-list
Add borderless List prop
2 parents 824a0ce + 1317222 commit 1eb164c

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

docs/Examples/List.example.purs

Lines changed: 9 additions & 1 deletion
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(..))
@@ -29,6 +29,14 @@ docs =
2929
}
3030
]
3131

32+
, h2_ "Basic List w/ no Borders"
33+
, example
34+
$ columnSelfStretch
35+
[ borderlessList defaultList
36+
{ rows = simpleListData
37+
}
38+
]
39+
3240
, h2_ "Compact Basic List"
3341
, example
3442
$ columnSelfStretch

src/Lumi/Components/List.purs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +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+
| r
1819
}
1920

20-
component :: Component ListProps
21-
component = createComponent "List"
22-
23-
list :: ListProps -> JSX
24-
list = makeStateless component $ lumiList <<< mapProps
21+
listComponent :: ListProps (borders :: Boolean) -> JSX
22+
listComponent = makeStateless (createComponent "List") $ lumiList <<< mapProps
2523
where
2624
mapProps props =
2725
{ className: "lumi"
@@ -30,6 +28,7 @@ list = makeStateless component $ lumiList <<< mapProps
3028
Just size -> show size
3129
Nothing -> show Medium
3230
, "data-right-aligned": props.rightAligned
31+
, "data-borders": props.borders
3332
, children: map renderRow props.rows
3433
}
3534
where
@@ -43,14 +42,32 @@ list = makeStateless component $ lumiList <<< mapProps
4342
lumiListRow = element (R.unsafeCreateDOMComponent "lumi-list-row")
4443
lumiListRowCell = element (R.unsafeCreateDOMComponent "lumi-list-row-cell")
4544

46-
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 ()
4764
defaultList =
4865
{ size: Just $ Medium
4966
, rightAligned: false
5067
, rows: []
5168
}
5269

53-
compactList :: ListProps
70+
compactList :: ListProps ()
5471
compactList =
5572
{ size: Just $ Small
5673
, rightAligned: false
@@ -100,9 +117,9 @@ styles = jss
100117
, display: "flex"
101118
, flexFlow: "row wrap"
102119
, justifyContent: "space-between"
103-
, borderTop: [ "1px", "solid", cssStringHSLA colors.black4 ]
104120
, minHeight: "calc(48px + 1px)"
105121
, padding: "6px 0"
122+
, borderTop: [ "1px", "solid", cssStringHSLA colors.black4 ]
106123

107124
, "& > lumi-list-row-cell":
108125
{ boxSizing: "border-box"
@@ -114,6 +131,13 @@ styles = jss
114131
}
115132
}
116133

134+
, "&[data-borders=\"false\"]":
135+
{ border: "0"
136+
, "& > lumi-list-row":
137+
{ border: "0"
138+
}
139+
}
140+
117141
, "&[data-size=\"small\"] > lumi-list-row":
118142
{ minHeight: "calc(40px + 1px)"
119143
, padding: "2px 0"

0 commit comments

Comments
 (0)