Skip to content

Commit 93460b8

Browse files
authored
Dismissable banner for v3 (#1038)
* Add dismissible banner for launch
1 parent bf199b0 commit 93460b8

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export function initDismissibleBanner() {
2+
const banner = document.getElementById('dismissible-banner')
3+
const dismissButton = document.getElementById('dismissible-button')
4+
5+
if (!localStorage.getItem('bannerDismissed')) {
6+
banner?.style.setProperty('display', 'flex')
7+
}
8+
9+
dismissButton?.addEventListener('click', () => {
10+
banner?.style.setProperty('display', 'none')
11+
localStorage.setItem('bannerDismissed', 'true')
12+
})
13+
}

src/Elastic.Markdown/Assets/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { initCopyButton } from './copybutton'
2+
import { initDismissibleBanner } from './dismissible-banner'
23
import { initHighlight } from './hljs'
34
import { openDetailsWithAnchor } from './open-details-with-anchor'
45
import { initNav } from './pages-nav'
@@ -21,6 +22,7 @@ document.addEventListener('htmx:load', function () {
2122
initNav()
2223
initSmoothScroll()
2324
openDetailsWithAnchor()
25+
initDismissibleBanner()
2426
})
2527

2628
// Don't remove style tags because they are used by the elastic global nav.

src/Elastic.Markdown/Assets/styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,14 @@ body {
248248
#pages-nav details > summary::-webkit-details-marker {
249249
display: none;
250250
}
251+
252+
#dismissible-banner {
253+
@apply font-body sticky bottom-0 z-50 mt-0 hidden flex-row items-center justify-between p-4 text-sm;
254+
}
255+
256+
#dismissible-button {
257+
@apply text-blue-developer text-base font-bold;
258+
&:hover {
259+
@apply bg-grey-20 rounded-2xl;
260+
}
261+
}

src/Elastic.Markdown/Slices/_Layout.cshtml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@using Elastic.Markdown.Myst.FrontMatter
22
@inherits RazorLayoutSlice<LayoutViewModel>
33
<!DOCTYPE html>
4-
<html lang="en" class="h-screen">
4+
<html lang="en" class="h-screen" xmlns="http://www.w3.org/1999/html">
55
@await RenderPartialAsync(_Head.Create(Model))
66

77
@{
@@ -20,6 +20,7 @@
2020
@(await RenderPartialAsync(_Header.Create(Model)))
2121
<div id="main-container" class="flex flex-col items-center border-t-1 border-grey-20">
2222
@functions {
23+
2324
private async Task DefaultLayout()
2425
{
2526
<div class="container h-full grid gap-2 grid-cols-1 md:grid-cols-[calc(var(--spacing)*65)_auto] lg:grid-cols-[calc(var(--spacing)*65)_auto_calc(var(--spacing)*50)] px-6">
@@ -43,7 +44,9 @@
4344
</main>
4445
</div>
4546
}
47+
4648
}
49+
4750
@switch (layout)
4851
{
4952
case LayoutName.NotFound:
@@ -61,5 +64,18 @@
6164
}
6265
</div>
6366
@await RenderPartialAsync(_Footer.Create(Model))
67+
<aside id="dismissible-banner" class="admonition note">
68+
<div class="container flex justify-between items-center mx-auto">
69+
<p>
70+
You are viewing the new Elastic Docs experience for the latest product versions.
71+
If the page exists in older docs, you can click <strong>View previous version</strong>.
72+
</p>
73+
<button id="dismissible-button">
74+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
75+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/>
76+
</svg>
77+
</button>
78+
</div>
79+
</aside>
6480
</body>
6581
</html>

0 commit comments

Comments
 (0)