microsite: add Banner component + k8s launch banner
This commit is contained in:
@@ -106,9 +106,29 @@ const Breakpoint = ({ narrow, wide }) => (
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
const Banner = simpleComponent('div', 'Banner', ['hidden']);
|
||||
Banner.Container = simpleComponent('div', 'Banner__Container');
|
||||
|
||||
const BannerDismissButton = simpleComponent(
|
||||
props => (
|
||||
<svg {...props} data-banner-dismiss viewBox="0 0 24 24">
|
||||
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
|
||||
</svg>
|
||||
),
|
||||
'Banner__DismissButton',
|
||||
);
|
||||
|
||||
Banner.Dismissable = ({ storageKey, children }) => (
|
||||
<Banner hidden data-banner={storageKey}>
|
||||
{children}
|
||||
<BannerDismissButton />
|
||||
</Banner>
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
Block,
|
||||
ActionBlock,
|
||||
Breakpoint,
|
||||
BulletLine,
|
||||
Banner,
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ const Block = Components.Block;
|
||||
const ActionBlock = Components.ActionBlock;
|
||||
const Breakpoint = Components.Breakpoint;
|
||||
const BulletLine = Components.BulletLine;
|
||||
const Banner = Components.Banner;
|
||||
|
||||
class Index extends React.Component {
|
||||
render() {
|
||||
@@ -53,6 +54,15 @@ class Index extends React.Component {
|
||||
</Block.Container>
|
||||
</Block>
|
||||
|
||||
<Banner.Container>
|
||||
<Banner.Dismissable storageKey="k8s-launch">
|
||||
🎉 New feature: Kubernetes for service owners.{' '}
|
||||
<a href="https://backstage.io/blog/2021/01/12/new-backstage-feature-kubernetes-for-service-owners">
|
||||
Learn more.
|
||||
</a>
|
||||
</Banner.Dismissable>
|
||||
</Banner.Container>
|
||||
|
||||
<Block small className="stripe-top bg-black">
|
||||
<Block.Container wrapped>
|
||||
<Block.TextBox>
|
||||
|
||||
@@ -82,6 +82,7 @@ const siteConfig = {
|
||||
'https://buttons.github.io/buttons.js',
|
||||
'https://unpkg.com/medium-zoom@1.0.6/dist/medium-zoom.min.js',
|
||||
'/js/medium-zoom.js',
|
||||
'/js/dismissable-banner.js',
|
||||
],
|
||||
|
||||
// On page navigation for the current documentation page.
|
||||
|
||||
@@ -1035,6 +1035,55 @@ code {
|
||||
}
|
||||
}
|
||||
|
||||
.Banner {
|
||||
position: relative;
|
||||
padding: 14px;
|
||||
margin: 14px 20px;
|
||||
border-radius: 4px;
|
||||
background-color: $primaryColor;
|
||||
font-family: Helvetica Neue, sans-serif;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.Banner--hidden {
|
||||
opacity: 0;
|
||||
transition: opacity 200ms ease-in-out;
|
||||
}
|
||||
|
||||
.Banner a {
|
||||
color: #000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.Banner__Container {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
z-index: 100;
|
||||
|
||||
max-width: 1430px;
|
||||
height: 0;
|
||||
margin: -14px auto 14px auto;
|
||||
}
|
||||
|
||||
.Banner__DismissButton {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
right: 8px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
|
||||
border-radius: 50%;
|
||||
padding: 6px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.Banner__DismissButton:hover {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.logos-mobile-background {
|
||||
position: absolute;
|
||||
width: 200vw;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const banners = document.querySelectorAll('[data-banner]');
|
||||
banners.forEach(banner => {
|
||||
const storageKey = `hideBanner/${banner.getAttribute('data-banner')}`;
|
||||
|
||||
if (!localStorage.getItem(storageKey)) {
|
||||
banner.classList.remove('Banner--hidden');
|
||||
}
|
||||
|
||||
const dismissButton = banner.querySelector('[data-banner-dismiss]');
|
||||
if (dismissButton) {
|
||||
dismissButton.addEventListener('click', () => {
|
||||
banner.classList.add('Banner--hidden');
|
||||
localStorage.setItem(storageKey, 'true');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user