Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rberenguel committed Nov 11, 2024
1 parent 633f80d commit 00aee6b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
26 changes: 20 additions & 6 deletions lib/quoteUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 00aee6b

Please sign in to comment.