Added Base component with ID used for state management. All other components must inherit from it To get Id property
parent
a9282b9b0a
commit
3331105811
@ -0,0 +1,5 @@
|
|||||||
|
@inherits ComponentBase
|
||||||
|
|
||||||
|
@*Base class for all components
|
||||||
|
It contains unique ID for the component used in
|
||||||
|
saving state of the component*@
|
@ -0,0 +1,20 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace Connected.Components
|
||||||
|
{
|
||||||
|
public partial class Base : ComponentBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Unique ID for the component used in state management
|
||||||
|
/// Every component should inherit from Base class
|
||||||
|
/// </summary>
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Id))
|
||||||
|
Id = Guid.NewGuid().ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
<div class="@ClassList" style="@StyleList">
|
@inherits Base
|
||||||
|
|
||||||
|
<div class="@ClassList" style="@StyleList">
|
||||||
@ChildContent
|
@ChildContent
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
<svg viewBox="0 0 24 24" class="@GlyphClassList" @onclick="@OnClick">
|
@inherits Base
|
||||||
|
|
||||||
|
<svg viewBox="0 0 24 24" class="@GlyphClassList" @onclick="@OnClick">
|
||||||
@((MarkupString)SVG)
|
@((MarkupString)SVG)
|
||||||
</svg>
|
</svg>
|
||||||
|
Loading…
Reference in new issue