From 00aee6b50ffd6c3e7ff64490a89cfa056d12fcc2 Mon Sep 17 00:00:00 2001 From: Ruben Berenguel Montoro Date: Mon, 11 Nov 2024 20:48:25 +0100 Subject: [PATCH] Tweaks --- lib/quoteUtils.js | 26 ++++++++++++++++++++------ style.css | 13 +++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/quoteUtils.js b/lib/quoteUtils.js index ad50fe0..4a1940a 100644 --- a/lib/quoteUtils.js +++ b/lib/quoteUtils.js @@ -53,10 +53,10 @@ function quotesFromMarkdown(paths, cb, basepath) { if (basepath) { obj = textToObject(block); } - + console.log(obj) if (!obj._valid) { quotes.push({ - text: `Error loading quote ${i} from file ${path}`, + lines: [`Error loading quote ${i} from file ${path}`], error: true, }); continue; @@ -106,22 +106,36 @@ function addQuotesToDiv(_quotes, targetDivId) { return; } const div = d(); - const color = - colors[Math.floor((Math.random() * colors.length) % colors.length)]; - div.style.color = `var(${color})`; + let color = + `var(${colors[Math.floor((Math.random() * colors.length) % colors.length)]})`; + if(quote.error){ + color = "red" + } + div.style.color = color; div.classList.add("quote"); const q = d(); q.classList.add("text"); const a = d(); a.classList.add("author"); + const n = d(); + n.classList.add("note"); for (const line of quote.lines) { const p = document.createElement("p"); p.innerHTML = line; // To avoid adding a full formatting parser q.appendChild(p); } - a.textContent = quote.extra; + let author = quote.extra + const authRegex = /(.*?)\((.*?)\)/; + const match = author.match(authRegex) div.appendChild(q); div.appendChild(a); + if(match){ + author = match[1] + n.textContent = match[2] + div.appendChild(n) + } + a.textContent = author; + wrapperNode.appendChild(div); targetDiv.appendChild(wrapperNode); rendered = true; diff --git a/style.css b/style.css index c57236a..38bb907 100644 --- a/style.css +++ b/style.css @@ -318,8 +318,17 @@ hr.dim { } .quote .author { + display: inline-block; font-size: 90%; - filter: grayscale(0.7) opacity(0.8); + filter: grayscale(0.6); text-align: center; - padding-left: 8em; + padding-left: 12em; } + +.quote .note { + display: inline-block; + font-style:oblique; + font-size: 70%; + filter: grayscale(0.6) ; + padding-left: 1em; +} \ No newline at end of file