public override void Process(TagHelperContext context, TagHelperOutput output) { var style = Looks != ButtonStyle.@default ? "--" + Looks.ToString().ToLower() : ""; var size = Size != ButtonSize.@default ? "--" + Size.ToString().ToLower() : ""; var color = Color != Color.@default ? "--" + Color.ToString().ToLower() : ""; output.Attributes.Merge("class", $"{ElementName} {style} {size} {color}"); if (output.Attributes.TryGetAttribute("is", out var attr)) { output.Attributes.Remove(attr); } }
public override void Process(TagHelperContext context, TagHelperOutput output) { var style = Looks != ButtonStyle.@default ? "--" + Looks.ToString().ToLower() : ""; var size = Size != ButtonSize.@default ? "--" + Size.ToString().ToLower() : ""; var color = Color != Color.@default ? "--" + Color.ToString().ToLower() : ""; var @class = output.Attributes["class"]?.Value ?? string.Empty; output.PreElement.AppendHtml($"<div class=\"aiplugs-selectable-button {@class} {style} {size} {color}\" data-controller=\"aiplugs-selectable-button\">"); output.PreElement.AppendHtml("<select class=\"aiplugs-selectable-button__select\" data-target=\"aiplugs-selectable-button.select\" data-action=\"aiplugs-selectable-button#change\" "); if (!string.IsNullOrEmpty(SelectName)) { output.PreElement.AppendHtml("name=\""); output.PreElement.Append(SelectName); output.PreElement.AppendHtml("\""); } output.PreElement.AppendHtml(">"); foreach (var item in Selection ?? new SelectListItem[0]) { output.PreElement.AppendHtml("<option value=\""); output.PreElement.Append(item.Value); output.PreElement.AppendHtml("\" "); if (item.Selected) { output.PostContent.AppendHtml("selected"); } output.PreElement.AppendHtml(">"); output.PreElement.Append(item.Text); output.PreElement.AppendHtml("</option>"); } output.PreElement.AppendHtml("</select>"); output.Attributes.Add("class", "aiplugs-selectable-button__button"); output.Attributes.Add("data-target", "aiplugs-selectable-button.button"); output.PostElement.AppendHtml("</div>"); }