oqtane.framework/Oqtane.Client/Modules/Controls/Label.razor
2021-07-09 11:43:37 -04:00

53 lines
1.4 KiB
Plaintext

@namespace Oqtane.Modules.Controls
@inherits LocalizableComponent
@if (!string.IsNullOrEmpty(HelpText))
{
<span class="@_spanclass" data-tip="@((MarkupString)@_helptext)">
<label for="@For" class="@_labelclass">@ChildContent</label> <img src="images/help.png" />
</span>
}
else
{
<label for="@For" class="@_labelclass">@ChildContent</label>
}
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public string For { get; set; } // optional - the id of the associated input control for accessibility
[Parameter]
public string Class { get; set; } // optional - CSS classes
[Parameter]
public string HelpText { get; set; } // optional - tooltip for this label
private string _spanclass = "app-tooltip";
private string _labelclass = "form-label";
private string _helptext = string.Empty;
protected override void OnParametersSet()
{
base.OnParametersSet();
if (!string.IsNullOrEmpty(HelpText))
{
_helptext = Localize(nameof(HelpText), HelpText);
_spanclass += (!string.IsNullOrEmpty(Class)) ? " " + Class : "";
}
else
{
_labelclass += (!string.IsNullOrEmpty(Class)) ? " " + Class : "";
}
var text = Localize("Text", String.Empty);
if (!string.IsNullOrEmpty(text))
{
ChildContent =@<text>@text</text>;
}
}
}