File tree 5 files changed +34
-46
lines changed
5 files changed +34
-46
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ menu: Primitives
5
5
---
6
6
7
7
import { Playground } from ' docz'
8
+ import { PropsTable } from ' ../.internal/props-table'
8
9
import { Image } from ' ../src'
9
10
10
11
# Image
@@ -18,3 +19,8 @@ import { Image } from 'pss-components'
18
19
<Playground >
19
20
<Image src = ' http://placekitten.com/500' width = { 1 / 2 } alt = ' ' />
20
21
</Playground >
22
+
23
+
24
+ ## Props Table
25
+
26
+ <PropsTable of = { Image } />
Original file line number Diff line number Diff line change 1
- import React from 'react'
1
+ import use from 'reuse'
2
+ import styled from '@emotion/styled'
3
+ import { themePath } from 'pss'
2
4
import { Box } from './box'
3
- import { extend } from './utils'
4
5
5
- const Image = extend ( props => (
6
- < Box
7
- use = 'img'
8
- display = 'block'
9
- maxWidth = '100%'
10
- height = 'auto'
11
- { ...props }
12
- />
13
- ) )
6
+ const Image = styled ( use ( Box , 'img' ) ) (
7
+ themePath ( 'image' )
8
+ )
14
9
15
10
Image . displayName = 'Image'
11
+ Image . propTypes = { ...Box . propTypes }
12
+
13
+ Image . defaultProps = {
14
+ display : 'block' ,
15
+ maxWidth : '100%' ,
16
+ height : 'auto'
17
+ }
16
18
17
19
export {
18
20
Image
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import { Flex } from './flex'
3
3
import { Box } from './box'
4
- import { extend } from './utils'
4
+ import { withRef } from './utils'
5
5
6
- const Layout = extend ( props => (
6
+ const Layout = withRef ( ( props ) => (
7
7
< Flex flex = '1 1 auto' { ...props } />
8
8
) )
9
9
10
- const LayoutSide = extend ( props => (
10
+ const LayoutSide = withRef ( ( props ) => (
11
11
< Box flex = '0 0 auto' { ...props } />
12
12
) )
13
13
14
- const LayoutContent = extend ( props => (
14
+ const LayoutContent = withRef ( ( props ) => (
15
15
< Box flex = '1 1 auto' { ...props } />
16
16
) )
17
17
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import PropTypes from 'prop-types'
3
- import { filterObj , isStr , flatten , identity } from '@exah/utils'
3
+ import { filterObj , isStr , identity } from '@exah/utils'
4
4
5
5
export const omit = ( blacklist = [ ] ) => filterObj ( ( key ) => ! blacklist . includes ( key ) )
6
6
export const omitStyles = ( styles ) => omit ( Object . keys ( Object ( styles . propTypes ) ) )
7
- export const cx = ( ...args ) => flatten ( args ) . filter ( isStr ) . join ( ' ' )
8
7
9
8
export const withRef = ( render ) => React . forwardRef (
10
9
( props , ref ) => render ( { ref, ...props } )
@@ -42,22 +41,3 @@ export function base ({
42
41
}
43
42
} )
44
43
}
45
-
46
- const generateClassName = ( ( id ) => ( ) => {
47
- id ++
48
- return 'pss-' + id
49
- } ) ( - 1 )
50
-
51
- export function extend ( render ) {
52
- const className = generateClassName ( )
53
-
54
- const Comp = withRef ( ( props ) =>
55
- render ( { ...props , className : cx ( props . className , className ) } )
56
- )
57
-
58
- return Object . defineProperties ( Comp , {
59
- toString : {
60
- value : ( ) => `.${ className } `
61
- }
62
- } )
63
- }
Original file line number Diff line number Diff line change @@ -1473,7 +1473,7 @@ exports[`Grid basic 1`] = `
1473
1473
` ;
1474
1474
1475
1475
exports [` Image empty 1` ] = `
1476
- .emotion-0 {
1476
+ .emotion-1 {
1477
1477
box - sizing : border - box ;
1478
1478
border : 0 ;
1479
1479
margin : 0 ;
@@ -1485,26 +1485,26 @@ exports[`Image empty 1`] = `
1485
1485
}
1486
1486
1487
1487
<img
1488
- className = " pss-3 emotion-0 emotion-1"
1488
+ className = " emotion-0 emotion-1 emotion-2 "
1489
1489
/>
1490
1490
` ;
1491
1491
1492
1492
exports [` Image with image 1` ] = `
1493
- .emotion-0 {
1493
+ .emotion-1 {
1494
1494
box - sizing : border - box ;
1495
1495
border : 0 ;
1496
1496
margin : 0 ;
1497
1497
padding : 0 ;
1498
1498
min - width : 0 ;
1499
+ width : 50 % ;
1499
1500
display : block ;
1500
1501
max - width : 100 % ;
1501
1502
height : auto ;
1502
- width : 50 % ;
1503
1503
}
1504
1504
1505
1505
<img
1506
1506
alt = " "
1507
- className = " pss-3 emotion-0 emotion-1"
1507
+ className = " emotion-0 emotion-1 emotion-2 "
1508
1508
src = " http://placekitten.com/500"
1509
1509
/>
1510
1510
` ;
@@ -1549,15 +1549,15 @@ exports[`Layout Holy Grail 1`] = `
1549
1549
}
1550
1550
1551
1551
<div
1552
- className = " pss-0 emotion-6 emotion-7 emotion-1"
1552
+ className = " emotion-6 emotion-7 emotion-1"
1553
1553
>
1554
1554
<header
1555
1555
className = " emotion-0 emotion-1"
1556
1556
>
1557
1557
Header
1558
1558
</header >
1559
1559
<main
1560
- className = " pss-2 emotion-2 emotion-1"
1560
+ className = " emotion-2 emotion-1"
1561
1561
>
1562
1562
Main
1563
1563
</main >
@@ -1608,15 +1608,15 @@ exports[`Layout Media Object 1`] = `
1608
1608
}
1609
1609
1610
1610
<div
1611
- className = " pss-0 emotion-4 emotion-5 emotion-1"
1611
+ className = " emotion-4 emotion-5 emotion-1"
1612
1612
>
1613
1613
<div
1614
- className = " pss-1 emotion-0 emotion-1"
1614
+ className = " emotion-0 emotion-1"
1615
1615
>
1616
1616
Side
1617
1617
</div >
1618
1618
<div
1619
- className = " pss-2 emotion-2 emotion-1"
1619
+ className = " emotion-2 emotion-1"
1620
1620
>
1621
1621
Content
1622
1622
</div >
You can’t perform that action at this time.
0 commit comments