Label component for field level help
This commit is contained in:
42
Oqtane.Client/Modules/Controls/Label.razor
Normal file
42
Oqtane.Client/Modules/Controls/Label.razor
Normal file
@ -0,0 +1,42 @@
|
||||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (!string.IsNullOrEmpty(HelpText))
|
||||
{
|
||||
<span class="app-tooltip" data-tip="@((MarkupString)HelpText)">@((MarkupString)_openLabel)@ChildContent@((MarkupString)_closeLabel) <img src="images/help.png" /></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@((MarkupString)_openLabel)@ChildContent@((MarkupString)_closeLabel)
|
||||
}
|
||||
|
||||
@code {
|
||||
string _openLabel = "";
|
||||
string _closeLabel = "</label>";
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } // required - the title of the label
|
||||
|
||||
[Parameter]
|
||||
public string For { get; set; } // optional - the id of the associated input control for accessibility
|
||||
|
||||
[Parameter]
|
||||
public string Class { get; set; } // optional - the class for the label ( ie. control-label )
|
||||
|
||||
[Parameter]
|
||||
public string HelpText { get; set; } // optional - tooltip for this label
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
_openLabel = "<label";
|
||||
if (!string.IsNullOrEmpty(For))
|
||||
{
|
||||
_openLabel += " for=\"" + For + "\"";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Class))
|
||||
{
|
||||
_openLabel += " class=\"" + Class + "\"";
|
||||
}
|
||||
_openLabel += ">";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user