oqtane.framework/Oqtane.Client/Modules/Controls/Label.razor
2022-05-31 10:40:42 +03:00

57 lines
1.5 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;
private string _labelclass;
private string _helptext = string.Empty;
protected override void OnParametersSet()
{
base.OnParametersSet();
if (!string.IsNullOrEmpty(HelpText))
{
_helptext = Localize(nameof(HelpText), HelpText);
_labelclass = "form-label";
var spanclass = (!string.IsNullOrEmpty(Class)) ? " " + Class : "";
_spanclass = "app-tooltip" + spanclass;
}
else
{
var labelclass = (!string.IsNullOrEmpty(Class)) ? " " + Class : "";
_labelclass = "form-label" + labelclass;
}
var text = Localize("Text", String.Empty);
if (!string.IsNullOrEmpty(text))
{
ChildContent =@<text>@text</text>;
}
}
}