Skip to content

Commit a3c911b

Browse files
committed
✨ Add listStyle prop to List and List.Item
1 parent 37bf9e7 commit a3c911b

File tree

2 files changed

+63
-12
lines changed

2 files changed

+63
-12
lines changed

docs/07-list.mdx

+40-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ menu: Components
55
---
66

77
import { Playground } from 'docz'
8-
import { ThemeProvider } from 'emotion-theming'
98
import { PropsTable } from '../.internal'
109
import { List } from '../src'
1110

1211
# List
1312

14-
Based on [Flex](#/flex) with applied reset styles for `ul`, `ol`. For more information see [Flex](#/flex) docs.
13+
Based on [Flex](#/flex) with reset styles for `ul`, `ol` and `flex-direction: column` by default.
14+
15+
For more information see [Flex](#/flex) docs.
16+
1517

1618
## Usage
1719

@@ -52,3 +54,39 @@ import { List } from 'pss-components'
5254
<List.Item>6</List.Item>
5355
</List>
5456
</Playground>
57+
58+
### Change `list-style`
59+
60+
<Playground>
61+
<List listStyle='square inside'>
62+
<List.Item>1</List.Item>
63+
<List.Item>2</List.Item>
64+
<List.Item>3</List.Item>
65+
<List.Item>4</List.Item>
66+
<List.Item>5</List.Item>
67+
<List.Item>6</List.Item>
68+
</List>
69+
</Playground>
70+
71+
### Ordered list
72+
73+
<Playground>
74+
<List as='ol' listStyle='decimal' pl='1em'>
75+
<List.Item>First</List.Item>
76+
<List.Item>Second</List.Item>
77+
<List.Item>Third</List.Item>
78+
<List.Item>Fourth</List.Item>
79+
<List.Item>Fifth</List.Item>
80+
<List.Item>Sixth</List.Item>
81+
</List>
82+
</Playground>
83+
84+
## Props
85+
86+
### List ([Flex](#/flex))
87+
88+
<PropsTable of={List} />
89+
90+
### List.Item ([Box](#/box))
91+
92+
<PropsTable of={List.Item} />

src/list.js

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
import React from 'react'
21
import styled from '@emotion/styled'
2+
import { style } from 'pss'
33
import { Box } from './box'
44
import { Flex } from './flex'
55

6-
const List = (props) => (
7-
<Flex
8-
as='ul'
9-
flexDirection='column'
10-
{...props}
11-
/>
6+
const listStyle = style({
7+
cssProp: 'listStyle'
8+
})
9+
10+
const List = styled(Flex)(
11+
listStyle
1212
)
1313

14-
const ListItem = styled(Box)({
15-
listStyle: 'none'
16-
})
14+
List.propTypes = {
15+
...listStyle.propTypes,
16+
...Flex.propTypes
17+
}
18+
19+
List.defaultProps = {
20+
as: 'ul',
21+
flexDirection: 'column',
22+
listStyle: 'none',
23+
...Flex.defaultProps
24+
}
25+
26+
const ListItem = styled(Box)(
27+
listStyle
28+
)
1729

30+
ListItem.propTypes = { ...listStyle.propTypes, ...Box.propTypes }
1831
ListItem.defaultProps = { as: 'li' }
1932
List.Item = ListItem
2033

0 commit comments

Comments
 (0)