Skip to content

Commit 23f5c67

Browse files
committed
Added css styling
1 parent 0a4b562 commit 23f5c67

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

my-app/src/App.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,38 @@ class App extends Component {
2424
})
2525
}
2626

27+
nameChangeHandler = (event) => {
28+
this.setState( {
29+
persons: [
30+
{ name: 'Max', age: 28 },
31+
{ name: event.target.value, age: 29 },
32+
{ name: 'Stephanie', age: 26 }
33+
]
34+
})
35+
}
36+
2737
render () {
38+
const style = {
39+
backgroundColor: 'white',
40+
font: 'inherit',
41+
border: '1px solid blue',
42+
padding: '8px',
43+
cursor: 'pointer'
44+
};
45+
2846
return (
2947
<div className="App">
3048
<h1>Hi, I'm a React App</h1>
3149
<p>This is really working!</p>
32-
<button onClick={() => this.switchNameHandler('Maximilan!!')}>Switch Name</button>
50+
<button
51+
onClick={() => this.switchNameHandler('Maximilan!!')}
52+
style={style}>Switch Name</button>
3353
<Person name={this.state.persons[0].name} age={this.state.persons[0].age}/>
3454
<Person
3555
name={this.state.persons[1].name}
3656
age={this.state.persons[1].age}
37-
click={this.switchNameHandler.bind(this, "Max!")}>My Hobbies: Racing</Person>
57+
click={this.switchNameHandler.bind(this, "Max!")}
58+
changed={this.nameChangeHandler}>My Hobbies: Racing</Person>
3859
<Person name={this.state.persons[2].name} age={this.state.persons[2].age}/>
3960
</div>
4061
)

my-app/src/Person/Person.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.Person {
2+
width: 60%;
3+
margin: 16px auto;
4+
border: 1px, solid, #eee;
5+
box-shadow: 0 2px 3px #ccc;
6+
padding: 16px;
7+
text-align: center;
8+
}

my-app/src/Person/Person.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from 'react';
2+
import './Person.css';
23

34
const person = (props) => {
45
return (
5-
<div>
6+
<div className="Person">
67
<p onClick={props.click}>I'm {props.name} and I am {props.age} years old!</p>
78
<p>{props.children}</p>
9+
<input type="text" onChange={props.changed} value={props.name}/>
810
</div>
911
);
1012
}

0 commit comments

Comments
 (0)