1
1
import React , { Component } from "react" ;
2
- import '../App.css' ;
2
+ import "../App.css" ;
3
+ import Card from "./Card" ;
3
4
4
5
class Form extends React . Component {
5
6
constructor ( props ) {
6
7
super ( props ) ;
7
8
this . state = {
8
9
file : "" ,
9
- previewUrl : ' http://s3.amazonaws.com/37assets/svn/765-default-avatar.png' ,
10
+ previewUrl : " http://s3.amazonaws.com/37assets/svn/765-default-avatar.png" ,
10
11
title : "" ,
11
12
text : ""
12
13
} ;
@@ -17,7 +18,7 @@ class Form extends React.Component {
17
18
18
19
handleSubmit ( e ) {
19
20
e . preventDefault ( ) ;
20
- console . log ( ' this' , this . state ) ;
21
+ console . log ( " this" , this . state ) ;
21
22
}
22
23
23
24
handleImageChange ( e ) {
@@ -29,7 +30,7 @@ class Form extends React.Component {
29
30
reader . onloadend = ( ) => {
30
31
this . setState ( {
31
32
file : file ,
32
- previewUrl : reader . result ,
33
+ previewUrl : reader . result
33
34
} ) ;
34
35
} ;
35
36
@@ -38,61 +39,63 @@ class Form extends React.Component {
38
39
39
40
render ( ) {
40
41
let { previewUrl } = this . state ;
41
- const { text, title } = this . state ;
42
-
42
+ const { text, title } = this . state ;
43
43
44
44
return (
45
-
46
- < div className = "container" >
47
-
48
- < div className = "col-lg-4 marginTop" >
49
- < div className = "col-md-8" >
50
- < div className = "form-group" >
51
-
52
- < div className = "marginTop" >
53
- < label htmlFor = "title" > Title:</ label >
54
- < input type = "text" className = "form-control" value = { title } onChange = { e => this . setState ( { title : e . target . value } ) } />
55
- </ div >
56
-
57
- < div className = "marginTop" >
58
- < label htmlFor = "text" > Text:</ label >
59
- < input type = "text" className = "form-control" value = { text } onChange = { e => this . setState ( { text : e . target . value } ) } />
60
- </ div >
61
-
62
- < div className = "marginTop" >
63
- < img src = { this . state . previewUrl } className = "rounded" width = "100px" alt = "Cinque Terre" />
64
- </ div >
65
-
66
- < div className = "marginTop" >
67
- < label > Upload Image: </ label >
68
- < div className = "input-group" >
69
- < span className = "input-group-btn" >
70
- < span className = "btn btn-default btn-file" >
71
- Browse... < input type = "file" onChange = { this . handleImageChange } className = "form-control" />
72
- </ span >
73
- </ span >
74
- < input type = "text" className = "form-control" readOnly />
75
- </ div >
76
- </ div >
77
- < button type = "submit" onClick = { this . handleSubmit } className = "btn btn-default marginTop" > Submit</ button >
78
- </ div >
79
- </ div >
80
- </ div >
81
-
82
- < div className = "marginTop " >
83
- < div className = "col-lg-7 cards" >
84
- < div class = "card" style = { { "width" : "18rem" } } >
85
- < img class = "card-img-top img-responsive" src = "http://s3.amazonaws.com/37assets/svn/765-default-avatar.png" alt = "Card image cap" />
86
- < div class = "card-body" >
87
- < h5 class = "card-title" > Card title</ h5 >
88
- < p class = "card-text" > Some quick example text to build on the card title and make up the bulk of the card's content.</ p >
89
- < a href = "#" class = "btn btn-primary" > Go somewhere</ a >
90
- </ div >
91
- </ div >
45
+ < div className = "form-group" >
46
+ < div className = "marginTop" >
47
+ < label htmlFor = "title" > Title:</ label >
48
+ < input
49
+ type = "text"
50
+ className = "form-control"
51
+ value = { title }
52
+ onChange = { e => this . setState ( { title : e . target . value } ) }
53
+ />
54
+ </ div >
55
+
56
+ < div className = "marginTop" >
57
+ < label htmlFor = "text" > Text:</ label >
58
+ < input
59
+ type = "text"
60
+ className = "form-control"
61
+ value = { text }
62
+ onChange = { e => this . setState ( { text : e . target . value } ) }
63
+ />
64
+ </ div >
65
+
66
+ < div className = "marginTop" >
67
+ < img
68
+ src = { this . state . previewUrl }
69
+ className = "rounded"
70
+ width = "100px"
71
+ alt = "Cinque Terre"
72
+ />
73
+ </ div >
74
+
75
+ < div className = "marginTop" >
76
+ < label > Upload Image: </ label >
77
+ < div className = "input-group" >
78
+ < span className = "input-group-btn" >
79
+ < span className = "btn btn-default btn-file" >
80
+ Browse...{ " " }
81
+ < input
82
+ type = "file"
83
+ onChange = { this . handleImageChange }
84
+ className = "form-control"
85
+ />
86
+ </ span >
87
+ </ span >
88
+ < input type = "text" className = "form-control" readOnly />
89
+ </ div >
90
+ </ div >
91
+ < button
92
+ type = "submit"
93
+ onClick = { this . handleSubmit }
94
+ className = "btn btn-default marginTop"
95
+ >
96
+ Submit
97
+ </ button >
92
98
</ div >
93
- </ div >
94
-
95
- </ div >
96
99
) ;
97
100
}
98
101
}
0 commit comments