Skip to content

Commit

Permalink
Display two gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
LoanR committed Sep 1, 2020
1 parent c8fee79 commit 2a63e34
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 56 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Gif-quiz</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
35 changes: 0 additions & 35 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
38 changes: 18 additions & 20 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import GifList from './components/gif_list';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
class App extends React.Component {
render() {
const gifs = [
{
url: 'https://media.giphy.com/media/j5PrIx7lLNRo4pGYYB/source.gif',
id: 'j5PrIx7lLNRo4pGYYB',
}, {
url: 'https://media.giphy.com/media/MeJgB3yMMwIaHmKD4z/source.gif',
id: 'MeJgB3yMMwIaHmKD4z',
},
]
return (
<div className="App">
<GifList gifs={gifs} />
</div>
);
}
}

export default App;
12 changes: 12 additions & 0 deletions src/components/gif.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

class Gif extends React.Component {
render() {
const {url} = this.props
return (
<img src={url} alt="awesome gif"/>
)
}
}

export default Gif;
15 changes: 15 additions & 0 deletions src/components/gif_list.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import Gif from './gif';

class GifList extends React.Component {
render() {
const {gifs} = this.props;
return (
<ul>
{gifs.map(({url, id}) => <li key={id}><Gif url={url} key={id} /></li>)}
</ul>
)
}
}

export default GifList

0 comments on commit 2a63e34

Please sign in to comment.