Skip to content

Commit 77fe9c8

Browse files
authored
Merge pull request #6 from Blazorade/feature/5-builder
Redesigned the builder infrastructure to include only one type of bui…
2 parents fbc0960 + 618c8d4 commit 77fe9c8

File tree

14 files changed

+224
-438
lines changed

14 files changed

+224
-438
lines changed

Blazorade.Core/Blazorade.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RazorLangVersion>3.0</RazorLangVersion>
6-
<Version>1.1.1</Version>
6+
<Version>1.3.0-preview3</Version>
77
<Authors>Mika Berglund</Authors>
88
<Company>Blazorade</Company>
99
<Description>Provides core functionality for your Blazor component libraries as well as many of the Blazorade libraries, such as Blazorade Bootstrap.</Description>

Blazorade.Core/Blazorade.Core.xml

Lines changed: 39 additions & 113 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Blazorade.Core/Components/BlazoradeComponentBase.cs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.AspNetCore.Components;
33
using System;
44
using System.Collections.Generic;
5+
using System.Collections.ObjectModel;
56
using System.Linq;
67
using System.Text;
78
using System.Threading.Tasks;
@@ -29,24 +30,15 @@ protected BlazoradeComponentBase()
2930
[Parameter(CaptureUnmatchedValues = true)]
3031
public IDictionary<string, object> Attributes { get; set; }
3132

32-
/// <summary>
33-
/// An attribute builder that is used when building attributes for the element before rendering.
34-
/// </summary>
3533
[Parameter]
36-
public IAttributeBuilder AttributeBuilder { get; set; }
34+
public IComponentBuilder Builder { get; set; }
3735

3836
/// <summary>
3937
/// Enables child content for the control.
4038
/// </summary>
4139
[Parameter]
4240
public virtual RenderFragment ChildContent { get; set; }
4341

44-
/// <summary>
45-
/// A class builder that is used when building the class names for the element before rendering.
46-
/// </summary>
47-
[Parameter]
48-
public IClassBuilder ClassBuilder { get; set; }
49-
5042
/// <summary>
5143
/// Returns a read-only copy of the classes defined on the component.
5244
/// </summary>
@@ -57,12 +49,6 @@ protected BlazoradeComponentBase()
5749
/// </summary>
5850
public IReadOnlyDictionary<string, string> Styles { get; set; }
5951

60-
/// <summary>
61-
/// A style builder that is used when building styles for the element before rendering.
62-
/// </summary>
63-
[Parameter]
64-
public IStyleBuilder StyleBuilder { get; set; }
65-
6652

6753

6854
/// <summary>
@@ -139,22 +125,21 @@ protected BlazoradeComponentBase AddStyle(string styleName, string value)
139125
/// </remarks>
140126
protected override void OnParametersSet()
141127
{
142-
143-
foreach(var a in this.AttributeBuilder?.Build() ?? new KeyValuePair<string, object>[0])
144-
{
145-
this.AddAttribute(a.Key, a.Value);
146-
}
128+
var builderAttributes = this.Builder?.BuildAttributes();
129+
var builderStyles = this.Builder?.BuildStyles();
147130

148-
if (null != this.ClassBuilder)
131+
foreach(var key in builderAttributes?.Keys ?? new string[0])
149132
{
150-
this.AddClasses(this.ClassBuilder.Build().ToArray());
133+
this.AddAttribute(key, builderAttributes[key]);
151134
}
152135

153-
foreach(var s in this.StyleBuilder?.Build() ?? new KeyValuePair<string, string>[0])
136+
foreach(var key in builderStyles?.Keys ?? new string[0])
154137
{
155-
this.AddStyle(s.Key, s.Value);
138+
this.AddStyle(key, builderStyles[key]);
156139
}
157140

141+
this.AddClasses((this.Builder?.BuildClasses() ?? new string[0]).ToArray());
142+
158143
base.OnParametersSet();
159144
}
160145

Blazorade.Core/Components/Builder/AttributeBuilder.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)