@@ -31,24 +31,27 @@ const createFragment = () => {
3131const fragments = [ text2 , text4 , text1 , text3 ] ;
3232
3333class Content extends React . Component {
34- state = { items : fragments } ;
35-
3634 render ( ) {
3735 const gutter = 16 ;
3836 const sizes = times ( identity , 100 ) . map ( columns => {
3937 const mq = `${ columns * 288 + ( columns - 1 ) * 16 } px` ;
40- console . log ( mq ) ;
4138 return {
4239 columns,
4340 mq,
4441 gutter
4542 } ;
4643 } ) ;
4744
48- const { items } = this . state ;
45+ const { items } = this . props ;
4946
5047 return (
51- < div style = { { padding : "16px" } } >
48+ < div
49+ style = { {
50+ paddingTop : "1rem" ,
51+ display : "flex" ,
52+ alignSelf : "center"
53+ } }
54+ >
5255 < Masonry sizes = { sizes } >
5356 { ( { forcePack } ) =>
5457 items . map ( ( fragment , index ) => (
@@ -59,18 +62,6 @@ class Content extends React.Component {
5962 < Group section = "body" >
6063 < Text size = "small" > { fragment } </ Text >
6164 </ Group >
62- < Button
63- size = "large"
64- variant = "warning"
65- onClick = { ( ) => {
66- const newItems = [ ...items ] ;
67- newItems . push ( createFragment ( ) ) ;
68- this . setState ( { items : newItems } ) ;
69- forcePack ( ) ;
70- } }
71- >
72- Add Item
73- </ Button >
7465 </ Card >
7566 ) )
7667 }
@@ -79,21 +70,33 @@ class Content extends React.Component {
7970 ) ;
8071 }
8172}
73+
8274class App extends React . Component {
8375 state = {
84- isOpen : false
76+ isOpen : false ,
77+ items : fragments
78+ } ;
79+
80+ addItem = ( ) => {
81+ const newItems = [ ...this . state . items ] ;
82+ newItems . push ( createFragment ( ) ) ;
83+ this . setState ( { items : newItems } ) ;
8584 } ;
8685
8786 render ( ) {
8887 const toggle = ( ) => this . setState ( { isOpen : ! this . state . isOpen } ) ;
8988 const links = [
89+ {
90+ onClick : this . addItem ,
91+ title : "Add Item" ,
92+ level : 1
93+ } ,
9094 {
9195 href : "https://condescending-wing-149611.netlify.com/" ,
9296 title : "Contribute" ,
9397 level : 3
9498 }
9599 ] ;
96-
97100 return (
98101 < ThemeProvider theme = { theme } >
99102 < AppShell
@@ -109,7 +112,7 @@ class App extends React.Component {
109112 content = "width=device-width, initial-scale=1"
110113 />
111114 </ Head >
112- < Content />
115+ < Content items = { this . state . items } />
113116 </ AppShell >
114117 </ ThemeProvider >
115118 ) ;
0 commit comments