Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulled the data #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
Binary file added .DS_Store
Binary file not shown.
17,825 changes: 17,719 additions & 106 deletions movie-browser/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion movie-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.21.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react-dom": "^16.8.6",
"styled-components": "^5.2.1"
},
"devDependencies": {
"react-scripts": "3.0.1"
Expand Down
7 changes: 5 additions & 2 deletions movie-browser/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react';
import FeatureImage from './FeatureImage';
import Movies from './Movies';

const App = () => {
return (
<div>
Movie Browser
<FeatureImage />
<Movies />
</div>
);
}
};

export default App;
11 changes: 11 additions & 0 deletions movie-browser/src/FeatureImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import cat from './images/cat.jpg'; // gives image path
const FeatureImage = () => {
return (
<div>
<img style={{ height: 300 }} src={cat} alt='' />
</div>
);
};

export default FeatureImage;
27 changes: 27 additions & 0 deletions movie-browser/src/MovieCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import styled, { ThemeProvider } from 'styled-components';

const theme = {
primarly: 'teal',
secondary: 'green',
font: 'sans-serif',
};

const H1 = styled.h1`
font-family: ${(props) => props.theme.font};
`;

const MovieCard = ({ data }) => {
const { title, description } = data;

return (
<ThemeProvider theme={theme}>
<div>
<H1>{title}</H1>
<p>{description}</p>
</div>
</ThemeProvider>
);
};

export default MovieCard;
35 changes: 35 additions & 0 deletions movie-browser/src/Movies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import axios from 'axios';
import React, { useState, useEffect } from 'react';

import MovieCard from './MovieCard';

const Movies = () => {
let [data, setData] = useState([]);

useEffect(() => {
const fetchData = async () => {
const result = await axios('https://ghibliapi.herokuapp.com/films');

if (result && result.data) {
setData(result.data);
}
};

fetchData();
}, []);

return (
<div>
<<<<<<< Updated upstream
{data.map((item) => {
return <MovieCard key={item.id} data={item} />;
=======
{data.data.map((item) => {
return <MovieCard key={item.id} {...item} />;
>>>>>>> Stashed changes
})}
</div>
);
};

export default Movies;
Binary file added movie-browser/src/images/cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added movie-browser/src/images/cat1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added movie-browser/src/images/cat2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added movie-browser/src/images/cat3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added movie-browser/src/images/cat4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.