public override void Process(TagHelperContext context, TagHelperOutput output) { int i = 0; foreach (var item in Items) { string selected = item.Selected ? @"checked=""checked""" : ""; string disabled = item.Disabled ? @"disabled=""disabled""" : ""; string html = $@" <div class=""c-check-field""> <input type=""checkbox"" {selected} {disabled} id=""{ModelName}_{i}__Selected"" name=""{ModelName}[{i}].Selected"" class=""c-check-field__input"" value=""true"" /> <label for='{ModelName}_{i}__Selected' class='c-check-field__decor' aria-hidden='true' role='presentation'></label> <label for='{ModelName}_{i}__Selected' class='c-check-field__label'>{item.Text}</label> <input type=""hidden"" id=""{ModelName}_{i}__Value"" name=""{ModelName}[{i}].Value"" value=""{item.Value}""> <input type=""hidden"" id=""{ModelName}_{i}__Text"" name=""{ModelName}[{i}].Text"" value=""{item.Text}""> </div>"; output.Content.AppendHtml(html); i += 1; } output.AddClass("checkboxlist", HtmlEncoder.Default); }
private void MakeActive(TagHelperOutput output) { output.AddClass("active", System.Text.Encodings.Web.HtmlEncoder.Default); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> /// <returns></returns> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.AddClass($"border-{BorderColor.ToClassName()}"); output.Attributes.RemoveAll("bd-color"); return(base.ProcessAsync(context, output)); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.AddClass(ApplicationService.LoginTheme, HtmlEncoder.Default); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (State == ButtonState.Primary && Weight != ButtonWeight.Clear) { // TODO throw necessary? throw new System.Exception("Cannot have a Type set when State is set to Primary."); } if (Branding != ButtonBranding.None && (Weight != ButtonWeight.Clear || State != ButtonState.Secondary)) { // TODO throw necessary? throw new System.Exception("Cannot have Weight or State set when Branding is set."); } output.TagMode = TagMode.StartTagAndEndTag; output.AddClass("s-btn"); if (Weight != ButtonWeight.Clear) { output.AddClass("s-btn__" + Weight.ToString().ToLower()); } if (State != ButtonState.Secondary) { output.AddClass("s-btn__" + State.ToString().ToLower()); } if (Branding != ButtonBranding.None) { output.AddClass("s-btn__" + Branding.ToString().ToLower()); } var sizeClass = ""; switch (Size) { case ButtonSize.XSmall: sizeClass = "s-btn__xs"; break; case ButtonSize.Small: sizeClass = "s-btn__sm"; break; case ButtonSize.Medium: sizeClass = "s-btn__md"; break; case ButtonSize.Large: sizeClass = "s-btn__lg"; break; case ButtonSize.XLarge: sizeClass = "s-btn__xl"; break; case ButtonSize.Default: default: break; } output.AddClass(sizeClass); if (Loading) { output.AddClass("is-loading"); } if (Selected) { output.AddClass("is-selected"); } if (Dropdown) { output.AddClass("s-btn__dropdown"); } if (Unset) { output.AddClass("s-btn__unset"); } if (Link) { output.AddClass("s-btn__link"); } }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var content = (await output.GetChildContentAsync()).GetContent(); BaseSearchModel search; var modalTitle = new TagBuilder("h5"); modalTitle.AddCssClass("modal-title"); modalTitle.InnerHtml.AppendHtml(_localizer[SharedResource.SearchFilters]); var closeText = new TagBuilder("span"); closeText.Attributes.Add("aria-hidden", "true"); closeText.InnerHtml.AppendHtml("×"); var closeButton = new TagBuilder("button"); closeButton.Attributes.Add("type", "button"); closeButton.Attributes.Add("data-dismiss", "modal"); closeButton.Attributes.Add("aria-label", "Close"); closeButton.AddCssClass("close"); closeButton.InnerHtml.AppendHtml(closeText); var modalHeader = new TagBuilder("div"); modalHeader.AddCssClass("modal-header"); modalHeader.InnerHtml.AppendHtml(modalTitle).AppendHtml(closeButton); var modalContent = new TagBuilder("div"); modalContent.AddCssClass("modal-content"); modalContent.InnerHtml.AppendHtml(modalHeader); var modalDialog = new TagBuilder("div"); modalDialog.AddCssClass("modal-dialog"); modalDialog.AddCssClass("modal-dialog-centered"); modalDialog.Attributes.Add("role", "document"); var form = new TagBuilder("form"); form.Attributes.Add("method", "post"); var pageNoInput = await new InputTagHelper(Generator) { ViewContext = ViewContext, For = SearchModel.GetPropertyModelExpression(nameof(search.PageNo)) }.RenderTagHelperAsync(); form.InnerHtml.AppendHtml(pageNoInput); var antiforgery = Generator.GenerateAntiforgery(ViewContext); form.InnerHtml.AppendHtml(antiforgery); var modalFooter = new TagBuilder("div"); modalFooter.AddCssClass("modal-footer"); var hasPrevillege = ViewContext.HttpContext.User.IsInRole(nameof(Role.Admin)) || ViewContext.HttpContext.User.IsInRole(nameof(Role.SuperAdmin)); if (hasPrevillege) { var includeDeletedItemsProperty = SearchModel.Model.GetType().GetPublicProperties() .FirstOrDefault(x => x.Name.Equals(nameof(search.IncludeDeletedItems), StringComparison.CurrentCulture)); var deletedCheck = await new InputTagHelper(Generator) { ViewContext = ViewContext, For = SearchModel.GetPropertyModelExpression(nameof(search.IncludeDeletedItems)) }.RenderTagHelperAsync(); deletedCheck.AddCssClass("custom-control-input"); var deletedCheckLabel = await new LabelTagHelper(Generator) { ViewContext = ViewContext, For = SearchModel.GetPropertyModelExpression(nameof(search.IncludeDeletedItems)) }.RenderTagHelperAsync(); deletedCheckLabel.AddCssClass("custom-control-label"); deletedCheckLabel.InnerHtml.Clear().AppendHtml(includeDeletedItemsProperty.GetDisplayName()); var deletedCheckWrapper = new TagBuilder("div"); deletedCheckWrapper.AddCssClass("custom-control"); deletedCheckWrapper.AddCssClass("custom-switch"); deletedCheckWrapper.Attributes.Add("dir", "rtl"); deletedCheckWrapper.InnerHtml.AppendHtml(deletedCheck).AppendHtml(deletedCheckLabel); var customControlWrapper = new TagBuilder("div"); customControlWrapper.AddCssClass("ml-auto"); customControlWrapper.InnerHtml.AppendHtml(deletedCheckWrapper); modalFooter.InnerHtml.AppendHtml(customControlWrapper); } var cancelButton = new TagBuilder("button"); cancelButton.Attributes.Add("type", "button"); cancelButton.Attributes.Add("data-dismiss", "modal"); cancelButton.AddCssClass("btn"); cancelButton.AddCssClass("btn-secondary"); cancelButton.AddCssClass("btn-sm"); cancelButton.InnerHtml.AppendHtml(_localizer[SharedResource.Cancel]); var submitButton = new TagBuilder("button"); submitButton.Attributes.Add("type", "submit"); submitButton.AddCssClass("btn"); submitButton.AddCssClass("btn-primary"); submitButton.AddCssClass("btn-sm"); submitButton.InnerHtml.AppendHtml(_localizer[SharedResource.Search]); var modalBody = new TagBuilder("div"); modalBody.AddCssClass("modal-body"); ((IViewContextAware)_viewComponentHelper).Contextualize(ViewContext); var adminSearch = await _viewComponentHelper.InvokeAsync(typeof(AdminSearchConditionViewComponent), new { model = SearchModel }); var modalBodyContainer = new TagBuilder("div"); modalBodyContainer.AddCssClass("container-fluid"); modalBodyContainer.InnerHtml.AppendHtml(content).AppendHtml(adminSearch); modalBody.InnerHtml.AppendHtml(modalBodyContainer); modalFooter.InnerHtml.AppendHtml(cancelButton).AppendHtml(submitButton); form.InnerHtml.AppendHtml(modalBody).AppendHtml(modalFooter); modalContent.InnerHtml.AppendHtml(form); modalDialog.InnerHtml.AppendHtml(modalContent); output.Content.AppendHtml(modalDialog); output.TagMode = TagMode.StartTagAndEndTag; output.TagName = "div"; output.AddClass("modal", HtmlEncoder.Default); output.AddClass("fade", HtmlEncoder.Default); output.AddClass("search", HtmlEncoder.Default); output.Attributes.Add("id", "searchModal"); output.Attributes.Add("tabindex", "-1"); output.Attributes.Add("role", "dialog"); output.Attributes.Add("aria-labelledby", "searchModalLabel"); output.Attributes.Add("aria-hidden", "true"); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> /// <returns></returns> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.TagName = "div"; output.AddClass("card-group"); return(base.ProcessAsync(context, output)); }
public override void Process(TagHelperContext context, TagHelperOutput output) { _urlHelper = _urlHelperFactory.GetUrlHelper(ViewContext); output.AddClass("btn"); if (Raised) { output.AddClass("pmd-btn-raised"); } if (Flat) { output.AddClass("pmd-btn-flat"); } if (Outline) { output.AddClass("pmd-btn-outline"); } if (Floating) { output.AddClass("pmd-btn-fab"); } if (IsLg) { output.AddClass("btn-lg"); } if (IsSm) { output.AddClass("btn-sm"); } if (Block) { output.AddClass("btn-block"); } if (Default) { output.AddClass("btn-default"); } if (Primary) { output.AddClass("btn-primary"); } if (Success) { output.AddClass("btn-success"); } if (Info) { output.AddClass("btn-info"); } if (Warning) { output.AddClass("btn-warning"); } if (Danger) { output.AddClass("btn-danger"); } if (Link) { output.AddClass("btn-link"); } if (!Default && !Primary && !Success && !Info && !Warning && !Danger && !Link) { output.AddClass("btn-primary"); } if (Icon != null) { output.AddClass("btn-icon"); output.PreContent.AppendHtml($"<i class=\"material-icons pmd-sm\">{Icon}</i>"); } if (Text == null) { output.AddClass("no-text"); } if (Action != null || Controller != null) { if (Type == null || (Type != null && Type == "submit")) { var url = _urlHelper.Action(Action, Controller, _routeValues); output.Attributes.SetAttribute("href", url); output.TagName = "a"; } } else if (Type != null && Type == "link") { output.TagName = "a"; } else if (OnClick != null) { output.SetAttribute("onclick", OnClick); output.TagName = "button"; } else { Type = "submit"; output.Attributes.SetAttribute("type", "submit"); output.TagName = "button"; } output.RemoveAttributes( new string[] { "raised", "flat", "outline", "floating", "lg", "sm", "block", "default", "primary", "success", "info", "warning", "danger", "link", "icon", "text" } ); output.TagMode = TagMode.StartTagAndEndTag; output.Content.SetHtmlContent(Text); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "form"; output.AddClass("form", NullHtmlEncoder.Default); output.AddClass("autoform", NullHtmlEncoder.Default); output.Attributes.Add("id", "config"); output.Attributes.Add("method", "post"); var obj = For.Model; var objName = For.Name; var groupedProps = obj .GetType() .GetProperties() .GroupBy(p => p.GetCustomAttribute <AutoformCategoryAttribute>()?.Name ?? "General") .ToDictionary(p => p.Key, p => p.ToList()); foreach (var(key, propertyInfos) in groupedProps) { output.Content.AppendHtml("<details>"); output.Content.AppendHtml($"<summary>{key}</summary>"); foreach (var prop in propertyInfos) { var type = Type.GetTypeCode(prop.PropertyType) switch { TypeCode.Int16 => "number", TypeCode.Int32 => "number", TypeCode.Int64 => "number", TypeCode.UInt16 => "number", TypeCode.UInt32 => "number", TypeCode.UInt64 => "number", TypeCode.Double => "number", TypeCode.Decimal => "number", TypeCode.Boolean => "checkbox", TypeCode.DateTime => "date", _ => "text" }; var label = prop.Name; var value = prop.GetValue(obj); output.Content.AppendHtml("<div class='o-form-group'>"); output.Content.AppendHtml($"<label for='{objName}_{label}'>{label}</label>"); output.Content.AppendHtml($"<input type='{type}' id='{objName}_{label}' name='{objName}.{label}' value='{value}' class='o-form-control active-border'>"); output.Content.AppendHtml("</div>"); } output.Content.AppendHtml("</details>"); } output.Content.AppendHtml("<div class='o-form-group'>"); output.Content.AppendHtml("<button type='submit' class='btn btn-primary'>Save</button>"); output.Content.AppendHtml("</div>"); var XCSRF = Generator.GenerateAntiforgery(ViewContext); if (XCSRF != null) { output.PostContent.AppendHtml(XCSRF); } } }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.AddClass("dropdown-item"); base.Process(context, output); }
public override void Process(TagHelperContext context, TagHelperOutput output) { var breadcrumbList = new TagBuilder("ol"); breadcrumbList.AddCssClass("govuk-breadcrumbs__list"); output.TagName = "div"; output.AddClass("govuk-breadcrumbs", HtmlEncoder.Default); if (Classes != null && Classes.Count > 0) { foreach (var @class in Classes) { output.AddClass(@class, HtmlEncoder.Default); } } if (CollapseOnMobile) { output.AddClass("govuk-breadcrumbs--collapse-on-mobile", HtmlEncoder.Default); } if (Items != null && Items.Count > 0) { foreach (var item in Items) { var anchor = new TagBuilder("a"); if (!string.IsNullOrWhiteSpace(item.Href)) { anchor.AddCssClass("govuk-breadcrumbs__link"); anchor.Attributes.Add("href", item.Href); if (item.Attributes != null && item.Attributes.Count > 0) { foreach (var attribute in item.Attributes) { anchor.Attributes.Add(attribute.Item1, attribute.Item2); } } } else { anchor.AddCssClass("govuk-breadcrumbs__list-item"); anchor.Attributes.Add("aria-current", "page"); } if (item.HTML != null) { anchor.InnerHtml.AppendHtml(item.HTML); } else { anchor.InnerHtml.Append(item.Text); } var listItem = new TagBuilder("li"); listItem.AddCssClass("govuk-breadcrumbs__list-item"); listItem.InnerHtml.AppendHtml(anchor); breadcrumbList.InnerHtml.AppendHtml(listItem); } } output.Content.AppendHtml(breadcrumbList); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.PreElement.AppendHtml("<div class=\"form-check\">"); output.AddClass("form-check-input"); output.PostElement.AppendHtml($"<label class=\"form-check-label\" for=\"{output.Attributes["id"].Value}\">{ (TagHelper.Text.IsNullOrWhiteSpace()? TagHelper.Title:TagHelper.Text)}</label></div>"); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.AddClass("text-right"); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var classNames = new List <string> { "govuk-button" }; if (Classes != null && Classes.Count > 0) { classNames.AddRange(Classes); } if (Disabled) { classNames.Add("govuk-button--disabled"); } // Determine type of element to use, if not explicitly set if (!string.IsNullOrWhiteSpace(Href)) { Element = ButtonType.a; } else { Element = ButtonType.button; } if (IsStartButton) { /* The SVG needs 'focusable="false"' so that Internet Explorer does not * treat it as an interactive element - without this it will be * 'focusable' when using the keyboard to navigate. */ var svg = @"<svg class=""govuk-button__start-icon"" xmlns=""http://www.w3.org/2000/svg"" width=""17.5"" height=""19"" viewBox=""0 0 33 40"" aria-hidden=""true"" focusable=""false""> <path fill=""currentColor"" d=""M0 0h13l20 20-20 20H0l20-20z"" /> </svg>"; classNames.Add("govuk-button--start"); if (Element.Equals(ButtonType.a) || Element.Equals(ButtonType.button)) { var tagContent = await output.GetChildContentAsync(); tagContent.AppendHtml(svg); output.Content.AppendHtml(tagContent); } } output.TagName = Element.ToString(); foreach (var className in classNames) { output.AddClass(className, HtmlEncoder.Default); } switch (Element) { case ButtonType.a: output.Attributes.Add("href", Href ?? "#"); output.Attributes.Add("role", "button"); output.Attributes.Add("draggable", "false"); break; case ButtonType.button: if (!string.IsNullOrWhiteSpace(Value)) { output.Attributes.Add("value", Value); } if (!string.IsNullOrWhiteSpace(Type)) { output.Attributes.Add("type", Type); } break; case ButtonType.input: if (!string.IsNullOrWhiteSpace(Value)) { output.Attributes.Add("value", Value); } if (!string.IsNullOrWhiteSpace(Type)) { output.Attributes.Add("type", Type); } else { output.Attributes.Add("type", "submit"); } break; default: break; } output.Attributes.Add("data-module", "govuk-button"); if (Attributes != null) { foreach (var Attribute in Attributes) { output.Attributes.Add(Attribute.Item1, Attribute.Item1); } } if (Element.Equals(ButtonType.button) || Element.Equals(ButtonType.input)) { if (!string.IsNullOrWhiteSpace(Name)) { output.Attributes.Add("name", Name); } if (Disabled) { output.Attributes.Add("disabled", "disabled"); output.Attributes.Add("aria-disabled", "true"); } if (PreventDoubleClick) { output.Attributes.Add("data-prevent-double-click", "true"); } } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> /// <returns></returns> public override void Process(TagHelperContext context, TagHelperOutput output) => output.AddClass("alert-heading");
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.TagName = "span"; output.TagMode = TagMode.StartTagAndEndTag; var startingContent = await output.GetChildContentAsync(); output.AddClass("s-badge"); string badgeTypeClass = null; switch (Type) { case BadgeType.Bronze: badgeTypeClass = "s-badge__bronze"; break; case BadgeType.Silver: badgeTypeClass = "s-badge__silver"; break; case BadgeType.Gold: badgeTypeClass = "s-badge__gold"; break; case BadgeType.Bounty: badgeTypeClass = "s-badge__bounty"; break; case BadgeType.Votes: badgeTypeClass = "s-badge__votes"; break; case BadgeType.Answered: badgeTypeClass = "s-badge__answered"; break; case BadgeType.Rep: badgeTypeClass = "s-badge__rep"; break; case BadgeType.RepDown: badgeTypeClass = "s-badge__rep-down"; break; case BadgeType.Important: badgeTypeClass = "s-badge__important"; break; } if (badgeTypeClass != null) { output.AddClass(badgeTypeClass); } string badgeSizeClass = null; switch (Size) { case BadgeSize.Mini: badgeSizeClass = "s-badge__mini"; break; } if (badgeSizeClass != null) { output.AddClass(badgeSizeClass); } if (!string.IsNullOrWhiteSpace(Image)) { output.Content.AppendHtml($@"<img class=""s-badge--image"" src=""{Image}"" aria-hidden=""true"" />"); } if (!startingContent.IsEmptyOrWhiteSpace) { var contentStr = startingContent.GetContent(); output.Content.AppendHtml(contentStr); } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> /// <returns></returns> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.AddClass("alert-link"); output.Attributes.RemoveAll("alert-link"); return(base.ProcessAsync(context, output)); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext); var contentContext = await output.GetChildContentAsync(); var content = contentContext.GetContent(); var classes = new List <string>(); if (string.IsNullOrEmpty(Subject)) { output.SuppressOutput(); return; } if (string.IsNullOrEmpty(Page) && string.IsNullOrEmpty(Action)) { output.TagName = "span"; } else { var link = string.IsNullOrEmpty(Action) ? urlHelper.Page(Page) : string.IsNullOrEmpty(Controller) ? urlHelper.Action(Action) : urlHelper.Action(Action, Controller); var current = _actionContextAccessor.ActionContext.HttpContext.Items.FirstOrDefault(x => x.Key == "NavHelper").Value?.ToString(); current = current?.StartsWith("/") == true ? current : $"/{current}"; current = current?.EndsWith("/Index", StringComparison.CurrentCultureIgnoreCase) == true ? string.Join("", current.Split("/Index")[0]) : current; var success = !string.IsNullOrEmpty(link) && !string.IsNullOrEmpty(current) && current == link; if (success) { if (HideOnTrigger) { output.SuppressOutput(); return; } classes.Add("active"); } if (!string.IsNullOrEmpty(Class)) { classes.AddRange(Class.Split(' ')); } output.Attributes.Add("href", link); output.TagName = "a"; } TagBuilder imgWrapper; if (string.IsNullOrEmpty(content)) { imgWrapper = new TagBuilder("div"); imgWrapper.AddCssClass("img"); var img = new TagBuilder("img"); img.Attributes.Add("src", urlHelper.Content(Icon)); img.Attributes.Add("alt", Subject); imgWrapper.InnerHtml.AppendHtml(img); } else { imgWrapper = null; } var txtWrapper = new TagBuilder("div"); txtWrapper.AddCssClass("text"); txtWrapper.InnerHtml.Append(Subject); if (!string.IsNullOrEmpty(content)) { var subItems = new TagBuilder("div"); subItems.AddCssClass("sub-items"); subItems.InnerHtml.AppendHtml(content); output.PostElement.AppendHtml(subItems); } output.AddClass("nav-link", HtmlEncoder.Default); if (!string.IsNullOrEmpty(content)) { output.AddClass("wrapper", HtmlEncoder.Default); } if (classes.Count > 0) { foreach (var @class in classes) { output.AddClass(@class, HtmlEncoder.Default); } } if (imgWrapper != null) { output.Content.AppendHtml(imgWrapper); } output.Content.AppendHtml(txtWrapper); output.TagMode = TagMode.StartTagAndEndTag; base.Process(context, output); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (output != null) { output.TagName = "div"; output.TagMode = TagMode.StartTagAndEndTag; string className = "form-group"; using var writer = new StringWriter(); switch (InputType) { case InputTypeSelect: WriteLabel(writer); WriteSelect(writer); WriteValidation(writer); break; case InputTypeRadioButtonGroup: WriteRadioGroup(writer); WriteValidation(writer); break; case InputTypeCheckboxGroup: WriteCheckboxGroup(writer); WriteValidation(writer); break; case InputTypeDateTimeOffset: WriteDateTimeOffsetBlock(writer); break; case InputTypeDate: WriteDateBlock(writer); break; case InputTypePassword: WriteLabel(writer); WritePassword(writer); WriteValidation(writer); break; case InputTypeCheckbox: className = "checkbox"; WriteCheckBoxInLabel(writer); WriteValidation(writer); break; case InputTypeTextArea: WriteLabel(writer); WriteTextArea(writer); WriteValidation(writer); break; case InputTypeTime: WriteLabel(writer); WriteTimeBox(writer); WriteValidation(writer); break; case InputTypeDateRange: WriteDateRangeBlock(writer); break; case InputTypeTimeRange: WriteTimeRangeBlock(writer); break; case InputTypeSplitTimeRange: className = "split-time-area"; WriteSplitTimeRangeBlock(writer); break; case InputTypeHiddenTimeRangeHidden: WriteTimeRangeBlock(writer, true); break; default: WriteLabel(writer); WriteInput(writer); WriteValidation(writer); break; } output.AddClass(className, _htmlEncoder); output.Content.AppendHtml(writer.ToString()); } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "h6"; output.AddClass("dropdown-header"); base.Process(context, output); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> /// <returns></returns> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.AddClass("mb-0"); return(base.ProcessAsync(context, output)); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.TagName = "div"; if (AsRow) { output.AddClass("row", HtmlEncoder.Default); } output.AddClass("grid", HtmlEncoder.Default); output.TagMode = TagMode.StartTagAndEndTag; if (Model?.Model == null) { goto NO_ITEM; } var pagination = Model.Model; var type = pagination.GetType(); if (!type.IsSubclassOf(typeof(PaginationViewModel))) { throw new Exception("Model that given to item-viewer is not typeof PaginationViewModel"); } var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList(); if (properties?.Any() != true) { throw new Exception("Model that given to item-viewer is not typeof PaginationViewModel"); } PaginationViewModel pag; var currentPageProp = properties.FirstOrDefault(x => x.Name.Equals(nameof(pag.CurrentPage), StringComparison.CurrentCulture)); var rowCountProp = properties.FirstOrDefault(x => x.Name.Equals(nameof(pag.Rows), StringComparison.CurrentCulture)); var pagesProp = properties.FirstOrDefault(x => x.Name.Equals(nameof(pag.Pages), StringComparison.CurrentCulture)); var itemsProp = properties.FirstOrDefault(x => x.Name.Equals("Items", StringComparison.CurrentCulture)); if (currentPageProp == null || rowCountProp == null || pagesProp == null || itemsProp == null) { throw new Exception("Model that given to item-viewer is not typeof PaginationViewModel"); } int currentPage; int rowCount; int pages; try { currentPage = (int)currentPageProp.GetValue(pagination); rowCount = (int)rowCountProp.GetValue(pagination); pages = (int)pagesProp.GetValue(pagination); } catch { throw new Exception("Model that given to item-viewer is not typeof PaginationViewModel"); } output.Attributes.Add("data-rows", rowCount); if (rowCount > 0) { var content = (await output.GetChildContentAsync()).GetContent(); output.Content.AppendHtml(content); return; } NO_ITEM: var message = new TagBuilder("h5"); message.InnerHtml.AppendHtml(_localizer[SharedResource.NoItemToShow]); if (!AsRow) { output.AddClass("row", HtmlEncoder.Default); } output.AddClass("justify-content-center", HtmlEncoder.Default); output.AddClass("align-items-center", HtmlEncoder.Default); output.Content.AppendHtml(message); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.AddClass("s-btn--icon"); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "div"; output.AddClass("btn-toolbar"); output.Attributes.Add("role", "toolbar"); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "div"; output.AddClass("govuk-width-container", HtmlEncoder.Default); output.TagMode = TagMode.StartTagAndEndTag; }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } if (For != null) { IDictionary <string, object> htmlAttributes = null; if (string.IsNullOrEmpty(For.Name) && string.IsNullOrEmpty(ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix) && output.Attributes.ContainsName(DataValidationForAttributeName)) { htmlAttributes = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase) { { DataValidationForAttributeName, "-non-empty-value-" }, }; } string message = null; if (!output.IsContentModified) { var tagHelperContent = await output.GetChildContentAsync(); if (!tagHelperContent.IsEmptyOrWhiteSpace) { message = tagHelperContent.GetContent(); } } var tagBuilder = Generator.GenerateValidationMessage( ViewContext, For.ModelExplorer, For.Name, message, null, htmlAttributes); if (tagBuilder != null) { output.MergeAttributes(tagBuilder); // Do not update the content if another tag helper targeting this element has already done so. if (!output.IsContentModified && tagBuilder.HasInnerHtml) { output.AddClass("nhsuk-error-message", HtmlEncoder.Default); var content = new DefaultTagHelperContent() .AppendHtml(new HtmlString("<span class=\"nhsuk-u-visually-hidden\">Error:</span>")) .AppendHtml(tagBuilder.InnerHtml); output.Content.SetHtmlContent(content); } } } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> protected virtual void AddBasicClasses(TagHelperContext context, TagHelperOutput output) { output.AddClass("carousel"); output.AddClass("slide"); SetFadeAnimation(context, output); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="output"></param> /// <returns></returns> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.TagName = "img"; output.AddClass($"card-img{Position.ToClassName()}"); return(base.ProcessAsync(context, output)); }
/// <summary> /// /// </summary> /// <param name="context"></param>s /// <param name="output"></param> /// <returns></returns> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { output.TagName = Heading.ToTagName(); output.AddClass("card-subtitle"); return(base.ProcessAsync(context, output)); }
public override void Process(TagHelperContext context, TagHelperOutput output) { var className = bool.Parse(IsActive) ? "active" : "inactive"; output.AddClass(className, HtmlEncoder.Default); }