Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Jan 9, 2024
1 parent 7fb147f commit 0640102
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 85 deletions.
76 changes: 5 additions & 71 deletions src/Masa.Blazor/Components/Alert/MAlert.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ protected override void SetComponentClass()
{
css.Add("m-sheet")
.AddIf("m-sheet--shaped", () => Shaped)
// .AddIf("m-alert--border", () => Border != Borders.None);
.Modifiers(m
=> m.Modifier("border", Border != Borders.None)
.Add(Border, Border != Borders.None)
Expand Down Expand Up @@ -221,78 +220,13 @@ protected override void SetComponentClass()
.Element("border", css =>
{
css
// .Modifiers(m
// => m.Modifier("has-color", ColoredBorder)
// // .Add(Border.ToString())
// // .AddTextColor(Color, ColoredBorder)
// )
.Modifiers(m
=> m.Modifier("has-color", ColoredBorder)
.Add(Border.ToString())
.AddTextColor(Color, ColoredBorder)
)
.AddIf(Type.ToString().ToLower(), () => HasTypedBorder);
}, style => { style.AddTextColor(Color, () => ColoredBorder); });

return;

CssProvider
.Apply(cssBuilder =>
{
cssBuilder
.Add("m-alert")
.Add("m-sheet")
.AddIf("m-alert--border", () => Border != Borders.None)
.Add(AlertBorderClass)
.AddIf("m-sheet--shaped", () => Shaped)
.AddTheme(IsDarkTheme, IndependentTheme)
.AddElevation(Elevation)
.AddFirstIf(
(() => "m-alert--prominent", () => Prominent),
(() => "m-alert--dense", () => Dense))
.AddIf("m-alert--text", () => Text)
.AddIf("m-alert--outlined", () => Outlined)
.AddColor(ComputedColor, HasText, () => !ColoredBorder)
.AddRounded(Rounded, Tile);
}, styleBuilder =>
{
styleBuilder
.AddColor(ComputedColor, HasText, () => !ColoredBorder)
.AddHeight(Height)
.AddMaxHeight(MaxHeight)
.AddMinHeight(MinHeight)
.AddWidth(Width)
.AddMaxWidth(MaxWidth)
.AddMinWidth(MinWidth)
.AddIf("display:none", () => Transition == null && !Value);
})
.Apply("wrapper", cssBuilder => { cssBuilder.Add("m-alert__wrapper"); })
.Apply("content", cssBuilder => { cssBuilder.Add("m-alert__content"); })
.Apply("title", cssBuilder => { cssBuilder.Add("m-alert__title"); })
.Apply("border", cssBuilder =>
{
cssBuilder
.Add("m-alert__border")
.Add(BorderClass)
.AddIf("m-alert__border--has-color", () => ColoredBorder)
.AddIf(() => Type.ToString().ToLower(), () => HasTypedBorder)
.AddTextColor(Color, () => ColoredBorder);
}, styleBuilder => { styleBuilder.AddTextColor(Color, () => ColoredBorder); });

string BorderClass() => Border switch
{
Borders.Left => "m-alert__border--left",
Borders.Right => "m-alert__border--right",
Borders.Top => "m-alert__border--top",
Borders.Bottom => "m-alert__border--bottom",
Borders.None => "",
_ => throw new ArgumentOutOfRangeException(nameof(Border))
};

string AlertBorderClass() => Border switch
{
Borders.Left => "m-alert--border-left",
Borders.Right => "m-alert--border-right",
Borders.Top => "m-alert--border-top",
Borders.Bottom => "m-alert--border-bottom",
Borders.None => "",
_ => throw new ArgumentOutOfRangeException(nameof(Border))
};
}

private async Task HandleOnDismiss(MouseEventArgs args)
Expand Down
14 changes: 0 additions & 14 deletions test/Masa.Blazor.Test/Alert/MAlertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@ namespace Masa.Blazor.Test.Alert
[TestClass]
public class MAlertTests : TestBase
{
[TestMethod]
public void TestLoad()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var cut = RenderComponent<MAlert>();
for (int i = 0; i < 100000; i++)
{
cut.Render();
}
stopwatch.Stop();
Console.Out.WriteLine("MAlert took " + stopwatch.ElapsedMilliseconds + " ms to render");
}

[TestMethod]
public void RenderAlertWithColoredBorder()
{
Expand Down

0 comments on commit 0640102

Please sign in to comment.