Exemplo n.º 1
0
        internal void BuildDataTableTemplateCell(TagBuilder cell, Tuple <DataTableTemplateColumnTagHelper, IHtmlContent> templateColumn)
        {
            if (!templateColumn.Item1.IsAutoHide)
            {
                cell.Attributes.Add("data-autohide-disabled", "false");
            }

            if (templateColumn.Item1.IsAutoWidth)
            {
                cell.Attributes.Add("data-width", "auto");
            }
            else if (templateColumn.Item1.Width > 0 && !templateColumn.Item1.IsAutoWidth)
            {
                cell.Attributes.Add("data-width", templateColumn.Item1.Width.ToString());
            }

            var classes = CssClassBuilder.Build(
                new CssClass("kt-datatable__cell--sort", templateColumn.Item1.IsSort),
                new CssClass("kt-datatable__cell--center", templateColumn.Item1.IsCenter)
                );

            cell.AddCssClass(classes);

            if (cell.TagName == "td")
            {
                cell.InnerHtml.AppendHtml($"<span>{templateColumn.Item2.ToHtml()}</span>");
            }
            else
            {
                var name = String.IsNullOrWhiteSpace(templateColumn.Item1.DisplayName) ? templateColumn.Item1.FieldName : templateColumn.Item1.DisplayName;

                cell.InnerHtml.AppendHtml($"<span>{name}</span>");
            }
        }
Exemplo n.º 2
0
        internal void BuildDataTableTextCell(TagBuilder cell, DataField field, string value)
        {
            if (!field.IsAutoHide)
            {
                cell.Attributes.Add("data-autohide-disabled", "false");
            }

            if (field.IsAutoWidth)
            {
                cell.Attributes.Add("data-width", "auto");
            }
            else if (field.Width > 0 && !field.IsAutoWidth)
            {
                cell.Attributes.Add("data-width", field.Width.ToString());
            }

            var classes = CssClassBuilder.Build(
                new CssClass("kt-datatable__cell--sort", field.IsSort),
                new CssClass("kt-datatable__cell--center", field.IsCenter)
                );

            cell.AddCssClass(classes);

            if (cell.TagName == "td")
            {
                cell.InnerHtml.AppendHtml($@"<span>{value}</span>");
            }
            else
            {
                var name = String.IsNullOrWhiteSpace(field.DisplayName) ? field.Name : field.DisplayName;

                cell.InnerHtml.AppendHtml($@"<span>{name}</span>");
            }
        }
        public string BuildCssClass(Breakpoint breakpoint)
        {
            var builder = new CssClassBuilder("order")
                          .Append(() => breakpoint.GetCssClassPart(), () => breakpoint != Breakpoint.None);

            ConfigureCssClassBuilder(builder);
            return(builder.Build());
        }
Exemplo n.º 4
0
        internal string BuildToolActionCssClasses(State state)
        {
            var classes = CssClassBuilder.Build(
                new CssClass("btn btn-sm btn-icon btn-icon-md", true),
                new CssClass("btn-clean", IsCleaned),
                new CssClass(IsOutline ? $"btn-outline-{state.ToValue()}" : $"btn-{state.ToValue()}", IsColored),
                new CssClass("btn-pill", IsPilled));

            return(classes);
        }
        public void ShouldRenderOneCssClassWithTwoStyles()
        {
            var cssClass = new CssClass("Button")
                           .WithStyle(CssPropertyNames.Color, "green")
                           .WithStyle(CssPropertyNames.Margin, "20px");

            var cssClassBuilder = new CssClassBuilder(NullLogger <CssClassBuilder> .Instance);
            var expectedResult  = "\n .Button {\r\n\tcolor: green;\r\n\tmargin: 20px;\r\n}";

            var cssRepresentation = cssClassBuilder.BuildCssClassRepresentaion(cssClass);

            Assert.Equal(expectedResult, cssRepresentation);
        }
        public IEnumerable <string> BuildCssClasses(Breakpoint breakpoint)
        {
            if (ImpactedSides == Sides.None)
            {
                yield break;
            }

            foreach (var side in GetSides())
            {
                var builder = new CssClassBuilder(GetCssClassPrefix(side))
                              .Append(() => breakpoint.GetCssClassPart(), () => breakpoint != Breakpoint.None)
                              .Append(GetCssClassSuffix);

                yield return(builder.Build());
            }
        }
        public void ShouldRenderOneCssClassWithTwoStylesAndClassWithSelector()
        {
            var cssClass = new CssClass("Button")
                           .WithStyle(CssPropertyNames.Color, "green")
                           .WithStyle(CssPropertyNames.Margin, "20px")
                           .AddPseudoSelector(PseudoSelector.Hover, props =>
                                              props.WithStyle(CssPropertyNames.Color, "red").WithlStyleInPixelUnit(CssPropertyNames.Margin, 50));

            var cssClassBuilder = new CssClassBuilder(NullLogger <CssClassBuilder> .Instance);
            var expectedResult  = "\n .Button {\r\n\tcolor: green;\r\n\tmargin: 20px;\r\n}\n " +
                                  ".Button:hover {\r\n\tcolor: red;\r\n\tmargin: 50px;\r\n}\r\n";

            var cssRepresentation = cssClassBuilder.BuildCssClassRepresentaion(cssClass);

            Assert.Equal(expectedResult, cssRepresentation);
        }
 protected override void ConfigureCssClassBuilder(CssClassBuilder builder)
 {
     builder.Append($"{Order}");
 }
 protected abstract void ConfigureCssClassBuilder(CssClassBuilder builder);
Exemplo n.º 10
0
 protected override void OnParametersSet()
 {
     base.OnParametersSet();
     wrapperClassBuilder = CssClassBuilder.CreateCssClassBuilder().Add("el-card", "box-card", $"is-{Shadow.ToString().ToLower()}-shadow", Cls);
     bodyClassBuilder    = CssClassBuilder.CreateCssClassBuilder().Add("el-card__body", BodyCls);
 }
 protected override void ConfigureCssClassBuilder(CssClassBuilder builder)
 {
     builder.Append(Position.GetCssClassPart());
 }