|
2 | 2 |
|
3 | 3 | @inject NavigationManager NavigationManager
|
4 | 4 |
|
5 |
| -<h2 id="@_id" class="ad-section-title"> |
6 |
| - @Title |
| 5 | +<CascadingValue TValue="DocsPageSection" Value="@this" IsFixed="@true"> |
| 6 | + <LumexElement Tag="@(Parent is null ? "h2" : "h3")" |
| 7 | + Id="@_id" |
| 8 | + Class="flex gap-2 text-"> |
| 9 | + @Title |
7 | 10 |
|
8 |
| - <LumexLink Route="@SectionLink"> |
9 |
| - <LumexIcon Icon="@Icons.Rounded.Tag" /> |
10 |
| - </LumexLink> |
11 |
| -</h2> |
| 11 | + <LumexLink Route="@Link"> |
| 12 | + <LumexIcon Icon="@Icons.Rounded.Tag" /> |
| 13 | + </LumexLink> |
| 14 | + </LumexElement> |
12 | 15 |
|
13 |
| -@ChildContent |
| 16 | + @ChildContent |
| 17 | +</CascadingValue> |
14 | 18 |
|
15 | 19 | @code {
|
16 | 20 | [CascadingParameter] private DocsPage Page { get; set; } = default!;
|
| 21 | + [CascadingParameter] private DocsPageSection Parent { get; set; } = default!; |
17 | 22 |
|
18 | 23 | [Parameter] public RenderFragment? ChildContent { get; set; }
|
19 | 24 | [Parameter] public string? Title { get; set; }
|
20 | 25 |
|
21 |
| - private string SectionLink => $"{_pageRelativePath}#{_id}"; |
| 26 | + internal int Level => (Parent?.Level ?? -1) + 1; |
| 27 | + private string Link => $"{_pageRelativePath}#{_id}"; |
| 28 | + |
| 29 | + private string TitleCssClass => |
| 30 | + new CssBuilder( "flex gap-2" ) |
| 31 | + .Build(); |
22 | 32 |
|
23 | 33 | private string? _id;
|
24 | 34 | private string? _pageRelativePath;
|
|
34 | 44 | if( !string.IsNullOrEmpty( Title ) )
|
35 | 45 | {
|
36 | 46 | _id = BuildIdAttributeValue( Title );
|
37 |
| - Page.AddSection( new PageSectionInfo( Title, SectionLink ) ); |
| 47 | + Page.AddSection( new PageSectionInfo( Title, Link, Level ) ); |
38 | 48 | }
|
39 | 49 | }
|
40 | 50 |
|
41 | 51 | private string BuildIdAttributeValue( string title )
|
42 | 52 | {
|
43 |
| - var words = title.Split( ' ' ); |
44 |
| - return string.Join( "-", words ).ToLowerInvariant(); |
| 53 | + var titleParts = title.Split( ' ' ); |
| 54 | + return string.Join( "-", titleParts ).ToLowerInvariant(); |
45 | 55 | }
|
46 | 56 | }
|
0 commit comments