From a1641b2551b72e1f73434ff71011feb518302cf8 Mon Sep 17 00:00:00 2001 From: James Mills Date: Thu, 15 Aug 2024 22:46:23 +0100 Subject: [PATCH] Update different style options for two two templates --- script.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 7ec6c24..a4ab159 100644 --- a/script.js +++ b/script.js @@ -35,7 +35,12 @@ advertElement.appendChild(title); const description = document.createElement('p'); - description.innerText = advert.description; + // Check if the description is an array and join with new lines if it is + if (Array.isArray(advert.description)) { + description.innerText = advert.description.join('\n'); + } else { + description.innerText = advert.description; + } advertElement.appendChild(description); const button = document.createElement('a'); @@ -53,6 +58,7 @@ const style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ` + /* Common styles for all templates */ #${containerId} .advert { border: 1px solid #ccc; padding: 16px; @@ -83,6 +89,22 @@ #${containerId} .advert-button:hover { background-color: #0056b3; } + + /* Styles for template-simple */ + #${containerId}.template-simple .advert { + margin-bottom: 16px; + display: block; + } + + /* Styles for template-card */ + #${containerId}.template-card { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); + gap: 16px; + } + #${containerId}.template-card .advert { + margin: 0; + } `; document.head.appendChild(style); }