|
1 | 1 | @using Elastic.Markdown.Helpers
|
2 | 2 | @inherits RazorSlice<NavigationViewModel>
|
3 |
| -<div class="pt-6 pb-20 font-body"> |
4 |
| - |
| 3 | +<div class="pb-20 font-body"> |
5 | 4 | @{
|
6 | 5 | var current = Model.TopLevelItems.FirstOrDefault(i => i.Id == Model.Tree.Id);
|
7 | 6 | }
|
8 |
| - |
9 |
| - @if (Model.IsPrimaryNavEnabled) |
| 7 | + @if (Model.IsPrimaryNavEnabled && current is { Group.Index: not null }) |
10 | 8 | {
|
11 |
| - <details class="block group border-b-1 border-grey-20 pb-8 font-sans"> |
12 |
| - <summary class="inline-grid md:grid grid-cols-[1fr_auto] cursor-pointer font-semibold gap-2 hover:text-black"> |
13 |
| - <span> |
14 |
| - @current?.Group.Index?.NavigationTitle |
15 |
| - </span> |
16 |
| - <div class="flex items-center justify-center size-6"> |
17 |
| - <svg |
18 |
| - xmlns="http://www.w3.org/2000/svg" |
19 |
| - fill="none" |
20 |
| - viewBox="0 0 24 24" |
21 |
| - stroke-width="1.5" |
22 |
| - stroke="currentColor" |
23 |
| - class="w-4 group-open:rotate-180"> |
24 |
| - <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/> |
25 |
| - </svg> |
26 |
| - </div> |
27 |
| - </summary> |
28 |
| - <ul> |
29 |
| - @foreach (var item in Model.TopLevelItems) |
30 |
| - { |
31 |
| - if (item.Group.Index == null) continue; |
32 |
| - <li class="block mt-2"> |
33 |
| - <a |
34 |
| - class="hover:underline hover:text-black active:text-blue-elastic-100 font-semibold text-sm @(item.Group.Id == Model.Tree.Id ? "text-blue-elastic" : "")" |
35 |
| - href="@item.Group.Index.Url" |
36 |
| - hx-get="@item.Group.Index.Url" |
37 |
| - hx-select-oob="#pages-nav,#content-container,#toc-nav" |
38 |
| - hx-push-url="true" |
39 |
| - preload>@item.Group.Index.NavigationTitle</a> |
40 |
| - </li> |
41 |
| - } |
42 |
| - </ul> |
43 |
| - </details> |
| 9 | + <div class="sticky top-0 py-6 bg-white z-10 border-b-1 border-grey-20 pr-4"> |
| 10 | + <details class="block group border-1 border-grey-20 rounded-sm font-sans "> |
| 11 | + <summary class="grid grid-cols-[1fr_auto] cursor-pointer font-semibold gap-1 hover:text-black pl-4 pr-2 py-2 group-open:border-b-1 border-grey-20"> |
| 12 | + <span> |
| 13 | + <a |
| 14 | + class="hover:underline text-blue-elastic hover:text-blue-elastic-100" |
| 15 | + href="@current.Group.Index?.Url" |
| 16 | + @Htmx.GetHxAttributes(current.Group.Index?.Url!, true) |
| 17 | + > |
| 18 | + @current.Group.Index?.NavigationTitle |
| 19 | + </a> |
| 20 | + </span> |
| 21 | + <div class="flex items-center justify-center size-6 hover:bg-grey-20 rounded-sm"> |
| 22 | + <svg |
| 23 | + xmlns="http://www.w3.org/2000/svg" |
| 24 | + fill="none" |
| 25 | + viewBox="0 0 24 24" |
| 26 | + stroke-width="1.5" |
| 27 | + stroke="currentColor" |
| 28 | + class="w-4 group-open:rotate-180"> |
| 29 | + <path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/> |
| 30 | + </svg> |
| 31 | + </div> |
| 32 | + </summary> |
| 33 | + <ul class="py-2"> |
| 34 | + @foreach (var item in Model.TopLevelItems) |
| 35 | + { |
| 36 | + if (item.Group.Index == null) continue; |
| 37 | + if (item.Id == current?.Id) continue; |
| 38 | + <li class="block"> |
| 39 | + <a |
| 40 | + class="block py-2 px-4 hover:underline hover:text-black hover:bg-grey-10 active:bg-blue-elastic-70 active:text-white font-semibold @(item.Group.Id == Model.Tree.Id ? "text-blue-elastic" : "")" |
| 41 | + href="@item.Group.Index.Url" |
| 42 | + hx-get="@item.Group.Index.Url" |
| 43 | + hx-select-oob="#pages-nav,#content-container,#toc-nav" |
| 44 | + hx-push-url="true" |
| 45 | + preload>@item.Group.Index.NavigationTitle</a> |
| 46 | + </li> |
| 47 | + } |
| 48 | + </ul> |
| 49 | + </details> |
| 50 | + </div> |
44 | 51 | }
|
45 | 52 | else
|
46 | 53 | {
|
47 | 54 | <a
|
48 | 55 | href="@Model.TitleUrl"
|
49 | 56 | @Htmx.GetHxAttributes(Model.TitleUrl, current is null || Model.Tree.Id == current?.Id)
|
50 |
| - class="font-semibold text-ink hover:text-black"> |
| 57 | + class="inline-block mx-4 mt-6 font-semibold text-ink hover:text-black"> |
51 | 58 | @Model.Title
|
52 | 59 | </a>
|
53 | 60 | }
|
54 |
| - |
55 |
| - |
56 |
| - <ul class="block"> |
| 61 | + |
| 62 | + <ul class="block pl-4"> |
57 | 63 | @await RenderPartialAsync(_TocTreeNav.Create(new NavigationTreeItem
|
58 | 64 | {
|
59 | 65 | IsPrimaryNavEnabled = Model.IsPrimaryNavEnabled,
|
|
0 commit comments