Skip to content

Commit 5663c8c

Browse files
committed
fix: remove div shadow on non existant image
1 parent e0e5c15 commit 5663c8c

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ a {
7474
margin: 0.8em 5em;
7575
}
7676

77-
.images {
77+
.image {
7878
width: 80%;
7979
border-radius: 3px;
8080
margin-top: 2em;
@@ -87,7 +87,7 @@ a {
8787
.def-text {
8888
margin: 0.8em 1em;
8989
}
90-
.images {
90+
.image {
9191
width: 95%;
9292
height: 20%;
9393
}

src/main.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const sectionLeft = document.querySelector(".section-left");
77
* in definitions
88
*/
99
function renderHTML(DOMElement, text, bulletPointText, image) {
10-
DOMElement.innerHTML = `<div class='def-text'>${text}</div><div class="bullet-text">${bulletPointText}</div>${image}`;
10+
const HTMLText = `<p class='def-text'>${text}</p>`;
11+
const HTMLBulletPoints = `<div class="bullet-text">${bulletPointText}</div>`;
12+
const HTMLImage = image ? `<img class="image"src=${image}>` : null;
13+
14+
DOMElement.innerHTML = image
15+
? `${HTMLText}${HTMLBulletPoints}${HTMLImage}`
16+
: `${HTMLText}${HTMLBulletPoints}`;
1117
}
1218

1319
function renderBulletPointsAsList(bulletPoints) {
@@ -18,7 +24,7 @@ function renderBulletPointsAsList(bulletPoints) {
1824
.join("");
1925
}
2026

21-
// when the user clicks on a link in the left panel update the DOM
27+
// When the user clicks on a link in the left panel update the DOM
2228
sectionLeft.addEventListener("click", function (e) {
2329
const sectionRight = document.querySelector(".section-right");
2430
const selectedValue = e.target.id;
@@ -28,8 +34,10 @@ sectionLeft.addEventListener("click", function (e) {
2834

2935
const { image: imageUrl, text, bulletPointItems } = selectedDefinition;
3036

31-
const HTMLImage = `<img class ="images"src=${imageUrl}>`;
32-
const HTMLBulletPoints = renderBulletPointsAsList(bulletPointItems);
33-
34-
renderHTML(sectionRight, text, HTMLBulletPoints, HTMLImage);
37+
renderHTML(
38+
sectionRight,
39+
text,
40+
renderBulletPointsAsList(bulletPointItems),
41+
imageUrl ?? null
42+
);
3543
});

0 commit comments

Comments
 (0)