Skip to content

Commit 5c3ce1f

Browse files
committed
Main Cleanup
1 parent fb651ce commit 5c3ce1f

File tree

10 files changed

+51
-38
lines changed

10 files changed

+51
-38
lines changed

BCSS.Test/CoreTests/BunitTest.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-

2-
using System;
3-
using System.Threading.Tasks;
4-
using BCSS.Services;
1+
using BCSS.Services;
52
using Bunit;
6-
using Microsoft.Extensions.DependencyInjection;
7-
using MudBlazor;
83
using MudBlazor.Services;
94
using MudExtensions.Services;
10-
using NUnit.Framework;
115

126
namespace BCSS.Test.Core
137
{

BCSS.Test/CoreTests/ConverterTests.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
using Bunit;
2-
using BCSSViewer.Docs.Pages;
3-
using FluentAssertions;
4-
using MudBlazor;
5-
using MudExtensions;
1+
using FluentAssertions;
62
using BCSS.Services;
7-
using Microsoft.AspNetCore.Components;
83

94
namespace BCSS.Test.Core
105
{

BCSS.Test/CoreTests/RenderTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using Bunit;
2-
using BCSSViewer.Docs.Pages;
1+
using BCSSViewer.Docs.Pages;
32
using FluentAssertions;
4-
using MudBlazor;
5-
using MudExtensions;
63

74
namespace BCSS.Test.Core
85
{

BCSS/Component/BlazorCssProvider.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@namespace BCSS
2-
@using BCSS.Services;
2+
@using BCSS.Services
33
@inherits ComponentBase
44
@inject BcssService BcssService
55

BCSS/Component/BlazorCssProvider.razor.cs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,33 @@ public partial class BlazorCssProvider : ComponentBase
2424
[Parameter]
2525
public bool KeepSingleValue { get; set; }
2626

27+
/// <summary>
28+
/// The spacing multiplier for px measured CSS properties like padding, margin, top, left, right, bottom.
29+
/// </summary>
2730
[Parameter]
2831
public int Spacing { get; set; } = 1;
2932

33+
/// <summary>
34+
/// The small size measured by pixels.
35+
/// </summary>
3036
[Parameter]
3137
public int Sm { get; set; } = 600;
3238

39+
/// <summary>
40+
/// The medium size measured by pixels.
41+
/// </summary>
3342
[Parameter]
3443
public int Md { get; set; } = 960;
3544

45+
/// <summary>
46+
/// The large size measured by pixels.
47+
/// </summary>
3648
[Parameter]
3749
public int Lg { get; set; } = 1280;
3850

51+
/// <summary>
52+
/// The extra large size measured by pixels.
53+
/// </summary>
3954
[Parameter]
4055
public int Xl { get; set; } = 1920;
4156

@@ -126,6 +141,10 @@ protected internal async Task<bool> IsValid(string propName, string propValue, b
126141
return true;
127142
}
128143

144+
/// <summary>
145+
/// Check all BCSS classes if they are valid or not. The method will automatically removes stored and invalid BCSS classes.
146+
/// </summary>
147+
/// <returns></returns>
129148
public async Task CheckAllValues()
130149
{
131150
List<BcssInfo> toBeDeletedInfos = new();
@@ -227,16 +246,23 @@ public void Update()
227246
_shouldRender = false;
228247
}
229248

230-
public void Clear(string key)
249+
/// <summary>
250+
/// Removes all BCSS classes (if key is null or empty) or matched classes (if key specified). If a BCSS class is currently using in the page, it will automatically add again.
251+
/// </summary>
252+
/// <param name="key"></param>
253+
public void Clear(string? key = null)
231254
{
255+
if (string.IsNullOrEmpty(key))
256+
{
257+
_bcssInfos.Clear();
258+
return;
259+
}
232260
_bcssInfos.RemoveAll(x => x.Key?.Split("-").First() == key.Split('-').First());
233261
}
234262

235-
public void Clear()
236-
{
237-
_bcssInfos.Clear();
238-
}
239-
263+
/// <summary>
264+
/// Removes last added BcssInfo.
265+
/// </summary>
240266
public void ClearLast()
241267
{
242268
_bcssInfos.Remove(_bcssInfos.Last());

BCSS/Extensions/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
using System;
2-
using System.Diagnostics.CodeAnalysis;
3-
using Microsoft.Extensions.DependencyInjection;
1+
using Microsoft.Extensions.DependencyInjection;
42
using Microsoft.Extensions.DependencyInjection.Extensions;
53

64
namespace BCSS.Services
75
{
8-
[ExcludeFromCodeCoverage]
96
public static class ServiceCollectionExtensions
107
{
118
public static IServiceCollection AddBcss(this IServiceCollection services)

BCSS/Services/BcssService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ public void Reset()
114114
Provider.Update();
115115
}
116116

117+
/// <summary>
118+
/// Adds unified classes with given user-created name and BCSS classes seperated with space.
119+
/// </summary>
120+
/// <param name="unifiedName"></param>
121+
/// <param name="value"></param>
117122
public void AddUnifiedClass(string unifiedName, string value)
118123
{
119124
if (Provider == null)
@@ -181,7 +186,7 @@ public void SetPerformanceMode(bool value)
181186
#pragma warning restore BL0005
182187
}
183188

184-
public async Task CheckValuesIsValid()
189+
public async Task RemoveInvalidClasses()
185190
{
186191
if (Provider == null)
187192
{

BCSS/Services/BlazorCssConverter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static string Convert(string className, BlazorCssProvider? provider = nul
4343
}
4444

4545
bool _shouldNotLowercase = false;
46-
if (className.Contains("[") && className.Contains("/"))
46+
if (className.Contains('[') && className.Contains('/'))
4747
{
4848
_shouldNotLowercase = true;
4949
}
@@ -226,7 +226,7 @@ public static string Convert(string className, BlazorCssProvider? provider = nul
226226

227227
if (string.Equals(fullKey, "bottom", StringComparison.InvariantCultureIgnoreCase))
228228
{
229-
return DimensionResult(processedValue, fullKey);
229+
return DimensionResult(processedValue.Replace('n', '-'), fullKey);
230230
}
231231

232232
if (string.Equals(fullKey, "box", StringComparison.InvariantCultureIgnoreCase))
@@ -306,7 +306,7 @@ public static string Convert(string className, BlazorCssProvider? provider = nul
306306

307307
if (string.Equals(fullKey, "left", StringComparison.InvariantCultureIgnoreCase))
308308
{
309-
return DimensionResult(processedValue, fullKey);
309+
return DimensionResult(processedValue.Replace('n', '-'), fullKey);
310310
}
311311

312312
if (string.Equals(fullKey, "min-height", StringComparison.InvariantCultureIgnoreCase))
@@ -541,7 +541,7 @@ public static string Convert(string className, BlazorCssProvider? provider = nul
541541

542542
if (string.Equals(fullKey, "right", StringComparison.InvariantCultureIgnoreCase))
543543
{
544-
return DimensionResult(processedValue, fullKey);
544+
return DimensionResult(processedValue.Replace('n', '-'), fullKey);
545545
}
546546

547547
if (string.Equals(fullKey, "rotate", StringComparison.InvariantCultureIgnoreCase))
@@ -663,7 +663,7 @@ public static string Convert(string className, BlazorCssProvider? provider = nul
663663

664664
if (string.Equals(fullKey, "top", StringComparison.InvariantCultureIgnoreCase))
665665
{
666-
return DimensionResult(processedValue, fullKey);
666+
return DimensionResult(processedValue.Replace('n', '-'), fullKey);
667667
}
668668

669669
if (string.Equals(fullKey, "translate", StringComparison.InvariantCultureIgnoreCase))

BCSS/wwwroot/Bcss.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
function checkcss(propname, propvalue) {
1+
function checkcss(propname, propvalue) {
32
var result = CSS.supports(propname, propvalue);
43
return result;
5-
}
4+
}

BCSSViewer/Pages/_Host.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
<script src="_framework/blazor.server.js"></script>
4949
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
5050
<script src="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"></script>
51-
<script src="_content/CodeBeam.BCSS/Bcss.js"></script>
51+
<script src="_content/CodeBeam.BCSS/Bcss.min.js"></script>
5252
</body>
5353
</html>

0 commit comments

Comments
 (0)