Skip to content

Commit f9578fe

Browse files
authored
Meme Generator App pushed
1 parent 1b187d8 commit f9578fe

File tree

15 files changed

+1309
-403
lines changed

15 files changed

+1309
-403
lines changed

README.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,68 @@
1-
# ReactThings
2-
this my repository for practice about react and this is it
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `npm start`
8+
9+
Runs the app in the development mode.<br />
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br />
13+
You will also see any lint errors in the console.
14+
15+
### `npm test`
16+
17+
Launches the test runner in the interactive watch mode.<br />
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `npm run build`
21+
22+
Builds the app for production to the `build` folder.<br />
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br />
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `npm run eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35+
36+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37+
38+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).
45+
46+
### Code Splitting
47+
48+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49+
50+
### Analyzing the Bundle Size
51+
52+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53+
54+
### Making a Progressive Web App
55+
56+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57+
58+
### Advanced Configuration
59+
60+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61+
62+
### Deployment
63+
64+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65+
66+
### `npm run build` fails to minify
67+
68+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

package-lock.json

Lines changed: 787 additions & 328 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "reactjs",
2+
"name": "memegenerator",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
66
"@testing-library/jest-dom": "^4.2.4",
7-
"@testing-library/react": "^9.4.0",
7+
"@testing-library/react": "^9.5.0",
88
"@testing-library/user-event": "^7.2.1",
9-
"react": "^16.12.0",
10-
"react-dom": "^16.12.0",
9+
"react": "^16.13.0",
10+
"react-dom": "^16.13.0",
1111
"react-scripts": "3.4.0"
1212
},
1313
"scripts": {

public/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from "react"
2+
import ReactDOM from "react-dom"
3+
import App from "./App"
4+
5+
ReactDOM.render(<App />, document.getElementById("root"))

src/App.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
height: 40vmin;
7+
pointer-events: none;
8+
}
9+
10+
@media (prefers-reduced-motion: no-preference) {
11+
.App-logo {
12+
animation: App-logo-spin infinite 20s linear;
13+
}
14+
}
15+
16+
.App-header {
17+
background-color: #282c34;
18+
min-height: 100vh;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
justify-content: center;
23+
font-size: calc(10px + 2vmin);
24+
color: white;
25+
}
26+
27+
.App-link {
28+
color: #61dafb;
29+
}
30+
31+
@keyframes App-logo-spin {
32+
from {
33+
transform: rotate(0deg);
34+
}
35+
to {
36+
transform: rotate(360deg);
37+
}
38+
}

src/App.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react"
2+
import Header from "./Header.js"
3+
import MemeGenerator from "./MemeGenerator"
4+
5+
function App() {
6+
return (
7+
<div>
8+
<Header />
9+
<MemeGenerator />
10+
</div>
11+
)
12+
}
13+
14+
export default App

src/App.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import App from './App';
4+
5+
test('renders learn react link', () => {
6+
const { getByText } = render(<App />);
7+
const linkElement = getByText(/learn react/i);
8+
expect(linkElement).toBeInTheDocument();
9+
});

src/Header.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from "react"
2+
3+
function Header() {
4+
return (
5+
<header>
6+
<img
7+
src="https://m.media-amazon.com/images/M/MV5BYzllMjE1MTItZjQ5Mi00NTU2LWFiMTgtMGNkNzlhYzVkZmMzXkEyXkFqcGdeQXVyNjc5Mjg0NjU@._V1_QL50_.jpg"
8+
alt="Problem?"
9+
/>
10+
<p>Meme Generator</p>
11+
</header>
12+
)
13+
}
14+
15+
export default Header

src/MemeGenerator.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React, {Component} from "react"
2+
3+
class MemeGenerator extends Component {
4+
constructor() {
5+
super()
6+
this.state = {
7+
topText: "",
8+
bottomText: "",
9+
randomImg: "http://i.imgflip.com/1bij.jpg",
10+
allMemeImgs: []
11+
}
12+
this.handleChange = this.handleChange.bind(this)
13+
this.handleSubmit = this.handleSubmit.bind(this)
14+
15+
}
16+
17+
componentDidMount() {
18+
fetch("https://api.imgflip.com/get_memes")
19+
.then(response => response.json())
20+
.then(response => {
21+
const {memes} = response.data
22+
this.setState({ allMemeImgs: memes })
23+
})
24+
}
25+
26+
/**
27+
* Create the onChagne handler method
28+
* It should update the corresponding state on every change of the input box
29+
*/
30+
31+
handleChange(event) {
32+
const {name, value} = event.target
33+
this.setState({ [name]: value })
34+
}
35+
36+
handleSubmit(event){
37+
event.preventDefault()
38+
const randNum=Math.floor(Math.random()*this.state.allMemeImgs.length)
39+
const randMemeImg=this.state.allMemeImgs[randNum].url
40+
this.setState({randomImg:randMemeImg})
41+
}
42+
43+
render() {
44+
return (
45+
<div>
46+
<form className="meme-form" onSubmit={this.handleSubmit}>
47+
<input
48+
type="text"
49+
name="topText"
50+
placeholder="Top Text"
51+
value={this.state.topText}
52+
onChange={this.handleChange}
53+
/>
54+
<input
55+
type="text"
56+
name="bottomText"
57+
placeholder="Bottom Text"
58+
value={this.state.bottomText}
59+
onChange={this.handleChange}
60+
/>
61+
62+
<button>Generator</button>
63+
</form>
64+
<div className="meme">
65+
<img src={this.state.randomImg} alt="" />
66+
<h2 className="top">{this.state.topText}</h2>
67+
<h2 className="bottom">{this.state.bottomText}</h2>
68+
</div>
69+
</div>
70+
)
71+
}
72+
}
73+
74+
export default MemeGenerator

0 commit comments

Comments
 (0)