Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
text-shadow: 1px 1px 5px #fff;
}
/* write your parent styles in here for your App.js */

43 changes: 40 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
import React from 'react';
import './App.css';
import React, {useState, useEffect} from 'react';
import './App.css'

import axios from 'axios'
import Character from './components/Character'


// console.log('data', data)
// data.map(item =>{
// console.log('hello', item)
// })
const App = () => {
const [character, setCharacter] = useState([])

const info= character.map(info => {
return ( info)
})
// console.log('hello', info)

useEffect(() => {
axios.get(`https://swapi.dev/api/people`)
.then (res =>{
setCharacter(res.data)

})
.catch (err => console.error(err))
}, [])


character.map(item => {
console.log ('waiting', item)
})

// Try to think through what state you'll need for this app before starting. Then build out
// the state properties here.

// Fetch characters from the API in an effect hook. Remember, anytime you have a
// side effect in a component, you want to think about which state and/or props it should
// sync up with, if any.

// console.log(character)
//
return (
<div className="App">
<h1 className="Header">Characters</h1>
<h2> {
character.map(character =>{
return (
<Character key = {`App-characterMap-character${character.created}`} character= {character} info={info} />
)
})
}</h2>
</div>
);
}
Expand Down
36 changes: 36 additions & 0 deletions src/components/Character.js
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
// Write your Character component here
import React, {useState, useEffect} from 'react'
import styled from 'styled-components'
import axios from 'axios'

const StyledCharacter= styled.div`
border: 1px solid lemonchiffon;
border-radius: 20%;
margin: 5%
`
const StyledButton= styled.button`
background-color:coral;
color:white;

`
const CharacterItem = (props) => {
const[button, setButton]= useState(true)

const {character} = props


const buttonClick = () => {
setButton(!button)
}


return(
<StyledCharacter >
<h2>{character.name}</h2>
<StyledButton >Want To Learn More?</StyledButton>
{/* <p>{`hailing from ${character.homeworld}, ${character.name} is a human with ${character.hair_color} hair, and ${character.eye_color} eyes.`}</p> */}
</StyledCharacter>
)
}


export default CharacterItem
2 changes: 1 addition & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ body {
padding: 0;
font-family: sans-serif;
background-image: url('./images/sw-bg.jpg');
background-size: cover;
background-size:cover;
}