modifications for Bootstrap 5

This commit is contained in:
Shaun Walker
2021-07-09 11:43:37 -04:00
parent d1c2abf7e3
commit 0ce81169a6
3 changed files with 38 additions and 52 deletions

View File

@ -3,17 +3,16 @@
@if (!string.IsNullOrEmpty(HelpText))
{
<span class="app-tooltip" data-tip="@((MarkupString)HelpText)">@((MarkupString)_openLabel)@ChildContent@((MarkupString)_closeLabel) <img src="images/help.png" /></span>
<span class="@_spanclass" data-tip="@((MarkupString)@_helptext)">
<label for="@For" class="@_labelclass">@ChildContent</label> <img src="images/help.png" />
</span>
}
else
{
@((MarkupString)_openLabel)@ChildContent@((MarkupString)_closeLabel)
<label for="@For" class="@_labelclass">@ChildContent</label>
}
@code {
private string _openLabel = string.Empty;
private string _closeLabel = "</label>";
[Parameter]
public RenderFragment ChildContent { get; set; }
@ -21,39 +20,33 @@ else
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 )
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(Class))
if (!string.IsNullOrEmpty(HelpText))
{
Class = "form-label";
_helptext = Localize(nameof(HelpText), HelpText);
_spanclass += (!string.IsNullOrEmpty(Class)) ? " " + Class : "";
}
_openLabel = "<label";
if (!string.IsNullOrEmpty(For))
else
{
_openLabel += " for=\"" + For + "\"";
_labelclass += (!string.IsNullOrEmpty(Class)) ? " " + Class : "";
}
if (!string.IsNullOrEmpty(Class))
{
_openLabel += " class=\"" + Class + "\"";
}
_openLabel += ">";
var text = Localize("Text", String.Empty);
if (text != String.Empty)
if (!string.IsNullOrEmpty(text))
{
ChildContent =@<text>@text</text>;
}
HelpText = Localize(nameof(HelpText), HelpText);
}
}