Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: implement blockquote block #3

Merged
merged 4 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions blocks/blockquote/blockquote.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.blockquote {
background-color: var(--overlay-background-color);
padding: 1em;
}

.blockquote blockquote {
margin: 0;
text-indent: 0;
padding: 0 32px;
}

.blockquote blockquote::after {
border-bottom: 2px solid var(--heading-highlight-color);
content: '';
display: block;
width: 80px;
position: relative;
top: 0.25em;
}

.blockquote > p {
margin: 10px 0 0 10px;
}

.blockquote blockquote * p, .blockquote blockquote * div {
font-size: 36px;
border: none;
margin: 0;
line-height: 1.5;
}
13 changes: 13 additions & 0 deletions blocks/blockquote/blockquote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function decorate(block) {
const quoteDiv = block.querySelector('div:last-of-type');
const blockquote = document.createElement('blockquote');
blockquote.innerHTML = `<strong>${quoteDiv.innerHTML}</strong>`;
quoteDiv.replaceWith(blockquote);

const authorDiv = block.querySelector('div:nth-child(2)');
if (authorDiv) {
const author = document.createElement('p');
author.innerHTML = `<b><i>${authorDiv.innerHTML}</i></b>`;
authorDiv.replaceWith(author);
}
}
17 changes: 5 additions & 12 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
--highlight-background-color: #ccc;
--text-color: #202020;
--text-color-light: #ebebeb;
--heading-highlight-color: #ffea00;
--overlay-text-color: var(--text-color);
--highlight-text-color: var(--text-color);

Expand Down Expand Up @@ -110,7 +111,7 @@ body.article h2::after {
width: 84px;
padding-top: 8px;
content: "";
border-bottom: 2px solid #ffea00;
border-bottom: 2px solid var(--heading-highlight-color);
}

h2 { font-size: var(--heading-font-size-xl) }
Expand Down Expand Up @@ -234,22 +235,14 @@ main pre {
}

main blockquote {
font-style: italic;
color: var(--blockquote-color);
background-color: var(--blockquote-background-color);
font-family: var(--heading-font-family);
margin: 3rem;
text-indent: -1rem;
hanging-punctuation: first;
}
Comment on lines 237 to 244
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally move this out of styles.css and into blockquote.css.


main blockquote p::before {
content: "“";
line-height: 0;
}

main blockquote p::after {
content: "”";
line-height: 0;
}

hr {
margin-top: 1.5em;
margin-bottom: 1.5em;
Expand Down