/// <summary> /// Changes the button to use the given size. /// </summary> /// <example> /// @n.Submit("Submit").WithSize(ButtonSize.Large) /// </example> /// <param name="attrs">The Html Attributes from a navigation button</param> /// <param name="size">The size of button</param> /// <returns>The Html Attribute object so other methods can be chained off of it</returns> public static ButtonHtmlAttributes WithSize(this ButtonHtmlAttributes attrs, ButtonSize size) { if (size != ButtonSize.Default) { attrs.AddClass(string.Format("btn-{0}", size.Humanize())); } return(attrs); }
/// <summary> /// Changes the button to use the given size. /// </summary> /// <example> /// @n.Submit("Submit").WithSize(ButtonSize.Large) /// </example> /// <param name="attrs">The Html Attributes from a navigation button</param> /// <param name="size">The size of button</param> /// <returns>The Html Attribute object so other methods can be chained off of it</returns> public static ButtonHtmlAttributes WithSize(this ButtonHtmlAttributes attrs, ButtonSize size) { if (size != ButtonSize.Default && size != ButtonSize.NoneSpecified) { attrs.AddClass($"btn-{size.Humanize()}"); } return(attrs); }
public void Output_submit_button_with_non_default_style_or_size() { var t = new TwitterBootstrapFormTemplate(); var result = new ButtonHtmlAttributes(h => t.Button(new HtmlString("content"), "submit", null, null, h)) .WithStyle(EmphasisStyle.Danger).WithSize(ButtonSize.Large).WithIcon("star"); HtmlApprovals.VerifyHtml(result.ToHtmlString()); }
/// <summary> /// Adds the given emphasis to the button. /// </summary> /// <example> /// @n.Submit("Submit").WithStyle(EmphasisStyle.Warning) /// </example> /// <param name="attrs">The Html Attributes from a navigation button</param> /// <param name="style">The style of button</param> /// <returns>The Html Attribute object so other methods can be chained off of it</returns> public static ButtonHtmlAttributes WithStyle(this ButtonHtmlAttributes attrs, EmphasisStyle style) { attrs.AddClass($"btn-{style.ToString().ToLower()}"); return(attrs); }
/// <summary> /// Adds the given icon to the start of a navigation button. /// </summary> /// <example> /// @n.Submit("Submit").WithIcon("arrow-right") /// // Output: /// <button type="submit"><span class="glyphicon glyphicon-arrow-right"></span> Submit</button> /// </example> /// <param name="attrs">The Html Attributes from a navigation button</param> /// <param name="icon">The icon to use; see https://getbootstrap.com/docs/3.3/components/#glyphicons</param> /// <returns>The Html Attribute object so other methods can be chained off of it</returns> public static ButtonHtmlAttributes WithIcon(this ButtonHtmlAttributes attrs, string icon) { attrs.Attr(TwitterBootstrap3FormTemplate.IconAttrKey, icon); return(attrs); }
/// <summary> /// Adds the given emphasis to the button. /// </summary> /// <example> /// @n.Submit("Submit").WithStyle(EmphasisStyle.Warning) /// </example> /// <param name="attrs">The Html Attributes from a navigation button</param> /// <param name="style">The style of button</param> /// <returns>The Html Attribute object so other methods can be chained off of it</returns> public static ButtonHtmlAttributes WithStyle(this ButtonHtmlAttributes attrs, EmphasisStyle style) { attrs.AddClass(string.Format("btn-{0}", style.ToString().ToLower())); return(attrs); }