-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathSectionNavigationNode.cs
More file actions
77 lines (62 loc) · 2.42 KB
/
SectionNavigationNode.cs
File metadata and controls
77 lines (62 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using Elastic.Documentation.Extensions;
namespace Elastic.Documentation.Navigation.V2;
/// <summary>
/// A top-level section that owns an independent sidebar nav tree.
/// Unlike <see cref="LabelNavigationNode"/>, a section has a real URL (the tab link)
/// and an <see cref="Isolated"/> flag that controls whether it appears in the top bar.
/// </summary>
public class SectionNavigationNode : INodeNavigationItem<INavigationModel, INavigationItem>
{
private readonly SectionIndexLeaf _index;
public SectionNavigationNode(
string label,
string url,
bool isolated,
IReadOnlyCollection<INavigationItem> children,
INodeNavigationItem<INavigationModel, INavigationItem>? parent
)
{
Id = ShortId.Create("section", label);
NavigationTitle = label;
Url = url;
Isolated = isolated;
NavigationItems = children;
Parent = parent;
NavigationRoot = parent?.NavigationRoot!;
_index = new SectionIndexLeaf(this);
}
/// <summary>Whether this section is excluded from the top bar and renders with a back arrow.</summary>
public bool Isolated { get; }
/// <inheritdoc />
public string Id { get; }
/// <inheritdoc />
public string Url { get; }
/// <inheritdoc />
public string NavigationTitle { get; }
/// <inheritdoc />
public IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot { get; }
/// <inheritdoc />
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
/// <inheritdoc />
public bool Hidden => false;
/// <inheritdoc />
public int NavigationIndex { get; set; }
/// <inheritdoc />
public ILeafNavigationItem<INavigationModel> Index => _index;
/// <inheritdoc />
public IReadOnlyCollection<INavigationItem> NavigationItems { get; }
private sealed class SectionIndexLeaf(SectionNavigationNode owner)
: ILeafNavigationItem<INavigationModel>, INavigationModel
{
public INavigationModel Model => this;
public string Url => owner.Url;
public string NavigationTitle => owner.NavigationTitle;
public IRootNavigationItem<INavigationModel, INavigationItem> NavigationRoot => owner.NavigationRoot;
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; } = owner;
public bool Hidden => true;
public int NavigationIndex { get; set; }
}
}