-
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.
1 parent
73836e4
commit 1e7ce00
Showing
11 changed files
with
927 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
|
||
export default function Header() { | ||
return ( | ||
<header className="header"> | ||
<img className="header-img" src="images/troll-face.png" alt="" /> | ||
<h2 className="header-title">Meme Generator</h2> | ||
<h4 className="header-project">React Course - Project</h4> | ||
</header> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { useState } from "react"; | ||
import memesData from "../memesData"; | ||
|
||
export default function Meme() { | ||
const [meme, setMeme] = useState({ | ||
topText: "", | ||
bottomText: "", | ||
randomImage: "https://i.imgflip.com/345v97.jpg", | ||
}); | ||
|
||
const [allMemeImages, setAllMemeImages] = useState(memesData); | ||
|
||
function getMemeImage() { | ||
const memesArray = allMemeImages.data.memes; | ||
const randomNumber = Math.floor(Math.random() * memesArray.length); | ||
const url = memesArray[randomNumber].url; | ||
setMeme((prevMeme) => ({ | ||
...prevMeme, | ||
randomImage: url, | ||
})); | ||
} | ||
return ( | ||
<main> | ||
<div className="form"> | ||
<input | ||
className="form-input" | ||
placeholder="Top Text" | ||
type="text" | ||
name="" | ||
id="" | ||
/> | ||
<input | ||
className="form-input" | ||
placeholder="Bottom Text" | ||
type="text" | ||
name="" | ||
id="" | ||
/> | ||
<button className="form-btn" onClick={getMemeImage}> | ||
Get a new meme image🖼 | ||
</button> | ||
</div> | ||
<img src={meme.randomImage} className="meme-image" /> | ||
</main> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,42 +0,0 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
a:nth-of-type(2) .logo { | ||
animation: logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} | ||
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,35 +1,12 @@ | ||
import { useState } from 'react' | ||
import reactLogo from './assets/react.svg' | ||
import viteLogo from '/vite.svg' | ||
import './App.css' | ||
|
||
function App() { | ||
const [count, setCount] = useState(0) | ||
import React from "react"; | ||
import Header from "../components/header"; | ||
import Meme from "../components/meme"; | ||
|
||
export default function App() { | ||
return ( | ||
<> | ||
<div> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src={viteLogo} className="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://react.dev" target="_blank"> | ||
<img src={reactLogo} className="logo react" alt="React logo" /> | ||
</a> | ||
</div> | ||
<h1>Vite + React</h1> | ||
<div className="card"> | ||
<button onClick={() => setCount((count) => count + 1)}> | ||
count is {count} | ||
</button> | ||
<p> | ||
Edit <code>src/App.jsx</code> and save to test HMR | ||
</p> | ||
</div> | ||
<p className="read-the-docs"> | ||
Click on the Vite and React logos to learn more | ||
</p> | ||
<Header /> | ||
<Meme /> | ||
</> | ||
) | ||
); | ||
} | ||
|
||
export default App |
This file was deleted.
Oops, something went wrong.
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,69 +1,64 @@ | ||
:root { | ||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; | ||
line-height: 1.5; | ||
font-weight: 400; | ||
|
||
color-scheme: light dark; | ||
color: rgba(255, 255, 255, 0.87); | ||
background-color: #242424; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
a { | ||
font-weight: 500; | ||
color: #646cff; | ||
text-decoration: inherit; | ||
body { | ||
font-family: "Karla", sans-serif; | ||
margin: 0; | ||
} | ||
a:hover { | ||
color: #535bf2; | ||
|
||
main { | ||
padding: 36px; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
.header { | ||
display: flex; | ||
place-items: center; | ||
min-width: 320px; | ||
min-height: 100vh; | ||
align-items: center; | ||
height: 65px; | ||
background: linear-gradient(90deg, #672280 1.18%, #a626d3 100%); | ||
color: white; | ||
padding: 20px; | ||
} | ||
|
||
h1 { | ||
font-size: 3.2em; | ||
line-height: 1.1; | ||
.header-img { | ||
height: 100%; | ||
margin-right: 6px; | ||
} | ||
|
||
button { | ||
border-radius: 8px; | ||
border: 1px solid transparent; | ||
padding: 0.6em 1.2em; | ||
font-size: 1em; | ||
.header-title { | ||
font-size: 20px; | ||
margin-right: auto; | ||
} | ||
|
||
.header-project { | ||
font-size: 0.75rem; | ||
font-weight: 500; | ||
font-family: inherit; | ||
background-color: #1a1a1a; | ||
cursor: pointer; | ||
transition: border-color 0.25s; | ||
} | ||
button:hover { | ||
border-color: #646cff; | ||
|
||
.form { | ||
display: grid; | ||
grid-template: 40px 40px / 1fr 1fr; | ||
gap: 17px; | ||
margin-bottom: 17px; | ||
} | ||
|
||
.form-input { | ||
font-family: "Karla", sans-serif; | ||
border-radius: 5px; | ||
border: 1px solid #d5d4d8; | ||
text-indent: 5px; | ||
} | ||
button:focus, | ||
button:focus-visible { | ||
outline: 4px auto -webkit-focus-ring-color; | ||
|
||
.form-btn { | ||
font-family: "Karla", sans-serif; | ||
border-radius: 5px; | ||
grid-column: 1 / -1; | ||
background: linear-gradient(90deg, #672280 1.18%, #a626d3 100%); | ||
color: white; | ||
cursor: pointer; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
:root { | ||
color: #213547; | ||
background-color: #ffffff; | ||
} | ||
a:hover { | ||
color: #747bff; | ||
} | ||
button { | ||
background-color: #f9f9f9; | ||
} | ||
.meme-image { | ||
width: 100%; | ||
border-radius: 3px; | ||
} |
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,10 +1,10 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App.jsx' | ||
import './index.css' | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import App from "./App.jsx"; | ||
import "./index.css"; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')).render( | ||
ReactDOM.createRoot(document.getElementById("root")).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
) | ||
</React.StrictMode> | ||
); |