Skip to content

Commit

Permalink
Merge pull request #486 from adobe/deprecation-banner
Browse files Browse the repository at this point in the history
feat: deprecation banner
  • Loading branch information
rofe authored Mar 19, 2024
2 parents 2ce63ed + f7af249 commit 7d1288a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions blocks/deprecation/deprecation.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.deprecation {
padding: 10px 16px;
margin-bottom: 16px;
background-color: #d31510;
color: #fff;
border-radius: var(--image-border-radius-l);
font-size: var(--type-body-s-size);
line-height: var(--type-body-s-lh);
}

.deprecation .header {
font-weight: 700;
font-size: var(--type-body-m-size);
text-transform: uppercase;
}
6 changes: 6 additions & 0 deletions blocks/deprecation/deprecation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function decorate(block) {
const header = document.createElement('div');
header.className = 'header';
header.textContent = 'Deprecation notice';
block.prepend(header);
}
14 changes: 14 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,20 @@ async function loadEager(doc) {
}
}

// deprecation banner
const deprecation = getMetadata('deprecation');
if (deprecation) {
const deprecationBanner = buildBlock('deprecation', deprecation);
const h1 = document.querySelector('h1');
if (h1) {
// insert above title
h1.parentElement.insertBefore(deprecationBanner, h1);
} else {
// insert at top of page
document.querySelector('main > div').append(deprecationBanner);
}
}

const main = doc.querySelector('main');
if (main) {
decorateMain(main);
Expand Down

0 comments on commit 7d1288a

Please sign in to comment.