-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add style prioritizer, button styles to include a loader
- Loading branch information
1 parent
819dde8
commit 859bab1
Showing
9 changed files
with
224 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
@inherits PureButtonBase | ||
|
||
<button | ||
@attributes="InputAttributes" | ||
class="@InternalCss @Styles" | ||
disabled="@Disabled" | ||
@onmousedown="() => Pressed = true" | ||
@onmouseup="() => Pressed = false" | ||
@onclick="OnClicked"> | ||
@if (ChildContent != null) | ||
{ | ||
@ChildContent | ||
} | ||
else | ||
{ | ||
@Text | ||
} | ||
</button> | ||
@if (Loading) | ||
{ | ||
<button | ||
type="button" | ||
@attributes="InputAttributes" | ||
class="@InternalCss @Styles"> | ||
<PureIcon Type="IconOpenCircle" Animate="PureAnimate.Spin" Size="PureSize.Small"></PureIcon> | ||
@if (LoadingText is not null) | ||
{ | ||
@LoadingText | ||
} | ||
else | ||
{ | ||
if (ChildContent is not null) | ||
{ | ||
@ChildContent | ||
} | ||
else | ||
{ | ||
@Text | ||
} | ||
} | ||
|
||
</button> | ||
} | ||
else | ||
{ | ||
<button | ||
@attributes="InputAttributes" | ||
class="@InternalCss @Styles" | ||
disabled="@Disabled" | ||
@onmousedown="() => Pressed = true" | ||
@onmouseup="() => Pressed = false" | ||
@onclick="OnClicked"> | ||
@if (ChildContent is not null) | ||
{ | ||
@ChildContent | ||
} | ||
else | ||
{ | ||
@Text | ||
} | ||
</button> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Pure.Blazor.Components/Common/Css/SegmentBenchmarks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Pure.Blazor.Components.Common.Css; | ||
|
||
public class SegmentBenchmarks | ||
{ | ||
[Benchmark(Baseline = true)] | ||
public void NoSeparator() => "foo".Segment(':'); | ||
|
||
[Benchmark] | ||
public void Single() => "bg-gray-100".Segment('-'); | ||
|
||
[Benchmark] | ||
public void OnlySeparators() => "foo:bar:baz".Segment(':'); | ||
|
||
[Benchmark] | ||
public void Parens() => "a:(b:c):d".Segment(':'); | ||
|
||
[Benchmark] | ||
public void Brackets() => "a:[b:c]:d".Segment(':'); | ||
|
||
[Benchmark] | ||
public void CurlyBraces() => "a:{b:c}:d".Segment(':'); | ||
|
||
[Benchmark] | ||
public void Var() => "var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)".Segment(','); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace Pure.Blazor.Components.Common.Css; | ||
|
||
public static class Segmentor | ||
{ | ||
public static Stack<string> Segment(this string input, char separator) | ||
{ | ||
var closingBracketStack = new Stack<char>(); | ||
var parts = new Stack<string>(); | ||
var lastPos = 0; | ||
|
||
for (var idx = 0; idx < input.Length; idx++) | ||
{ | ||
var charValue = input[idx]; | ||
|
||
if (closingBracketStack.Count == 0 && charValue == separator) | ||
{ | ||
parts.Push(input.Substring(lastPos, idx - lastPos)); | ||
lastPos = idx + 1; | ||
continue; | ||
} | ||
|
||
switch (charValue) | ||
{ | ||
case '\\': | ||
idx += 1; | ||
break; | ||
case '(': | ||
closingBracketStack.Push(')'); | ||
break; | ||
case '[': | ||
closingBracketStack.Push(']'); | ||
break; | ||
case '{': | ||
closingBracketStack.Push('}'); | ||
break; | ||
case ')': | ||
case ']': | ||
case '}': | ||
if (closingBracketStack.Count > 0 && charValue == closingBracketStack.Peek()) | ||
{ | ||
closingBracketStack.Pop(); | ||
} | ||
|
||
break; | ||
} | ||
} | ||
|
||
parts.Push(input[lastPos..]); | ||
|
||
return parts; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<svg xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
fill="@strokeFill" | ||
viewBox="0 0 24 24" | ||
stroke-width="1.5" | ||
stroke="currentColor" | ||
stroke-width="@strokeWidth" | ||
stroke="@strokeColor" | ||
class="@InternalCss @Css"> | ||
@Markup | ||
@markupString | ||
</svg> |
Oops, something went wrong.