-
Notifications
You must be signed in to change notification settings - Fork 10
Nikita-w1-Browsers #31
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Test Summary | ||
|
||
**Mentors**: For more information on how to review homework assignments, please refer to the [Review Guide](https://github.com/HackYourFuture/mentors/blob/main/assignment-support/review-guide.md). | ||
|
||
### 2-Browsers - Week1 | ||
|
||
| Exercise | Passed | Failed | ESLint | | ||
|------------------|--------|--------|--------| | ||
| ex1-bookList | 6 | - | ✓ | | ||
| ex2-aboutMe | 4 | - | ✓ | | ||
| ex3-hijackLogo | 3 | - | ✓ | | ||
| ex4-whatsTheTime | 6 | - | ✓ | | ||
| ex5-catWalk | 5 | - | ✓ | |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,38 @@ https://hackyourfuture.github.io/example-pages/Browsers/Week1/1-booklist/ | |
//cspell: enable | ||
|
||
function createBookList(books) { | ||
// TODO your code goes in here, return the ul element | ||
const listBooks = document.createElement('ul'); | ||
listBooks.classList.add('list__books'); | ||
|
||
books.forEach((book) => { | ||
const paragraph = document.createElement('p'); | ||
paragraph.classList.add('title'); | ||
|
||
const itemBook = document.createElement('li'); | ||
itemBook.classList.add('item__book'); | ||
|
||
// if (book.alreadyRead) { | ||
// itemBook.classList.add('item__book-read'); | ||
// } else { | ||
// itemBook.classList.add('item__book-not-read'); | ||
// } | ||
book.alreadyRead | ||
? itemBook.classList.add('item__book-read') | ||
: itemBook.classList.add('item__book-not-read'); | ||
|
||
const imgBook = document.createElement('img'); | ||
imgBook.classList.add('img__book'); | ||
imgBook.src = book.image; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you just love how much cleaner using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, thank you. Interesting graph and site |
||
imgBook.alt = `Cover of ${book.title} by ${book.author}`; | ||
// paragraph.textContent = book.title + ' ' + book.author; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could still delete this comment, but don't worry about it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okey, I just left it to remember the different way |
||
paragraph.textContent = `${book.title} ${book.author}`; | ||
|
||
itemBook.appendChild(imgBook); | ||
itemBook.appendChild(paragraph); | ||
listBooks.appendChild(itemBook); | ||
}); | ||
|
||
return listBooks; | ||
} | ||
|
||
function main() { | ||
|
@@ -28,18 +59,21 @@ function main() { | |
author: 'Don Norman', | ||
isbn: '978-0465050659', | ||
alreadyRead: false, | ||
image: 'assets/the_design_of_everyday_things.jpg', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I were in a particularly bad mood I would say, "this is not actually the image, but a link to the image, so use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was in danger, but it seems we all got lucky with the weather in the Netherlands this spring |
||
}, | ||
{ | ||
title: 'The Most Human Human', | ||
author: 'Brian Christian', | ||
isbn: '978-1617933431', | ||
alreadyRead: true, | ||
image: 'assets/the_most_human_human.jpg', | ||
}, | ||
{ | ||
title: 'The Pragmatic Programmer', | ||
author: 'Andrew Hunt', | ||
isbn: '978-0201616224', | ||
alreadyRead: true, | ||
image: 'assets/the_pragmatic_programmer.jpg', | ||
}, | ||
]; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
/* Write your style here */ | ||
.list__books { | ||
list-style-type: none; | ||
display: flex; | ||
gap: 25px; | ||
flex-wrap: wrap; | ||
} | ||
|
||
.item__book { | ||
padding: 10px; | ||
} | ||
|
||
.item__book-read { | ||
background-color: green; | ||
} | ||
|
||
.item__book-not-read { | ||
background-color: red; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/* 3. Add a css rule for .list-item to make the color red. */ | ||
.list-item { | ||
color: red; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,15 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B | |
HackYourFuture logo instead. | ||
------------------------------------------------------------------------------*/ | ||
function hijackGoogleLogo() { | ||
// TODO your code goes in here | ||
} | ||
|
||
hijackGoogleLogo(); | ||
const googleLogo = document.querySelector('.lnXdpd'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this identifier is randomly generated, and thus prone to change. Do you think you could find one that is potentially more stable? |
||
|
||
if (googleLogo) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love the check to see if we got anything. I think it could be even better if we take this as an opportunity to escape the function a bit earlier, by writing |
||
const newLogoUrl = 'https://github.com/HackYourFuture/Assignments/blob/main/assets/hyf-logo-black-bg-small.png'; | ||
|
||
googleLogo.src = newLogoUrl; | ||
googleLogo.srcset = newLogoUrl; | ||
} | ||
} | ||
|
||
hijackGoogleLogo(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,18 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B | |
second). Use `setInterval()` to make sure the time stays current. | ||
2. Have the function execute when it's loading in the browser. | ||
------------------------------------------------------------------------------*/ | ||
|
||
const container = document.querySelector('body'); | ||
const titleTime = document.createElement('h1'); | ||
titleTime.textContent = 'Loading...'; | ||
container.appendChild(titleTime); | ||
|
||
function addCurrentTime() { | ||
// TODO complete this function | ||
let currentTime = new Date().toLocaleTimeString('en-GB', { timeZone: 'Europe/Amsterdam' }); | ||
titleTime.textContent = currentTime; | ||
} | ||
|
||
// TODO execute `addCurrentTime` when the browser has completed loading the page | ||
window.addEventListener('DOMContentLoaded', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you choose this specific event to listen for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to be sure that our DOM tree is fully completed (ready). Or I need to change it? |
||
addCurrentTime(); | ||
setInterval(addCurrentTime, 1000); | ||
}); |
RHSebregts marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, the cats walks well, and the code looks a lot cleaner and more readable! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, but I think the cat's starting to make me crazy. I found it again in the API module |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,38 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B | |
|
||
https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif | ||
-----------------------------------------------------------------------------*/ | ||
const movingCat = document.querySelector('img'); | ||
let startPoint = 0; | ||
let timerId; | ||
const clientWidth = document.documentElement.clientWidth; | ||
const widthCat = movingCat.clientWidth; | ||
let isCatCenter = false; | ||
const centerPosition = (clientWidth - widthCat) / 2; | ||
const dancingCatGIF = | ||
'https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif'; | ||
const walkingCatGIF = 'http://www.anniemation.com/clip_art/images/cat-walk.gif'; | ||
|
||
function catWalk() { | ||
// TODO complete this function | ||
movingCat.style.left = `${startPoint}px`; | ||
startPoint += 10; | ||
|
||
if (startPoint >= clientWidth - widthCat) { | ||
startPoint = 0; | ||
isCatCenter = false; | ||
} | ||
|
||
if (startPoint >= centerPosition && !isCatCenter) { | ||
clearInterval(timerId); | ||
movingCat.src = dancingCatGIF; | ||
|
||
setTimeout(() => { | ||
movingCat.src = walkingCatGIF; | ||
isCatCenter = true; | ||
timerId = setInterval(catWalk, 50); | ||
}, 5000); | ||
} | ||
} | ||
|
||
// TODO execute `catWalk` when the browser has completed loading the page | ||
window.addEventListener('DOMContentLoaded', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you choose this specific event to listen for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to be sure that our DOM tree is fully completed (ready) |
||
timerId = setInterval(catWalk, 50); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*** Unit Test Error Report *** | ||
|
||
PASS .dist/2-Browsers/Week1/unit-tests/ex1-bookList.test.js | ||
br-wk1-ex1-bookList | ||
✅ HTML should be syntactically valid (76 ms) | ||
✅ should have all TODO comments removed | ||
✅ should contain a <ul> that is a child of <div id="bookList"> (1 ms) | ||
✅ should contain a <ul> with 3 <li> elements (1 ms) | ||
✅ should contain an <li> with title and author for each book of the `myBooks` array (1 ms) | ||
✅ should contain an <img> element for each book | ||
|
||
Test Suites: 1 passed, 1 total | ||
Tests: 6 passed, 6 total | ||
Snapshots: 0 total | ||
Time: 1.666 s, estimated 5 s | ||
Ran all test suites matching /\/Users\/nikitastefanchuk\/Desktop\/Projects\/Assignments-cohort52\/.dist\/2-Browsers\/Week1\/unit-tests\/ex1-bookList.test.js/i. | ||
No linting errors detected. | ||
No spelling errors detected. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
*** Unit Test Error Report *** | ||
|
||
PASS .dist/2-Browsers/Week1/unit-tests/ex2-aboutMe.test.js | ||
br-wk1-ex2-aboutMe | ||
✅ should be syntactically valid (83 ms) | ||
✅ should have all TODO comments removed | ||
✅ each <li> should have the CSS class `list-item` (1 ms) | ||
✅ each <li> should rendered red (= rgb(255, 0, 0)) (8 ms) | ||
|
||
Test Suites: 1 passed, 1 total | ||
Tests: 4 passed, 4 total | ||
Snapshots: 0 total | ||
Time: 1.682 s, estimated 2 s | ||
Ran all test suites matching /\/Users\/nikitastefanchuk\/Desktop\/Projects\/Assignments-cohort52\/.dist\/2-Browsers\/Week1\/unit-tests\/ex2-aboutMe.test.js/i. | ||
No linting errors detected. | ||
No spelling errors detected. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
*** Unit Test Error Report *** | ||
|
||
PASS .dist/2-Browsers/Week1/unit-tests/ex3-hijackLogo.test.js | ||
br-wk1-ex3-hijackLogo | ||
✅ should have all TODO comments removed | ||
✅ should set the `.src` property | ||
✅ should set the `.srcset` property | ||
|
||
Test Suites: 1 passed, 1 total | ||
Tests: 3 passed, 3 total | ||
Snapshots: 0 total | ||
Time: 0.164 s, estimated 1 s | ||
Ran all test suites matching /\/Users\/nikitastefanchuk\/Desktop\/Projects\/Assignments-cohort52\/.dist\/2-Browsers\/Week1\/unit-tests\/ex3-hijackLogo.test.js/i. | ||
No linting errors detected. | ||
|
||
|
||
*** Spell Checker Report *** | ||
|
||
2-Browsers/Week1/assignment/ex3-hijackLogo.js:10:50 - Unknown word (Xdpd) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*** Unit Test Error Report *** | ||
|
||
PASS .dist/2-Browsers/Week1/unit-tests/ex4-whatsTheTime.test.js | ||
br-wk1-ex4-whatsTheTime | ||
✅ HTML should be syntactically valid (74 ms) | ||
✅ should have all TODO comments removed | ||
✅ should use `setInterval()` | ||
✅ should not call `setInterval()` more than once (2002 ms) | ||
✅ should use `window.onload` or `window.addEventListener()` for the `load` or `DOMContentLoaded` event (1 ms) | ||
✅ `window.onload` or `window.addEventListener` should not call its event handler function (1 ms) | ||
|
||
Test Suites: 1 passed, 1 total | ||
Tests: 6 passed, 6 total | ||
Snapshots: 0 total | ||
Time: 3.666 s, estimated 4 s | ||
Ran all test suites matching /\/Users\/nikitastefanchuk\/Desktop\/Projects\/Assignments-cohort52\/.dist\/2-Browsers\/Week1\/unit-tests\/ex4-whatsTheTime.test.js/i. | ||
No linting errors detected. | ||
No spelling errors detected. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*** Unit Test Error Report *** | ||
|
||
PASS .dist/2-Browsers/Week1/unit-tests/ex5-catWalk.test.js | ||
br-wk1-ex5-catWalk | ||
✅ HTML should be syntactically valid (73 ms) | ||
✅ should have all TODO comments removed | ||
✅ should use `setInterval()` and/or `setTimeout()` | ||
✅ should use `window.onload` or `window.addEventListener()` for the `load` or `DOMContentLoaded` event | ||
✅ `window.onload` or `window.addEventListener` should not call its event handler function | ||
|
||
Test Suites: 1 passed, 1 total | ||
Tests: 5 passed, 5 total | ||
Snapshots: 0 total | ||
Time: 1.689 s | ||
Ran all test suites matching /\/Users\/nikitastefanchuk\/Desktop\/Projects\/Assignments-cohort52\/.dist\/2-Browsers\/Week1\/unit-tests\/ex5-catWalk.test.js/i. | ||
No linting errors detected. | ||
No spelling errors detected. |
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.
👍