File tree Expand file tree Collapse file tree 6 files changed +73
-4
lines changed
Expand file tree Collapse file tree 6 files changed +73
-4
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import withBorder from './components/HOC/withBorder';
99
1010class App extends Component {
1111 state = {
12- show : false
12+ show : false ,
1313 }
1414
1515 showModal = ( ) => {
@@ -20,6 +20,7 @@ class App extends Component {
2020 }
2121 render ( ) {
2222 let WithBorderInput = withBorder ( InputTag ) ;
23+
2324 return (
2425 < div className = "App" >
2526 { /* <WithBorderInput placeholder="press enter/space to + tag" /> */ }
@@ -31,7 +32,6 @@ class App extends Component {
3132 < Modal onClose = { this . showModal } show = { this . state . show } >
3233 This message is from Modal!
3334 </ Modal >
34-
3535 </ div >
3636 ) ;
3737 }
Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react' ;
2+ import withModal from './components/HOC/withModal' ;
3+ import TodoItem from './features/todo/todo-item' ;
4+ import './appwithmodal.css' ;
5+
6+ export default class AppWithModal extends Component {
7+ state = {
8+ todos : [
9+ { id : 1 , title : "Learn React" } ,
10+ { id : 2 , title : "Learn Angular" } ,
11+ { id : 3 , title : "Learn Vue" } ,
12+ { id : 4 , title : "Learn Node" } ,
13+ { id : 5 , title : "Learn MongoDB" } ,
14+ { id : 6 , title : "Learn GraphQL" } ,
15+ { id : 7 , title : "Learn Redux" } ,
16+ { id : 8 , title : "Learn .NET Core" } ,
17+ ]
18+ }
19+
20+ render ( ) {
21+ let taskUI = this . state . todos . map ( ( todo ) => {
22+ let TodoItemWithModal = withModal ( TodoItem ) ;
23+ return (
24+ < TodoItemWithModal key = { todo . id } todo = { todo } />
25+ ) ;
26+ } ) ;
27+
28+ return (
29+ < div >
30+ < h2 > HOC - Modal Dialog Demo</ h2 >
31+ < div className = "todo-list" >
32+ { taskUI }
33+ </ div >
34+ </ div >
35+ ) ;
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ body {
2+ margin : 20px ;
3+ }
4+ .todo-list {
5+ display : flex;
6+ flex : 1 ; /* All items same length, regardless of content */
7+ flex-direction : row;
8+ flex-wrap : wrap;
9+ }
10+
11+ .todo-item {
12+ padding : 20px ;
13+ width : 200px ;
14+ background-color : coral;
15+ color : white;
16+ margin : 10px ;
17+ user-select : none;
18+
19+ }
Original file line number Diff line number Diff line change @@ -83,5 +83,6 @@ export default class Modal extends React.Component {
8383}
8484
8585Modal . propTypes = {
86- onClose : PropTypes . func . isRequired
86+ onClose : PropTypes . func . isRequired ,
87+ show : PropTypes . bool . isRequired
8788}
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ const todoItem = ( { todo} ) => {
4+ return (
5+ < div className = "todo-item" >
6+ < h2 > { todo . title } </ h2 >
7+ </ div >
8+ ) ;
9+ }
10+
11+ export default todoItem ;
Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ import './index.css';
44import App from './App' ;
55import AppDragDropDemo from './AppDragDropDemo' ;
66import AppSlideShow from './AppSlideShow' ;
7+ import AppWithModal from './AppWithModal' ;
78
89import registerServiceWorker from './registerServiceWorker' ;
910
10- ReactDOM . render ( < App /> , document . getElementById ( 'root' ) ) ;
11+ ReactDOM . render ( < AppWithModal /> , document . getElementById ( 'root' ) ) ;
1112registerServiceWorker ( ) ;
You can’t perform that action at this time.
0 commit comments