internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var grid = new TagBuilder("div", "grid", IsInGrid); onRender?.Invoke(grid); MergeAttributes(grid, context); if (Height != null) { grid.MergeStyle("height", Height.Value); } if (_rows != null) { grid.MergeStyle("grid-template-rows", _rows.ToAttribute()); } if (_columns != null) { grid.MergeStyle("grid-template-columns", _columns.ToAttribute()); } if (Background != BackgroundStyle.Default) { grid.AddCssClass("background-" + Background.ToString().ToKebabCase()); } if (DropShadow != ShadowStyle.None) { grid.AddCssClass("drop-shadow"); grid.AddCssClass(DropShadow.ToString().ToLowerInvariant()); } if (Gap != null) { grid.MergeStyle("grid-gap", Gap.ToString()); } if (AutoFlow != AutoFlowMode.Default) { grid.MergeStyle("grid-auto-flow", AutoFlow.ToString().ToKebabCase(delim: " ")); } if (AlignItems != AlignItem.Default) { String aiStyle = AlignItems.ToString().ToLowerInvariant(); if (AlignItems == AlignItem.Top) { aiStyle = "start"; } if (AlignItems == AlignItem.Bottom) { aiStyle = "end"; } grid.MergeStyle("align-items", aiStyle); } grid.RenderStart(context); RenderChildren(context); grid.RenderEnd(context); }
public static StyleBuilder AddStyle(this StyleBuilder styleBuilder, string name, AutoFlow autoFlow) => styleBuilder.AddStyle(name, Converter.ToCss(autoFlow), autoFlow != AutoFlow.None);