update artist creation script to handle multiline bios
This commit is contained in:
@ -1,43 +1,55 @@
|
||||
const makeArtistImg = function(artistImg) {
|
||||
let imgDiv = document.createElement("div");
|
||||
imgDiv.classList.add("fit-contain");
|
||||
|
||||
let img = document.createElement("img");
|
||||
img.src = artistImg.src;
|
||||
img.alt = artistImg.alt;
|
||||
|
||||
imgDiv.append(img);
|
||||
return imgDiv;
|
||||
}
|
||||
|
||||
const makeArtistDesc = function(bio, contact) {
|
||||
let descDiv = document.createElement("div");
|
||||
descDiv.classList.add("description");
|
||||
|
||||
for (const bioLine of bio) {
|
||||
let p = document.createElement("p");
|
||||
p.innerHTML = bioLine;
|
||||
descDiv.append(p);
|
||||
}
|
||||
|
||||
let contacts = document.createElement("p");
|
||||
for (let i = 0; i < contact.length; i++) {
|
||||
let a = document.createElement("a");
|
||||
a.href = contact[i].href;
|
||||
a.innerHTML = contact[i].title;
|
||||
a.target = "_blank";
|
||||
contacts.append(a);
|
||||
|
||||
if (i !== contact.length - 1) contacts.append(" ● ");
|
||||
}
|
||||
descDiv.append(contacts);
|
||||
|
||||
return descDiv;
|
||||
}
|
||||
|
||||
const makeArtist = function(artist) {
|
||||
let container = document.createElement("div");
|
||||
container.classList.add("artist");
|
||||
container.id = artist.id;
|
||||
|
||||
/* artist img */
|
||||
let imgDiv = document.createElement("div");
|
||||
imgDiv.classList.add("fit-contain");
|
||||
let img = document.createElement("img");
|
||||
img.src = artist.img.src;
|
||||
img.alt = artist.img.alt;
|
||||
imgDiv.append(img);
|
||||
container.append(imgDiv);
|
||||
container.append(makeArtistImg(artist.img));
|
||||
|
||||
/* artist name */
|
||||
let h3 = document.createElement("h3");
|
||||
h3.innerHTML = artist.name;
|
||||
container.append(h3);
|
||||
|
||||
/* artist bio */
|
||||
let descDiv = document.createElement("div");
|
||||
descDiv.classList.add("description");
|
||||
let bio = document.createElement("p");
|
||||
bio.innerHTML = artist.bio;
|
||||
descDiv.append(bio);
|
||||
|
||||
/* artist contact info */
|
||||
let contacts = document.createElement("p");
|
||||
for (let i = 0; i < artist.contact.length; i++) {
|
||||
let a = document.createElement("a");
|
||||
a.href = artist.contact[i].href;
|
||||
a.innerHTML = artist.contact[i].title;
|
||||
a.target = "_blank";
|
||||
contacts.append(a);
|
||||
|
||||
if (i !== artist.contact.length - 1) contacts.append(" ● ");
|
||||
}
|
||||
descDiv.append(contacts);
|
||||
|
||||
container.append(descDiv);
|
||||
/* artist description */
|
||||
container.append(makeArtistDesc(artist.bio, artist.contact));
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user