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

created public folder #2528

Open
wants to merge 1 commit 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
20 changes: 20 additions & 0 deletions .codesandbox/workspace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"responsive-preview": {
"Mobile": [
320,
675
],
"Tablet": [
1024,
765
],
"Desktop": [
1400,
800
],
"Desktop HD": [
1920,
1080
]
}
}
12 changes: 0 additions & 12 deletions index.html

This file was deleted.

12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "static",
"name": "quote-generator",
"version": "1.0.0",
"description": "This is a static template with no bundling",
"description": "",
"main": "index.html",
"scripts": {
"start": "serve",
Expand All @@ -11,11 +11,7 @@
"type": "git",
"url": "git+https://github.com/codesandbox-app/static-template.git"
},
"keywords": [
"static",
"template",
"codesandbox"
],
"keywords": [],
"author": "Ives van Hoorne",
"license": "MIT",
"bugs": {
Expand All @@ -25,4 +21,4 @@
"devDependencies": {
"serve": "^11.2.0"
}
}
}
35 changes: 35 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="style.css" />
<script defer src="script.js"></script>
<script
src="https://kit.fontawesome.com/9c77fdc30e.js"
crossorigin="anonymous"
></script>
<title>Static Template</title>
</head>
<body>
<div class="container">
<div class="quote-left"><i class="fa-solid fa-quote-left"></i></div>
<span class="quote text-animation" id="quote"
>"One of my movies was called 'True Lies.' It's what the Democrats
should have called their convention."</span
>
<div class="author text-animation" id="author">
~Arnold Schwarzenegger~
</div>
<div class="buttons">
<div class="media-btns">
<button class="media-btn" id="twitter-share">
<i class="fa-brands fa-twitter" title="tweet this"></i>
</button>
</div>
<button class="new-quote-btn" id="new-quote">New Quote</button>
</div>
</div>
</body>
</html>
49 changes: 49 additions & 0 deletions public/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const quoteElement = document.getElementById("quote");
const newQuoteBtn = document.getElementById("new-quote");
const author = document.getElementById("author");
const twitterBtn = document.getElementById("twitter-share");
const instagramBtn = document.getElementById("instagram-share");

let apiQuotes = [];

function newQuote() {
const quote = apiQuotes[Math.floor(Math.random() * apiQuotes.length)];

quoteElement.innerText = quote.text;
author.innerText = `~${quote.author}~`;
console.log(quote.text.length);
if (quote.text.length >= 100) {
quoteElement.classList.add("long-text");
} else {
quoteElement.classList.remove("long-text");
}

quoteElement.classList.remove("text-animation");
author.classList.remove("text-animation");
void quoteElement.offsetWidth;
void author.offsetWidth;
quoteElement.classList.add("text-animation");
author.classList.add("text-animation");
}
async function getQuotes() {
try {
const apiUrl =
"https://jacintodesign.github.io/quotes-api/data/quotes.json";
const response = await fetch(apiUrl);
apiQuotes = await response.json();
} catch (error) {}
}
getQuotes();

newQuoteBtn.addEventListener("click", () => {
newQuote();
});

twitterBtn.addEventListener("click", () => {
twitterBtn.addEventListener("click", () => {
const quoteText = quoteElement.innerText;
const authorText = author.innerText;
const twitterUrl = `https://twitter.com/intent/tweet?text=${quoteText}`;
window.open(twitterUrl, "_blank");
});
});
105 changes: 105 additions & 0 deletions public/style.css

Large diffs are not rendered by default.