Created
February 21, 2020 07:39
-
-
Save zaynaib/d24ad2fc3f89d28d4a7486a46d6e8c4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import "./Input.css"; | |
import fonts from "../data.json"; | |
import Card from "./Card" | |
import Main from "./Main" | |
class Input extends React.Component{ | |
constructor(props) { | |
super(props); | |
// This binding is necessary to make `this` work in the callback | |
this.handleChange = this.handleChange.bind(this); | |
} | |
handleChange(event){ | |
this.props.onTemperatureChange(event.target.value); | |
} | |
render(){ | |
const temperature = this.props.temperature; | |
return( | |
<div> | |
<div className="InputBar"> | |
<input type="text" className="InputBar__searchFont" value={temperature} onChange={this.handleChange}></input> | |
<input type="text" className="InputBar__previewFont"></input> | |
<input type="number" className="InputBar__sizeFont"></input> | |
<button onClick={this.handleClick}>dark mode</button> | |
<button>light mode</button> | |
<button>list mode</button> | |
<button>reset</button> | |
</div> | |
</div> | |
) | |
} | |
} | |
export default Input; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Header from "./Header"; | |
import Input from "./Input"; | |
import Card from "./Card"; | |
import fonts from "../data.json"; | |
import "./Main.css" | |
//https://stackoverflow.com/questions/44309300/iterating-over-json-in-react | |
class Main extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.handleFahrenheitChange = this.handleFahrenheitChange.bind(this); | |
this.state = {temperature: ''}; | |
} | |
handleFahrenheitChange(temperature) { | |
this.setState({temperature}); | |
console.log(this.state.temperature) | |
} | |
render(){ | |
const temperature = this.state.temperature; | |
return( | |
<div> | |
<Header/> | |
<Input onTemperatureChange={this.handleFahrenheitChange} /> | |
<div className="container"> | |
{fonts.map( (fontDetail,index) => { | |
return <Card title ={fontDetail.name} author={fontDetail.author} display = {this.state.temperature}/> | |
})} | |
</div> | |
</div> | |
) | |
} | |
} | |
export default Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment