File tree Expand file tree Collapse file tree 5 files changed +115
-83
lines changed Expand file tree Collapse file tree 5 files changed +115
-83
lines changed Original file line number Diff line number Diff line change 1
1
export default [
2
2
{
3
- " columns" : 1
3
+ columns : 1 ,
4
4
} ,
5
5
{
6
- " columns" : 1
6
+ columns : 1 ,
7
7
} ,
8
8
{
9
- " columns" : 1
9
+ columns : 1 ,
10
10
} ,
11
11
{
12
- " columns" : 1
12
+ columns : 1 ,
13
13
} ,
14
14
{
15
- " columns" : 1
15
+ columns : 1 ,
16
16
} ,
17
17
{
18
- " columns" : 1
18
+ columns : 1 ,
19
19
} ,
20
20
{
21
- " columns" : 1
21
+ columns : 1 ,
22
22
} ,
23
23
{
24
- " columns" : 1
24
+ columns : 1 ,
25
25
} ,
26
26
{
27
- " columns" : 1
27
+ columns : 1 ,
28
28
} ,
29
29
{
30
- " columns" : 1
30
+ columns : 1 ,
31
31
} ,
32
32
{
33
- " columns" : 1
33
+ columns : 1 ,
34
34
} ,
35
35
{
36
- " columns" : 1
36
+ columns : 1 ,
37
37
} ,
38
38
{
39
- " columns" : 2
39
+ columns : 2 ,
40
40
} ,
41
41
{
42
- " columns" : 2
42
+ columns : 2 ,
43
43
} ,
44
44
{
45
- " columns" : 2
45
+ columns : 2 ,
46
46
} ,
47
47
{
48
- " columns" : 2
48
+ columns : 2 ,
49
49
} ,
50
50
{
51
- " columns" : 2
51
+ columns : 2 ,
52
52
} ,
53
53
{
54
- " columns" : 2
54
+ columns : 2 ,
55
55
} ,
56
56
{
57
- " columns" : 3
57
+ columns : 3 ,
58
58
} ,
59
59
{
60
- " columns" : 3
60
+ columns : 3 ,
61
61
} ,
62
62
{
63
- " columns" : 3
63
+ columns : 3 ,
64
64
} ,
65
65
{
66
- " columns" : 3
66
+ columns : 3 ,
67
67
} ,
68
68
{
69
- " columns" : 4
69
+ columns : 4 ,
70
70
} ,
71
71
{
72
- " columns" : 4
72
+ columns : 4 ,
73
73
} ,
74
74
{
75
- " columns" : 4
75
+ columns : 4 ,
76
76
} ,
77
77
{
78
- " columns" : 5
78
+ columns : 5 ,
79
79
} ,
80
80
{
81
- " columns" : 7
81
+ columns : 7 ,
82
82
} ,
83
83
{
84
- " columns" : 6
84
+ columns : 6 ,
85
85
} ,
86
86
{
87
- " columns" : 6
87
+ columns : 6 ,
88
88
} ,
89
89
{
90
- " columns" : 4
90
+ columns : 4 ,
91
91
} ,
92
92
{
93
- " columns" : 8
93
+ columns : 8 ,
94
94
} ,
95
95
{
96
- " columns" : 3
96
+ columns : 3 ,
97
97
} ,
98
98
{
99
- " columns" : 9
99
+ columns : 9 ,
100
100
} ,
101
101
{
102
- " columns" : 2
102
+ columns : 2 ,
103
103
} ,
104
104
{
105
- " columns" : 10
105
+ columns : 10 ,
106
106
} ,
107
107
{
108
- " columns" : 1
108
+ columns : 1 ,
109
109
} ,
110
110
{
111
- " columns" : 11
111
+ columns : 11 ,
112
112
} ,
113
113
{
114
- " columns" : 12
114
+ columns : 12 ,
115
115
} ,
116
116
{
117
- " columns" : 4
117
+ columns : 4 ,
118
118
} ,
119
119
{
120
- " columns" : 4
120
+ columns : 4 ,
121
121
} ,
122
122
{
123
- " columns" : 4
123
+ columns : 4 ,
124
124
} ,
125
125
{
126
- " columns" : 4
126
+ columns : 4 ,
127
127
} ,
128
128
{
129
- " columns" : 4
130
- }
131
- ]
129
+ columns : 4 ,
130
+ } ,
131
+ ] ;
Original file line number Diff line number Diff line change 1
1
import 'react-app-polyfill/ie11' ;
2
2
import * as React from 'react' ;
3
3
import * as ReactDOM from 'react-dom' ;
4
- import { Flex , Item } from '../.'
5
- import myList from './example'
4
+ import { Flex , Item } from '../.' ;
5
+ import myList from './example' ;
6
6
7
7
const App = ( ) => (
8
8
< div
9
- style = { {
10
- maxWidth : 960 ,
11
- margin : "0 auto"
12
- } }
13
- >
14
- < h1 > Example</ h1 >
15
- < Flex col = { 4 } >
16
- { myList . map ( ( { columns } , i : number ) => (
17
- < Item
18
- key = { i }
19
- col = { columns }
20
- colTablet = { 6 }
21
- colMobile = { 12 }
22
- gap = { 1 }
23
- marginBottom = { 30 }
24
- stretch
25
- >
26
- < div
27
- style = { {
28
- textAlign : "center" ,
29
- width : "100%" ,
30
- border : "1px solid #eee" ,
31
- background : "#eee"
32
- } }
9
+ style = { {
10
+ maxWidth : 960 ,
11
+ margin : '0 auto' ,
12
+ } }
13
+ >
14
+ < h1 > Example</ h1 >
15
+ < Flex col = { 4 } total = { myList . length } >
16
+ { myList . map ( ( { columns } , i : number ) => (
17
+ < Item
18
+ key = { i }
19
+ col = { columns }
20
+ colTablet = { 6 }
21
+ colMobile = { 12 }
22
+ gap = { 1 }
23
+ marginBottom = { 30 }
24
+ stretch
33
25
>
34
- < h1 > { columns } </ h1 >
35
- </ div >
36
- </ Item >
37
- ) ) }
38
- </ Flex >
39
- </ div >
40
- )
26
+ < div
27
+ style = { {
28
+ textAlign : 'center' ,
29
+ width : '100%' ,
30
+ border : '1px solid #eee' ,
31
+ background : '#eee' ,
32
+ } }
33
+ >
34
+ < h1 > { columns } </ h1 >
35
+ </ div >
36
+ </ Item >
37
+ ) ) }
38
+ </ Flex >
39
+ < h2 > Hello</ h2 >
40
+ </ div >
41
+ ) ;
41
42
42
43
ReactDOM . render ( < App /> , document . getElementById ( 'root' ) ) ;
Original file line number Diff line number Diff line change 41
41
"size-limit" : [
42
42
{
43
43
"path" : " dist/react-flex-ready.cjs.production.min.js" ,
44
- "limit" : " 10 KB"
44
+ "limit" : " 16 KB"
45
45
},
46
46
{
47
47
"path" : " dist/react-flex-ready.esm.js" ,
48
- "limit" : " 10 KB"
48
+ "limit" : " 16 KB"
49
49
}
50
50
],
51
51
"devDependencies" : {
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
1
2
import styled from 'styled-components' ;
2
3
import { FlexProps } from './interfaces' ;
4
+ import Item from './Item' ;
3
5
4
- const Flex = styled . div < FlexProps > `
6
+ const StyledFlex = styled . div < Omit < FlexProps , 'total' > > `
5
7
display: flex;
6
8
justify-content: ${ ( { justifyContent } ) => justifyContent || 'space-between' } ;
7
9
flex-wrap: wrap;
@@ -29,4 +31,34 @@ const Flex = styled.div<FlexProps>`
29
31
}
30
32
` ;
31
33
34
+ const Flex : React . FC < FlexProps > = ( {
35
+ children,
36
+ col,
37
+ colTablet,
38
+ colMobile,
39
+ gap,
40
+ gabTablet,
41
+ gapMobile,
42
+ align,
43
+ justifyContent,
44
+ className,
45
+ style,
46
+ } ) => (
47
+ < StyledFlex
48
+ col = { col }
49
+ colTablet = { colTablet }
50
+ colMobile = { colMobile }
51
+ gap = { gap }
52
+ gabTablet = { gabTablet }
53
+ gapMobile = { gapMobile }
54
+ align = { align }
55
+ justifyContent = { justifyContent }
56
+ className = { className }
57
+ style = { style }
58
+ >
59
+ { children }
60
+ < Item col = { col } colTablet = { colTablet } colMobile = { colMobile } />
61
+ </ StyledFlex >
62
+ ) ;
63
+
32
64
export default Flex ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export interface ItemProps extends HTMLAttributes<HTMLDivElement> {
14
14
style ?: object ;
15
15
}
16
16
17
- export interface FlexProps extends HTMLAttributes < HTMLDivElement > {
17
+ export interface FlexProps {
18
18
gap ?: number ;
19
19
gabTablet ?: number ;
20
20
gapMobile ?: number ;
@@ -23,7 +23,6 @@ export interface FlexProps extends HTMLAttributes<HTMLDivElement> {
23
23
col ?: number ;
24
24
colTablet ?: number ;
25
25
colMobile ?: number ;
26
- as ?: string | Component ;
27
26
className ?: string ;
28
27
style ?: object ;
29
28
}
You can’t perform that action at this time.
0 commit comments