Skip to content

Commit 0a57476

Browse files
committed
RadzenTocItem inherits RadzenComponentWithChildren
1 parent 59b1440 commit 0a57476

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

Radzen.Blazor/RadzenTocItem.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<li class=@GetCssClass() @attributes=@Attributes role="presentation">
1+
@inherits RadzenComponentWithChildren
2+
<li role="presentation" @ref=@Element style=@Style @attributes=@Attributes class=@GetCssClass() id=@GetId()>
23
<div class=@WrapperClass>
34
<a href=@Selector class=@LinkClass @onclick:preventDefault @onclick=@OnClickAsync>@if (Template is null) {@Text} else {@Template}</a>
45
</div>

Radzen.Blazor/RadzenTocItem.razor.cs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Microsoft.AspNetCore.Components;
22
using Radzen.Blazor.Rendering;
33
using System;
4-
using System.Collections.Generic;
5-
using System.Collections.ObjectModel;
64
using System.Threading.Tasks;
75
namespace Radzen.Blazor;
86

@@ -11,23 +9,8 @@ namespace Radzen.Blazor;
119
/// <summary>
1210
/// Represents a table of contents item.
1311
/// </summary>
14-
public partial class RadzenTocItem : ComponentBase, IAsyncDisposable
12+
public partial class RadzenTocItem : RadzenComponentWithChildren, IAsyncDisposable
1513
{
16-
/// <summary>
17-
/// Gets or sets a dictionary of additional HTML attributes that will be applied to the component's root element.
18-
/// Any attributes not explicitly defined as parameters will be captured here and rendered on the element.
19-
/// Use this to add data-* attributes, ARIA attributes, or any custom HTML attributes.
20-
/// </summary>
21-
/// <value>The unmatched attributes dictionary.</value>
22-
[Parameter(CaptureUnmatchedValues = true)]
23-
public IReadOnlyDictionary<string, object> Attributes { get; set; } = new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());
24-
25-
/// <summary>
26-
/// Gets or sets the child content.
27-
/// </summary>
28-
[Parameter]
29-
public RenderFragment? ChildContent { get; set; }
30-
3114
/// <summary>
3215
/// Gets or sets the text displayed in the table of contents.
3316
/// </summary>
@@ -54,25 +37,13 @@ public partial class RadzenTocItem : ComponentBase, IAsyncDisposable
5437

5538
private bool selected;
5639

57-
/// <summary>
58-
/// Gets the final CSS class rendered by the component. Combines it with a <c>class</c> custom attribute.
59-
/// </summary>
60-
protected string GetCssClass()
40+
/// <inheritdoc />
41+
protected override string GetComponentCssClass()
6142
{
62-
if (Attributes != null && Attributes.TryGetValue("class", out var @class) && !string.IsNullOrEmpty(Convert.ToString(@class)))
63-
{
64-
return $"{GetComponentCssClass()} {@class}";
65-
}
66-
67-
return GetComponentCssClass();
68-
}
69-
70-
/// <summary>
71-
/// Gets the component CSS class.
72-
/// </summary>
73-
protected string GetComponentCssClass() => ClassList.Create("rz-toc-item")
43+
return ClassList.Create("rz-toc-item")
7444
.Add("rz-toc-item-selected", selected)
7545
.ToString();
46+
}
7647

7748
private string WrapperClass => ClassList.Create("rz-toc-item-wrapper")
7849
.Add(Level switch

0 commit comments

Comments
 (0)