Skip to content

Commit 6a40d7a

Browse files
committed
Update the Visible property
1 parent 47849c3 commit 6a40d7a

File tree

8 files changed

+82
-6
lines changed

8 files changed

+82
-6
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<FluentStack Orientation="@Orientation.Vertical">
2+
<div>
3+
Content before the ProgressBar
4+
</div>
5+
<FluentProgressBar Width="200px" Visible="@Visible" Style="height: 5px;" />
6+
<div>
7+
Content after the ProgressBar
8+
</div>
9+
</FluentStack>
10+
11+
<FluentSelect Items="@([true, false, null])"
12+
OptionText="@(i => GetVisibleText(i) )"
13+
TOption="bool?"
14+
@bind-Value="@Visible" />
15+
16+
@code
17+
{
18+
bool? Visible = true;
19+
20+
string GetVisibleText(bool? visible)
21+
{
22+
return $"Visible = {(visible.HasValue ? (visible == true ? "true" : "false") : "null")}";
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<FluentStack Orientation="@Orientation.Vertical">
2+
<div>
3+
Content before the ProgressBar
4+
</div>
5+
<FluentSpinner Visible="@Visible" />
6+
<div>
7+
Content after the ProgressBar
8+
</div>
9+
</FluentStack>
10+
11+
<FluentSelect Items="@([true, false, null])"
12+
OptionText="@(i => GetVisibleText(i) )"
13+
TOption="bool?"
14+
@bind-Value="@Visible" />
15+
16+
@code
17+
{
18+
bool? Visible = true;
19+
20+
string GetVisibleText(bool? visible)
21+
{
22+
return $"Visible = {(visible.HasValue ? (visible == true ? "true" : "false") : "null")}";
23+
}
24+
}

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Progress/FluentProgressBar.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ The background color of the progress bar can be set using the `BackgroundColor`
4040

4141
{{ ProgressBarState }}
4242

43+
## Visible
44+
45+
The `Visible` parameter can be used to show or hide the progress bar.
46+
This parameter is nullable:
47+
- If `true` (default), the component is visible.
48+
- If `false`, the component is hidden.
49+
- If `null`, the component is hidden and not rendered.
50+
51+
{{ ProgressBarVisible }}
52+
4353
## API FluentProgressBar
4454

4555
{{ API Type=FluentProgressBar }}

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Progress/FluentSpinner.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ In some situations, you may need to display a spinner on a dark background.
3838

3939
{{ SpinnerInverted }}
4040

41+
## Visible
42+
43+
The `Visible` parameter can be used to show or hide the progress bar.
44+
This parameter is nullable:
45+
- If `true` (default), the component is visible.
46+
- If `false`, the component is hidden.
47+
- If `null`, the component is hidden and not rendered.
48+
49+
{{ SpinnerVisible }}
50+
4151
## API FluentSpinner
4252

4353
{{ API Type=FluentSpinner }}

src/Core/Components/Progress/FluentProgressBar.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@using Microsoft.FluentUI.AspNetCore.Components.Extensions
33
@inherits FluentComponentBase
44

5-
@if (Visible)
5+
@if (Visible.HasValue)
66
{
77
@if (HasCustomStyle)
88
{

src/Core/Components/Progress/FluentProgressBar.razor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public partial class FluentProgressBar : FluentComponentBase, ITooltipComponent
2121

2222
/// <summary />
2323
protected string? StyleValue => DefaultStyleBuilder
24+
.AddStyle("visibility", "hidden", () => Visible == false)
2425
.AddStyle("width", Width, () => !string.IsNullOrEmpty(Width))
2526
.AddStyle("background-color", BackgroundColor, () => !string.IsNullOrEmpty(BackgroundColor))
2627
.Build();
@@ -52,10 +53,13 @@ public partial class FluentProgressBar : FluentComponentBase, ITooltipComponent
5253
public int? Value { get; set; }
5354

5455
/// <summary>
55-
/// Gets or sets the visibility of the component
56+
/// Gets or sets the visibility of the component.
57+
/// If `true` (default), the component is visible.
58+
/// If `false`, the component is hidden.
59+
/// If `null`, the component is hidden and not rendered.
5660
/// </summary>
5761
[Parameter]
58-
public bool Visible { get; set; } = true;
62+
public bool? Visible { get; set; } = true;
5963

6064
/// <summary>
6165
/// Gets or sets the component width.

src/Core/Components/Progress/FluentSpinner.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@using Microsoft.FluentUI.AspNetCore.Components.Extensions
33
@inherits FluentComponentBase
44

5-
@if (Visible)
5+
@if (Visible.HasValue)
66
{
77
<fluent-spinner id="@Id"
88
class="@ClassValue"

src/Core/Components/Progress/FluentSpinner.razor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ public partial class FluentSpinner : FluentComponentBase, ITooltipComponent
1717

1818
/// <summary />
1919
protected string? StyleValue => DefaultStyleBuilder
20+
.AddStyle("visibility", "hidden", () => Visible == false)
2021
.Build();
2122

2223
/// <summary>
23-
/// Gets or sets the visibility of the component
24+
/// Gets or sets the visibility of the component.
25+
/// If `true` (default), the component is visible.
26+
/// If `false`, the component is hidden.
27+
/// If `null`, the component is hidden and not rendered.
2428
/// </summary>
2529
[Parameter]
26-
public bool Visible { get; set; } = true;
30+
public bool? Visible { get; set; } = true;
2731

2832
/// <summary>
2933
/// Gets or sets whether the spinner should be shown in an inverted color scheme (i.e. light spinner on dark background)

0 commit comments

Comments
 (0)