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

Add optional announcement banner #243

Merged
merged 1 commit into from
Jul 26, 2024
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
17 changes: 17 additions & 0 deletions blocks/article/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,23 @@ article [data-docs-heading] span {
align-items: center;
}

.announcement {
padding-bottom: var(--spacing--10);
}

.announcement p {
color: white;
background-color: #aa0006;
margin: 0;
padding: 15px 10px;
}

.announcement a {
color: white;
font-weight: bold;
text-decoration: underline;
}

.article-actions {
align-items: center;
display: flex;
Expand Down
13 changes: 12 additions & 1 deletion blocks/article/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const TEMPLATE = /* html */ `
<i class="icon-share-alt"></i>
</a>
</div>
</div>
</div>
<slot name="announcement"></slot>
<div class="banner contain">
<div class="banner-inner">
<span class="banner-inner-desktop">
Expand Down Expand Up @@ -402,6 +403,16 @@ async function renderContent(block, res, rerender = false) {
block.classList.remove(`source-${isGdoc ? 'adoc' : 'gdoc'}`);
block.classList.add(`source-${isGdoc ? 'gdoc' : 'adoc'}`);

// Set announcement
const announceStr = getMetadata('announcement');
if (announceStr) {
maxakuru marked this conversation as resolved.
Show resolved Hide resolved
const announce = document.createElement('div');
announce.classList.add('announcement');
announce.innerHTML = announceStr;
announce.setAttribute('slot', 'announcement');
fragment.append(announce);
}

if (articleFound) {
const { html, info } = res;
const article = parseFragment(html);
Expand Down
Loading