This repository was archived by the owner on Apr 18, 2025. It is now read-only.
generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 83
NW6 | Pedro Ricciardi | JS3 Module | [TECH ED] Programmer Humour | Week 3 Backlog #303
Open
PERicci
wants to merge
7
commits into
CodeYourFuture:main
Choose a base branch
from
PERicci:NW6/PedroRicciardi-JS3Week3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6771155
layout done
PERicci 0f78583
fetch and render implemented
PERicci c65d7b5
background colour changed
PERicci c308a12
show error to the user
PERicci 8e5d8e5
added noopener and noreferrer
PERicci ca09cc9
html root element content deleted to receive the fetched data
PERicci fc9e46f
some adjustments requested by Jed Thompson
PERicci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
|
||
<link href="https://fonts.googleapis.com/css2?family=Comic+Neue:wght@300;400;700&display=swap" rel="stylesheet"> | ||
<link rel="stylesheet" href="styles.css"> | ||
<title>xkcd webcomic</title> | ||
</head> | ||
|
||
<body> | ||
<header> | ||
<h1>xkcd</h1> | ||
<p>Webcomic</p> | ||
</header> | ||
<main id="root"> | ||
|
||
</main> | ||
<footer> | ||
<p>Comic made by Randall Munroe from <a href="https://xkcd.com/" target="_blank" | ||
rel="noopener noreferrer">xkcd.com</a></p> | ||
<p>Page made by Pedro Ricciardi - <a href="https://www.linkedin.com/in/pedro-ricciardi/" target="_blank" | ||
rel="noopener noreferrer">LinkedIn</a> and <a href="https://github.com/PERicci/" target="_blank" | ||
rel="noopener noreferrer">GitHub</a> | ||
</p> | ||
</footer> | ||
|
||
<script src="./script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains hidden or 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,35 @@ | ||
const api = "https://xkcd.now.sh/?comic=latest" | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
fetchComic(api); | ||
}); | ||
|
||
function fetchComic(api) { | ||
fetch(api) | ||
.then((response) => response.json()) | ||
.then((lastComic) => renderPage(lastComic)) | ||
.catch((error) => showError(error)); | ||
} | ||
|
||
function renderPage(data) { | ||
console.log(data); | ||
const root = document.querySelector("#root") | ||
const html = htmlGenerator(data.title, data.img, data.alt); | ||
|
||
root.innerHTML = html; | ||
} | ||
|
||
function htmlGenerator(title, imageUrl, imageAlt) { | ||
let html = `<h2>${title}</h2> | ||
<img src="${imageUrl}" alt="${imageAlt}"> | ||
<p>From <a href="https://xkcd.com/" target="_blank">xkcd.com</a></p> | ||
</p>` | ||
|
||
return html | ||
} | ||
|
||
function showError(error) { | ||
console.log(error); | ||
const root = document.querySelector("#root") | ||
root.innerHTML = `<h2>${error}</h2>` | ||
} | ||
PERicci marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,100 @@ | ||
:root { | ||
--page-width: 50vw; | ||
--primary-colour: #3a7bd5; | ||
--secondary-colour: #362db3; | ||
--text-colour-dark: #333; | ||
--text-colour-light: #ffffff; | ||
--background-colour: #798b9b; | ||
--foreground-colour: #fff; | ||
--font-family: "Comic Neue", cursive; | ||
--border-radius: 0.25rem; | ||
--box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
body, main, header, footer, div { | ||
box-sizing: border-box; | ||
} | ||
|
||
h1, h2, h3, p, a { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
a, a:active, a:visited { | ||
text-decoration: none; | ||
color: var(--secondary-colour); | ||
} | ||
|
||
a:hover { | ||
font-weight: 700; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
background-color: var(--background-colour); | ||
font-family: var(--font-family); | ||
|
||
height: 100vh; | ||
|
||
display: grid; | ||
grid-template-rows: auto 1fr auto; | ||
} | ||
|
||
header, main, footer { | ||
width: var(--page-width); | ||
margin: 0 auto; | ||
} | ||
|
||
h1 { | ||
font-size: 5rem; | ||
line-height: 4rem; | ||
margin: 0; | ||
color: var(--primary-colour); | ||
} | ||
|
||
h2 { | ||
font-size: 2.5rem; | ||
} | ||
|
||
header { | ||
background-color: var(--foreground-colour); | ||
padding: 1rem 2rem; | ||
} | ||
|
||
main { | ||
background-color: var(--primary-colour); | ||
text-align: center; | ||
padding: 2rem; | ||
|
||
color: var(--text-colour-light); | ||
|
||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
main a, main a:active, main a:visited { | ||
color: var(--text-colour-light); | ||
text-decoration: underline; | ||
} | ||
|
||
img { | ||
padding: 1rem; | ||
background-color: var(--foreground-colour); | ||
border-radius: var(--border-radius); | ||
margin: 1rem 0 0.5rem; | ||
} | ||
|
||
footer { | ||
background-color: var(--foreground-colour); | ||
padding: 0.5rem 1rem; | ||
text-align: center; | ||
|
||
color: var(--text-colour-dark); | ||
font-weight: 300; | ||
} | ||
|
||
footer a{ | ||
color: var(--secondary-colour); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.