Skip to content

Commit 956ace1

Browse files
authored
Loading: Add Class/Style to the mudprogress component, and style to text (#80)
* Loading: Add Class and style for the mudprogress component, and style for the text * Simplify ClassLoader and styles * Rename TextStyle to StyleText and LoaderStyle to StyleLoader
1 parent 66549d4 commit 956ace1

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed

CodeBeam.MudExtensions/Components/Loading/MudLoading.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
{
1616
<MudOverlay Visible="_loading" Absolute="true" DarkBackground="@Darken">
1717
<div class="d-flex flex-column align-center justify-center">
18-
<MudProgressCircular Color="Color.Primary" Indeterminate="true" />
19-
<MudText Class="@TextClassname">@Text</MudText>
18+
<MudProgressCircular Class="@ClassLoader" Style="@StyleLoader" Color="Color.Primary" Indeterminate="true" />
19+
<MudText Class="@TextClassname" Style="@StyleText">@Text</MudText>
2020
</div>
2121
</MudOverlay>
2222
}
@@ -30,8 +30,8 @@
3030
else
3131
{
3232

33-
<MudProgressLinear Class="mb-2" Color="Color.Primary" Indeterminate="true" />
34-
<MudText Class="@TextClassname" Align="Align.Center">@Text</MudText>
33+
<MudProgressLinear Class="@ClassLoader" Style="@StyleLoader" Color="Color.Primary" Indeterminate="true" />
34+
<MudText Class="@TextClassname" Style="@StyleText" Align="Align.Center">@Text</MudText>
3535

3636
<MudOverlay Visible="_loading" Absolute="true" DarkBackground="@Darken">
3737
<div class="d-flex align-center justify-center">

CodeBeam.MudExtensions/Components/Loading/MudLoading.razor.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public partial class MudLoading : MudComponentBase
1616
.AddClass("mt-4")
1717
.AddClass(ClassText)
1818
.Build();
19-
19+
2020
bool _loading = true;
2121
/// <summary>
2222
/// Two way binded loading state.
@@ -64,6 +64,27 @@ public bool Loading
6464
[Category(CategoryTypes.FormComponent.Appearance)]
6565
public string ClassText { get; set; }
6666

67+
/// <summary>
68+
/// CSS classes for the progress component, seperated by space.
69+
/// </summary>
70+
[Parameter]
71+
[Category(CategoryTypes.FormComponent.Appearance)]
72+
public string ClassLoader { get; set; }
73+
74+
/// <summary>
75+
/// CSS style for the text.
76+
/// </summary>
77+
[Parameter]
78+
[Category(CategoryTypes.FormComponent.Appearance)]
79+
public string StyleText { get; set; }
80+
81+
/// <summary>
82+
/// CSS style for the progress component.
83+
/// </summary>
84+
[Parameter]
85+
[Category(CategoryTypes.FormComponent.Appearance)]
86+
public string StyleLoader { get; set; }
87+
6788
/// <summary>
6889
/// If true, show a darken background.
6990
/// </summary>

ComponentViewer.Docs/Pages/Components/LoadingPage.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<ExampleCard ExampleName="LoadingExample2" Title="Custom Loading Indicator" Description="Loading indicator can be a RenderFragment.">
1010
<LoadingExample2 />
1111
</ExampleCard>
12+
13+
<ExampleCard ExampleName="LoadingExample3" Title="Custom Classes" Description="Custom classes added to the loader and text">
14+
<LoadingExample3 />
15+
</ExampleCard>
1216
</ExamplePage>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@inject ISnackbar Snackbar
2+
3+
<MudGrid>
4+
<MudItem xs="12" sm="8" Class="d-flex gap-4 align-center flex-wrap">
5+
<MudPaper Class="mud-width-full" Style="height: 300px; position: relative">
6+
<MudLoading @bind-Loading="_loading" LoaderType="_loaderType" Text="@_text" ClassText="@_classText" ClassLoader="@_classLoader" StyleText="@_styleText" StyleLoader="@_styleLoader">
7+
<MudStack>
8+
<MudText>This is a text inside a paper. Its the content.</MudText>
9+
<MudButton OnClick="ShowSnackbar" Variant="Variant.Filled" Color="Color.Primary">A Button Can Not Be Clickable While Loading</MudButton>
10+
</MudStack>
11+
</MudLoading>
12+
</MudPaper>
13+
</MudItem>
14+
15+
<MudItem xs="12" sm="4">
16+
<MudStack>
17+
<MudSwitch @bind-Checked="_loading" Color="Color.Primary">Loading</MudSwitch>
18+
<MudSelect @bind-Value="_loaderType" Variant="Variant.Outlined" Label="Loader Type">
19+
<MudSelectItem Value="LoaderType.Circular">Circular</MudSelectItem>
20+
<MudSelectItem Value="LoaderType.Linear">Linear</MudSelectItem>
21+
</MudSelect>
22+
<MudTextField @bind-Value="_text" Variant="Variant.Outlined" Label="Text" />
23+
<MudTextField @bind-Value="_classText" Variant="Variant.Outlined" Label="Text Class" />
24+
<MudTextField @bind-Value="_styleText" Variant="Variant.Outlined" Label="Text Style" />
25+
<MudTextField @bind-Value="_classLoader" Variant="Variant.Outlined" Label="Loader Class" />
26+
<MudTextField @bind-Value="_styleLoader" Variant="Variant.Outlined" Label="Loader Style" />
27+
</MudStack>
28+
</MudItem>
29+
</MudGrid>
30+
31+
@code {
32+
bool _loading = true;
33+
string _text = "Some text.";
34+
string _classText;
35+
string _styleText;
36+
string _classLoader;
37+
string _styleLoader;
38+
LoaderType _loaderType = LoaderType.Circular;
39+
40+
private void ShowSnackbar()
41+
{
42+
Snackbar.Add("Button clicked.", Severity.Info);
43+
}
44+
}

0 commit comments

Comments
 (0)