Skip to content

Commit e04e990

Browse files
authored
Add a banner to a page (#217)
``` :page-banner: note :page-banner-text: Lorem ipsum dolor sit est. :page-banner-link: https://neo4j.com/docs :page-banner-link-text: Link text ``` `note` is the default, `warning` can also be used.
1 parent 6c05cb9 commit e04e990

File tree

10 files changed

+100
-1
lines changed

10 files changed

+100
-1
lines changed

preview-src/banner-note.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
= Note banner
2+
:page-theme: docs
3+
:page-banner: note
4+
:page-banner-text: Lorem ipsum dolor sit est.
5+
:page-banner-link: https://neo4j.com/docs
6+
:page-banner-link-text: Link text
7+
8+
9+
[abstract]
10+
--
11+
Add page banner attributes to a page to display a message between the header and the toolbar.
12+
--
13+
14+
[source]
15+
----
16+
:page-banner: note
17+
:page-banner-text: Lorem ipsum dolor sit est.
18+
:page-banner-link: https://neo4j.com/docs
19+
:page-banner-link-text: Link text
20+
----

preview-src/banner-warning.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
= Warning banner
2+
:page-theme: docs
3+
:page-banner: warning
4+
:page-banner-text: Lorem ipsum dolor sit est.
5+
:page-banner-link: https://neo4j.com/docs
6+
:page-banner-link-text: Link text
7+
8+
9+
[abstract]
10+
--
11+
Add page banner attributes to a page to display a message between the header and the toolbar
12+
--
13+
14+
[source]
15+
----
16+
:page-banner: warning
17+
:page-banner-text: Lorem ipsum dolor sit est.
18+
:page-banner-link: https://neo4j.com/docs
19+
:page-banner-link-text: Link text
20+
----

preview-src/docs-roles.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
= Docs `code test` flags
22
:page-role: not-on-aura
33
:page-theme: docs
4+
:page-banner: warning
5+
:page-banner-text: Lorem ipsum dolor sit est.
6+
:page-banner-link: https://neo4j.com/docs
7+
:page-banner-link-text: Link text
48
// :page-labels: fabric enterprise-edition alpha test
59

610
[abstract]

preview-src/ui-model.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ page:
139139
- content: Admonitions
140140
url: admonitions.html
141141
urlType: internal
142+
- content: Page Banners
143+
items:
144+
- content: note
145+
url: banner-note.html
146+
urlType: internal
147+
- content: warning
148+
url: banner-warning.html
149+
urlType: internal
142150
- content: Labels
143151
url: labels.html
144152
urlType: internal

src/css/header.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ body {
66
padding-top: var(--navbar-height);
77
}
88

9+
.header-banner {
10+
background: var(--note-background-color);
11+
color: var(--note-color);
12+
box-shadow: 0 0 1px var(--note-border-color);
13+
font-size: calc(16 / var(--rem-base) * 1rem);
14+
height: var(--banner-height);
15+
position: fixed;
16+
top: var(--navbar-height);
17+
width: 100%;
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
21+
z-index: var(--z-index-banner);
22+
}
23+
24+
.header-banner.warning-banner {
25+
background: var(--warning-background-color);
26+
color: var(--warning-color);
27+
box-shadow: 0 0 1px var(--warning-border-color);
28+
}
29+
30+
.header-banner span {
31+
padding: 0.25rem;
32+
}
33+
934
.navbar {
1035
background: var(--navbar-background);
1136
color: var(--navbar-font-color);

src/css/nav.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
position: sticky;
5151
height: var(--nav-height--desktop);
5252
}
53+
54+
body.has-banner .nav {
55+
top: calc(var(--navbar-height) + var(--banner-height));
56+
}
5357
}
5458

5559
.nav .panels {

src/css/toolbar.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
z-index: var(--z-index-toolbar);
1313
}
1414

15+
body.has-banner .toolbar {
16+
top: calc(var(--navbar-height) + var(--banner-height));
17+
}
18+
1519
.toolbar-wrapper {
1620
display: flex;
1721
width: 100%;

src/css/vars.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
--tip-color: rgba(var(--theme-light-palette-primary-bg-strong));
251251
--tip-background-color: rgba(var(--theme-light-palette-primary-bg-weak));
252252
--warning-color: rgba(var(--theme-light-palette-danger-bg-strong));
253+
--warning-border-color: rgba(var(--theme-light-palette-danger-bg-strong));
253254
--warning-background-color: rgba(var(--theme-light-palette-danger-bg-weak));
254255
--mark-background: rgba(var(--theme-light-palette-primary-bg-weak));
255256

@@ -370,6 +371,7 @@
370371
/* dimensions and positioning */
371372
--navbar-height: calc(68 / var(--rem-base) * 1rem);
372373
--toolbar-height: calc(45 / var(--rem-base) * 1rem);
374+
--banner-height: calc(45 / var(--rem-base) * 1rem);
373375
--drawer-height: var(--toolbar-height);
374376
--body-top: var(--navbar-height);
375377
--body-min-height: calc(100vh - var(--body-top));
@@ -398,6 +400,7 @@
398400
/* stacking */
399401
--z-index-nav: 1;
400402
--z-index-toolbar: 20;
403+
--z-index-banner: 30;
401404
--z-index-code: 10;
402405
--z-index-page-version-menu: 3;
403406
--z-index-navbar: 5000;

src/layouts/default.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
{{> head defaultPageTitle='Untitled'}}
55
</head>
6-
<body class="article{{#with (or page.attributes.role page.role)}} {{{this}}}{{/with}}{{#with asciidoc.attributes.role}} {{{this}}}{{/with}}{{#with (or page.attributes.theme "developer")}} {{{this}}}{{/with}}{{#with (or page.attributes.styles page.styles)}} {{{this}}}{{/with}}{{#if (or page.attributes.show-labels page.show-labels)}} show-labels{{/if}}">
6+
<body class="article{{#if page.attributes.banner}} has-banner{{/if}}{{#with (or page.attributes.role page.role)}} {{{this}}}{{/with}}{{#with asciidoc.attributes.role}} {{{this}}}{{/with}}{{#with (or page.attributes.theme "developer")}} {{{this}}}{{/with}}{{#with (or page.attributes.styles page.styles)}} {{{this}}}{{/with}}{{#if (or page.attributes.show-labels page.show-labels)}} show-labels{{/if}}">
77
{{> header}}
88
{{> body}}
99
{{> footer}}

src/partials/header-content.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,15 @@
103103
{{/if}}
104104
</div>
105105
</nav>
106+
{{#if (and page.attributes.banner page.attributes.banner-text)}}
107+
<div class="header-banner{{#with (or page.attributes.banner "info")}} {{{this}}}-banner{{/with}}">
108+
<span>{{#with page.attributes.banner-text}}{{{this}}}{{/with}}</span>
109+
{{#if page.attributes.banner-link}}
110+
<span>
111+
<a href="{{{page.attributes.banner-link}}}">{{#with (or page.attributes.banner-link-text page.attributes.banner-link)}}{{{this}}}{{/with}}</a>
112+
</span>
113+
{{/if}}
114+
</div>
115+
{{/if}}
116+
106117
</header>

0 commit comments

Comments
 (0)