Skip to content

Commit ed880e5

Browse files
authored
feat(Light): support flash function when set IsFlat to true (#5083)
* feat: add is-flat-flash style * doc: 更新文档 * test: 更新单元测试
1 parent 00e9170 commit ed880e5

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

src/BootstrapBlazor.Server/Components/Samples/Lights.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@
9494
<Light Color="Color.Warning" IsFlat="true"></Light>
9595
</div>
9696
<div class="col-12 col-sm-4 col-md-3 col-lg-auto">
97-
<Light Color="Color.Primary" IsFlat="true"></Light>
97+
<Light Color="Color.Primary" IsFlat="true" IsFlash="true"></Light>
9898
</div>
9999
<div class="col-12 col-sm-4 col-md-3 col-lg-auto">
100-
<Light Color="Color.Secondary" IsFlat="true"></Light>
100+
<Light Color="Color.Secondary" IsFlat="true" IsFlash="true"></Light>
101101
</div>
102102
<div class="col-12 col-sm-4 col-md-3 col-lg-auto">
103-
<Light Color="Color.Dark" IsFlat="true"></Light>
103+
<Light Color="Color.Dark" IsFlat="true" IsFlash="true"></Light>
104104
</div>
105105
</div>
106106
<div class="row g-3 light-sm">

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,14 @@
485485
"LightsNormalTitle": "common usage",
486486
"LightsNormalIntro": "for status indication",
487487
"LightsFlashingTitle": "flicker",
488-
"LightsFlashingIntro": "Flash the light by setting the property <code>IsFlash</code>",
488+
"LightsFlashingIntro": "Flash the light by setting the parameter <code>IsFlash</code>",
489489
"LightsColorTitle": "discoloration",
490-
"LightsColorIntro": "Color the light by setting the value of the property <code>Color</code>",
490+
"LightsColorIntro": "Color the light by setting the value of the parameter <code>Color</code>",
491491
"LightsTooltipTextTitle": "prompt text",
492492
"LightsTooltipTextIntro": "By setting the value of the attribute <code>TooltipText</code> to make the <code>tooltip</code> text prompt when the mouse hovers over the indicator light",
493-
"TooltipText": "I am prompt text message"
493+
"TooltipText": "I am prompt text message",
494+
"LightsFlatTitle": "Flat",
495+
"LightsFlatIntro": "Make the indicator light flat by setting the parameter <code>IsFlat</code>"
494496
},
495497
"BootstrapBlazor.Server.Components.Samples.Charts.Index": {
496498
"Chart": "Chart",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@
490490
"LightsColorIntro": "通过设置属性 <code>Color</code> 值使指示灯进行变色",
491491
"LightsTooltipTextTitle": "提示文字",
492492
"LightsTooltipTextIntro": "通过设置属性 <code>TooltipText</code> 值使鼠标悬浮指示灯上时提示 <code>tooltip</code> 文字",
493-
"TooltipText": "我是提示文字信息"
493+
"TooltipText": "我是提示文字信息",
494+
"LightsFlatTitle": "扁平化",
495+
"LightsFlatIntro": "通过设置属性 <code>IsFlat</code> 使指示灯扁平化"
494496
},
495497
"BootstrapBlazor.Server.Components.Samples.Charts.Index": {
496498
"Chart": "Chart 图表",

src/BootstrapBlazor/Components/Light/Light.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public partial class Light
1616
protected string? ClassString => CssBuilder.Default("light")
1717
.AddClass("is-flat", IsFlat)
1818
.AddClass("flash", IsFlash && !IsFlat)
19+
.AddClass("is-flat-flash", IsFlash && IsFlat)
1920
.AddClass($"light-{Color.ToDescriptionString()}", Color != Color.None)
2021
.AddClassFromAttributes(AdditionalAttributes)
2122
.Build();

src/BootstrapBlazor/Components/Light/Light.razor.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
height: 100%;
7777
border-radius: 50%;
7878
border: 1px solid var(--bb-light-bg);
79+
}
80+
81+
&.is-flat-flash:after {
7982
animation: light-flat 1.2s infinite ease-in-out;
8083
}
8184
}
@@ -196,7 +199,7 @@
196199
@include animation(light-danger, #e17777, #892726);
197200
@include animation(light-success, #5cb85c, #116811);
198201
@include animation(light-info, #5bc0de, #1d7792);
199-
@include animation(light-light-warning, #ffc107, #cc9f18);
202+
@include animation(light-warning, #ffc107, #cc9f18);
200203
@include animation(light-primary, #007bff, #0f5fb5);
201204
@include animation(light-secondary, #6c757d, #4b5054);
202205
@include animation(light-dark, #6061e2, #3232a0);

test/UnitTest/Components/LightTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ public class LightTest : BootstrapBlazorTestBase
1111
public void IsFlash_Ok()
1212
{
1313
var cut = Context.RenderComponent<Light>(builder => builder.Add(s => s.IsFlash, true));
14-
Assert.Contains("flash", cut.Markup);
14+
Assert.Contains("light flash", cut.Markup);
15+
Assert.DoesNotContain("is-flash-flat", cut.Markup);
1516

1617
cut.SetParametersAndRender(pb =>
1718
{
1819
pb.Add(a => a.IsFlat, true);
1920
});
20-
Assert.DoesNotContain("flash", cut.Markup);
21+
Assert.DoesNotContain("light flash", cut.Markup);
2122
Assert.Contains("is-flat", cut.Markup);
23+
Assert.Contains("is-flat-flash", cut.Markup);
2224
}
2325

2426
[Fact]

0 commit comments

Comments
 (0)