Skip to content

Commit 275b44a

Browse files
Add active indicator to the shell nav items (#908)
* Added active indicator to the nav-item to highlight active navigation item * Update documentation to reflect active property on a menu_item * Updated shell component examples to separate active flag as its own example * Update examples/official-site/sqlpage/migrations/01_documentation.sql --------- Co-authored-by: Ophir LOJKINE <[email protected]>
1 parent 1582956 commit 275b44a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ and in its object form, to generate a dropdown menu named "Community" with links
12081208
The object form can be used directly only on database engines that have a native JSON type.
12091209
On other engines (such as SQLite), you can use the [`dynamic`](?component=dynamic#component) component to generate the same result.
12101210
1211+
12111212
You see the [page layouts demo](./examples/layouts.sql) for a live example of the different layouts.
12121213
',
12131214
json('[{
@@ -1262,6 +1263,22 @@ You see the [page layouts demo](./examples/layouts.sql) for a live example of th
12621263
"footer": "[Built with SQLPage](https://github.com/sqlpage/SQLPage/tree/main/examples/official-site)"
12631264
}]')),
12641265
('shell', '
1266+
This example shows how to set menu items as active in the navigation, so that they are highlighted in the nav bar.
1267+
1268+
In this example you can see that two menu items are created, "Home" and "About" and the "Home" tab is marked as active.
1269+
',
1270+
json('[{
1271+
"component": "shell",
1272+
"title": "SQLPage: SQL websites",
1273+
"icon": "database",
1274+
"link": "/",
1275+
"menu_item": [
1276+
{"title": "Home", "active": true},
1277+
{"title": "About"}
1278+
]
1279+
}]')),
1280+
1281+
('shell', '
12651282
### Sharing the shell between multiple pages
12661283
12671284
It is common to want to share the same shell between multiple pages.

sqlpage/templates/shell.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
{{~#if (or (eq (typeof this) 'object') (and (eq (typeof this) 'string') (starts_with this '{')))}}
9595
{{~#with (parse_json this)}}
9696
{{#if (or (or this.title this.icon) this.image)}}
97-
<li class="nav-item{{#if this.submenu}} dropdown{{/if}}">
97+
<li class="nav-item{{#if this.submenu}} dropdown{{/if}}{{#if this.active}} active{{/if}}">
9898
<a class="nav-link {{#if this.submenu}}dropdown-toggle{{/if}}" href="{{#if this.link}}{{this.link}}{{else}}#{{/if}}"
9999
{{~#if this.submenu}} data-bs-toggle="dropdown" data-bs-auto-close="outside" {{/if~}}
100100
{{#if this.target}}target="{{this.target}}"{{/if}}

0 commit comments

Comments
 (0)