generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 125
London | 25-ITP-May | Halimatou Saddiyaa | Sprint 3 | Programmer humour #304
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
Open
Halimatou-saddiyaa
wants to merge
4
commits into
CodeYourFuture:main
Choose a base branch
from
Halimatou-saddiyaa:Programmer-humour
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 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fc61b22
Create html file to build programmer humour app
Halimatou-saddiyaa 09948b4
created function to make an API call
Halimatou-saddiyaa 78a9f4a
Added some styling to the app
Halimatou-saddiyaa 9d4ec8c
Modified code to prevent unnecessary scrolling
Halimatou-saddiyaa 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,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>XKCD Latest Comic</title> | ||
<link rel="stylesheet" type="text/css" href="style.css" /> | ||
</head> | ||
<body> | ||
<h1>Latest XKCD Comic</h1> | ||
<div id="image-container"></div> | ||
<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 @@ | ||
async function fetchLatestXKCD() { | ||
const apiEndpoint = 'https://xkcd.now.sh/?comic=latest'; | ||
|
||
try { | ||
const response = await fetch(apiEndpoint); | ||
if (!response.ok) { | ||
throw new Error(`Fetching error! Status: ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
console.log('Received data:', data); | ||
|
||
if (data.img) { | ||
const imgElement = document.createElement('img'); | ||
imgElement.src = data.img; | ||
imgElement.alt = data.alt || 'XKCD Comic'; | ||
|
||
const container = document.getElementById('image-container'); | ||
container.innerHTML = ''; | ||
container.appendChild(imgElement); | ||
} else { | ||
console.warn('No "img" property found in the data.'); | ||
} | ||
|
||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
const errorMsg = document.createElement('div'); | ||
errorMsg.className = 'error'; | ||
errorMsg.textContent = `Error fetching data: ${error.message}`; | ||
document.body.appendChild(errorMsg); | ||
} | ||
} | ||
|
||
fetchLatestXKCD(); | ||
|
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,41 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f0f2f5; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
margin: 0; | ||
padding: 20px; | ||
} | ||
|
||
h1 { | ||
color: #333; | ||
} | ||
|
||
#image-container { | ||
margin-top: 20px; | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 20px; | ||
justify-content: center; | ||
} | ||
|
||
#image-container img { | ||
max-width: 300px; | ||
border-radius: 12px; | ||
box-shadow: 0 4px 12px rgba(0,0,0,0.15); | ||
transition: transform 0.2s, box-shadow 0.2s; | ||
} | ||
|
||
#image-container img:hover { | ||
transform: scale(1.05); | ||
box-shadow: 0 8px 20px rgba(0,0,0,0.3); | ||
} | ||
|
||
.error { | ||
color: red; | ||
font-weight: bold; | ||
margin-top: 20px; | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor issue: Be careful when using height and padding - on some devices this causes scrollbars which are unnecessary for the size of this webpage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified min-height to use dynamic viewport height(dvh) to avoid unnecessary scroll and use box-sizing: border-box to prevent padding increasing the overall height.