Skip to content

Commit

Permalink
displaying initial image until fetch, add styling for main img and txt
Browse files Browse the repository at this point in the history
  • Loading branch information
avivsab committed Nov 3, 2020
1 parent b6fb913 commit 2c312cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ function loadImages(genre, currInterval) {
fetch(URL).then(res => res.json().then(data => {
imgContainer.innerHTML = '';
const img = document.createElement('img');
img.src = './initial-sun.png';
img.classList.add('main-image');
imgContainer.append(img);

const figcaption = document.createElement('figcaption');
if (document.getElementsByTagName(figcaption)[0]) figcaption = '';
figcaption.innerText = genre ? `${genre} collection` : 'random collection';
figcaption.innerHTML = genre ? `<span>${genre}</span> collection` : 'random collection';
imgContainer.append(figcaption);


Expand All @@ -92,6 +93,7 @@ function loadImages(genre, currInterval) {
img.title = 'stop on image';
img.addEventListener('click', () => {
clearInterval(int);
modeMsg.style.display = 'block';
})
}, 1500);
timers.push(int)
Expand Down Expand Up @@ -121,7 +123,7 @@ function getImages(e) {
img.alt = 'main-picture';

const figcaption = document.createElement('figcaption');
figcaption.innerText = `${currentGenre} collection`;
figcaption.innerHTML = `<span>${currentGenre}</span> collection`;
imgContainer.append(figcaption);

const imgArrLength = imagesArr.length;
Expand All @@ -136,6 +138,7 @@ function getImages(e) {
img.src = imgSrc;
img.addEventListener('click', () => {
clearInterval(interval);
modeMsg.style.display = 'block';
})
}, 1500);
timers.push(interval);
Expand Down
Binary file added initial-sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ h1 {
width: 500px;
height: 300px;
border-radius: 8px;
box-shadow: 1px 3px 5px darkslategrey;
}

figcaption {
Expand All @@ -86,6 +87,10 @@ figcaption {
text-transform: uppercase;
}

figcaption span {
color: mediumvioletred;
}

.right-btn {
position: relative;
left: 60%;
Expand Down

0 comments on commit 2c312cb

Please sign in to comment.