Skip to content

Commit bbbcd6e

Browse files
committed
♻️ Change usebase, add base to List
1 parent 1bfea15 commit bbbcd6e

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

docs/list.mdx

+16-14
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { List, Flex } from '../src'
1212

1313
Based on [Box](/box) with reset styles for `ul`, `ol`. By default renders `<ul>`.
1414

15-
For more information see [Flex](/flex) docs.
16-
1715

1816
## Usage
1917

@@ -42,18 +40,6 @@ import { List } from 'pss-components'
4240
</List>
4341
</Playground>
4442

45-
### Make `horizontal` list with [Flex](/flex)
46-
47-
<Playground>
48-
<List use={Flex} justifyContent='space-between'>
49-
<List.Item>1</List.Item>
50-
<List.Item>2</List.Item>
51-
<List.Item>3</List.Item>
52-
<List.Item>4</List.Item>
53-
<List.Item>5</List.Item>
54-
<List.Item>6</List.Item>
55-
</List>
56-
</Playground>
5743

5844
### Change `list-style`
5945

@@ -68,6 +54,7 @@ import { List } from 'pss-components'
6854
</List>
6955
</Playground>
7056

57+
7158
### Ordered list
7259

7360
<Playground>
@@ -81,6 +68,21 @@ import { List } from 'pss-components'
8168
</List>
8269
</Playground>
8370

71+
72+
### Replace [Box](/box) inside with [Flex](/flex)
73+
74+
<Playground>
75+
<List as='ol' base={Flex} justifyContent='space-between'>
76+
<List.Item>1</List.Item>
77+
<List.Item>2</List.Item>
78+
<List.Item>3</List.Item>
79+
<List.Item>4</List.Item>
80+
<List.Item>5</List.Item>
81+
<List.Item>6</List.Item>
82+
</List>
83+
</Playground>
84+
85+
8486
## Props
8587

8688
### List ([Box](/box))

src/list.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import styled from '@emotion/styled'
2-
import { style } from 'pss'
2+
import pss from 'pss'
33
import { Box } from './box'
4+
import { base } from './utils'
45

5-
const listStyle = style({
6-
cssProp: 'listStyle'
6+
const listStyle = pss({
7+
listStyle: true
78
})
89

9-
const List = styled(Box)(
10+
const BaseList = base({
11+
use: Box,
12+
name: 'List'
13+
})
14+
15+
const List = styled(BaseList)(
1016
listStyle
1117
)
1218

src/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function base ({
2222
const Base = React.forwardRef((props, ref) => {
2323
const {
2424
as: Element = defaultElement,
25-
use: Comp = (BaseComp || Element),
25+
base: Comp = (BaseComp || Element),
2626
className,
2727
...rest
2828
} = props
@@ -51,7 +51,7 @@ export function base ({
5151
Base.propTypes = {
5252
className: PropTypes.string,
5353
as: PropTypes.elementType,
54-
use: PropTypes.elementType
54+
base: PropTypes.elementType
5555
}
5656

5757
return Base

test/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ describe('Layout', () => {
4747
test('Holy Grail', () => {
4848
const result = renderJSON(
4949
<Layout flexDirection='column' minHeight='100%'>
50-
<Box use='header'>
50+
<Box as='header'>
5151
Header
5252
</Box>
53-
<Layout.Content use='main'>
53+
<Layout.Content as='main'>
5454
Main
5555
</Layout.Content>
56-
<Box use='footer'>
56+
<Box as='footer'>
5757
Footer
5858
</Box>
5959
</Layout>

0 commit comments

Comments
 (0)