-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
30 deletions.
There are no files selected for viewing
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
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
28 changes: 18 additions & 10 deletions
28
react-props-and-state-lab-onl01-seng-pt-041320/src/components/Pet.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
import React from 'react' | ||
import React from "react"; | ||
|
||
class Pet extends React.Component { | ||
render() { | ||
return ( | ||
<div className="card"> | ||
<div className="content"> | ||
<a className="header"> | ||
{/*'♀' OR '♂' */} | ||
PET NAME | ||
{this.props.pet.name}{" "} | ||
{this.props.pet.gender === "female" ? "♀" : "♂"}{" "} | ||
</a> | ||
<div className="meta"> | ||
<span className="date">PET TYPE</span> | ||
<span className="date">{this.props.pet.type}</span> | ||
</div> | ||
<div className="description"> | ||
<p>Age: PET AGE</p> | ||
<p>Weight: PET WEIGHT</p> | ||
<p>Age: {this.props.pet.age}</p> | ||
<p>Weight: {this.props.pet.weight}</p> | ||
</div> | ||
</div> | ||
<div className="extra content"> | ||
<button className="ui disabled button">Already adopted</button> | ||
<button className="ui primary button">Adopt pet</button> | ||
{this.props.pet.isAdopted ? ( | ||
<button className="ui disabled button">Already adopted</button> | ||
) : ( | ||
<button | ||
className="ui primary button" | ||
onClick={() => this.props.onAdoptPet(this.props.pet.id)} | ||
> | ||
Adopt pet | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
); | ||
} | ||
} | ||
|
||
export default Pet | ||
export default Pet; |
12 changes: 8 additions & 4 deletions
12
react-props-and-state-lab-onl01-seng-pt-041320/src/components/PetBrowser.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import React from 'react' | ||
import React from "react"; | ||
|
||
import Pet from './Pet' | ||
import Pet from "./Pet"; | ||
|
||
class PetBrowser extends React.Component { | ||
render() { | ||
return <div className="ui cards">PET COMPONENT SHOULD GO HERE</div> | ||
const petCards = this.props.pets.map((pet) => ( | ||
<Pet pet={pet} key={pet.id} onAdoptPet={this.props.onAdoptPet} /> | ||
)); | ||
|
||
return <div className="ui cards">{petCards}</div>; | ||
} | ||
} | ||
|
||
export default PetBrowser | ||
export default PetBrowser; |