File tree Expand file tree Collapse file tree 7 files changed +123
-6
lines changed Expand file tree Collapse file tree 7 files changed +123
-6
lines changed Original file line number Diff line number Diff line change 1+ .App {
2+ text-align : center;
3+ }
4+
5+ .App-body {
6+ display : flex;
7+ max-width : 1200px ;
8+ padding : 1rem 2rem 4rem 2rem ;
9+ margin : auto;
10+ }
Original file line number Diff line number Diff line change 11import React , { Component } from "react" ;
2+
23import "./App.css" ;
34
5+ import Header from "./components/Header" ;
6+
47class App extends Component {
58 render ( ) {
69 return (
710 < div className = "App" >
8- < header className = "App-header" >
9- < h1 className = "App-title" > Welcome to React</ h1 >
10- </ header >
11- < p className = "App-intro" >
12- To get started, edit < code > src/App.js</ code > and save to reload.
13- </ p >
11+ < div className = "App-body" >
12+ < Header />
13+ </ div >
1414 </ div >
1515 ) ;
1616 }
Original file line number Diff line number Diff line change 1+ .Header {
2+ display : flex;
3+ width : 100% ;
4+ align-items : center;
5+ height : 50px ;
6+ }
7+
8+ .Header-label {
9+ font-size : 20px ;
10+ margin-right : 10px ;
11+ }
Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import "./Header.css" ;
3+
4+ import SearchBox from "../containers/SearchBox" ;
5+
6+ export default function Header ( ) {
7+ return (
8+ < div className = "Header" >
9+ < label className = "Header-label" htmlFor = "search" >
10+ Search
11+ </ label >
12+ < SearchBox />
13+ </ div >
14+ ) ;
15+ }
Original file line number Diff line number Diff line change 1+ .SearchBox {
2+ display : flex;
3+ }
4+
5+ .SearchBox-input {
6+ /* reset */
7+ background-image : none;
8+ background-color : transparent;
9+ -webkit-box-shadow : none;
10+ -moz-box-shadow : none;
11+ box-shadow : none;
12+ border : none;
13+
14+ font-size : 16px ;
15+ min-width : 400px ;
16+ height : 30px ;
17+ padding : 0 6px ;
18+ border : 1px solid darkgray;
19+ border-bottom-left-radius : 2px ;
20+ border-top-left-radius : 2px ;
21+ }
22+
23+ .SearchBox-button {
24+ /* reset */
25+ border : none;
26+ margin : 0 ;
27+ padding : 0 ;
28+ width : auto;
29+ overflow : visible;
30+ background : transparent;
31+ color : inherit;
32+ font : inherit;
33+ line-height : normal;
34+ -webkit-font-smoothing : inherit;
35+ -moz-osx-font-smoothing : inherit;
36+ -webkit-appearance : none;
37+
38+ border-bottom-right-radius : 2px ;
39+ border-top-right-radius : 2px ;
40+ border : 1px solid darkgray;
41+ border-left : none;
42+ padding : 0 5px ;
43+ cursor : pointer;
44+ }
Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import "./SearchBox.css" ;
3+
4+ export default function SearchBox ( { value, onChange } ) {
5+ return (
6+ < form className = "SearchBox" >
7+ < input
8+ className = "SearchBox-input"
9+ type = "text"
10+ value = { value }
11+ onChange = { onChange }
12+ />
13+ < button className = "SearchBox-button" > GO</ button >
14+ </ form >
15+ ) ;
16+ }
Original file line number Diff line number Diff line change 1+ import React , { Component } from "react" ;
2+
3+ import SearchBox from "../components/SearchBox" ;
4+
5+ class App extends Component {
6+ state = {
7+ value : "cat"
8+ } ;
9+
10+ render ( ) {
11+ return < SearchBox value = { this . state . value } onChange = { this . handleChange } /> ;
12+ }
13+
14+ handleChange = e => {
15+ this . setState ( {
16+ value : e . currentTarget . value
17+ } ) ;
18+ } ;
19+ }
20+
21+ export default App ;
You can’t perform that action at this time.
0 commit comments