Skip to content

Commit 791e5cb

Browse files
Loader Initial Docs (#131)
* chore(loader): basic setup * docs(loader): single click button; appearance basics * chore(loader): screenshots and code to explore appearance settings * chore(loader): better gif so it is not choppy * chore(loader): custom color screenshot * chore(loader): sample loading panel
1 parent 9b28ff6 commit 791e5cb

File tree

10 files changed

+318
-0
lines changed

10 files changed

+318
-0
lines changed

_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ navigation:
236236
title: "LinearGauge"
237237
"*listbox":
238238
title: "ListBox"
239+
"*loader":
240+
title: "Loader"
239241
"*map":
240242
title: "Map"
241243
"*maskedtextbox":
@@ -336,6 +338,7 @@ intro_columns:
336338
"Tab Strip": "components/tabstrip/overview"
337339
"TreeView": "components/treeview/overview"
338340
"Pager": "pager-overview"
341+
"Loader": "loader-overview"
339342

340343
-
341344
categories:

components/loader/appearance.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
title: Appearance
3+
page_title: Loader Appearance
4+
description: Appearance settings of the Loading indicator for Blazor.
5+
slug: loader-appearance
6+
tags: telerik,blazor,loader,appearance
7+
published: True
8+
position: 5
9+
---
10+
11+
# Appearance Settings
12+
13+
The loader component provides the following parameters that control its appearance:
14+
15+
* [Type](#type)
16+
* [Size](#size)
17+
* [ThemeColor](#themecolor)
18+
19+
You can use all three together to get the desired appearance. This article will explain their effect one by one.
20+
21+
## Type
22+
23+
The `Type` parameter controls the general shape of the animation. It takes a member of the `Telerik.Blazor.Components.LoaderType` enum:
24+
25+
* `Pulsing`
26+
* `InfiniteSpinner`
27+
* `ConvergingSpinner`
28+
29+
You can see them in action in the [Loader Overview](https://demos.telerik.com/blazor-ui/loader/overview) Live Demo.
30+
31+
>caption Loader Types
32+
33+
![loader types](images/loader-types.gif)
34+
35+
````CSHTML
36+
@foreach (LoaderType type in Enum.GetValues(typeof(Telerik.Blazor.Components.LoaderType)))
37+
{
38+
<div style="float: left; margin: 20px;">
39+
@type
40+
<br /><br />
41+
<TelerikLoader Type="@type"></TelerikLoader>
42+
</div>
43+
}
44+
````
45+
46+
## Size
47+
48+
There are three predefined sizes for the loader that you can set through its `Size` parameter that takes a member of the `Telerik.Blazor.Components.LoaderSize` enum:
49+
50+
* `Small`
51+
* `Medium`
52+
* `Large`
53+
54+
You can see them in action in the [Loader Overview](https://demos.telerik.com/blazor-ui/loader/overview) Live Demo.
55+
56+
>caption Loader Size
57+
58+
![loader size](images/loader-size.png)
59+
60+
````CSHTML
61+
@foreach (LoaderSize size in Enum.GetValues(typeof(Telerik.Blazor.Components.LoaderSize)))
62+
{
63+
<div style="float: left; margin: 20px;">
64+
@size
65+
<br /><br />
66+
<TelerikLoader Size="@size"></TelerikLoader>
67+
</div>
68+
}
69+
````
70+
71+
## ThemeColor
72+
73+
The color of the animated loading icon is controlled through the `ThemeColor` parameter. You can set it to a member of the `Telerik.Blazor.ThemeColor` enum:
74+
75+
* `Primary`
76+
* `Secondary`
77+
* `Tertiary`
78+
* `Success`
79+
* `Info`
80+
* `Warning`
81+
* `Error`
82+
* `Dark`
83+
* `Light`
84+
* `Inverse`
85+
86+
These predefined options match the main [Telerik Theme]({%slug general-information/themes%}) and you can see that in action in the [Appearance](https://demos.telerik.com/blazor-ui/loader/appearance) Live Demo.
87+
88+
>caption Built-in Theme Colors
89+
90+
![Loader Theme Colors](images/loader-built-in-theme-colors.png)
91+
92+
````CSHTML
93+
@{
94+
var fields = typeof(Telerik.Blazor.ThemeColors)
95+
.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static |
96+
System.Reflection.BindingFlags.FlattenHierarchy)
97+
.Where(fi => fi.IsLiteral && !fi.IsInitOnly).ToList();
98+
foreach (var f in fields)
99+
{
100+
string color = f.GetValue(null).ToString();
101+
<div style="float: left; margin: 20px;">
102+
@color
103+
<br /><br />
104+
<TelerikLoader ThemeColor="@color"></TelerikLoader>
105+
</div>
106+
}
107+
}
108+
````
109+
110+
The `ThemeColor` parameter renders as the `k-loader-<ThemeColor>` CSS class on the wrapping element and you can set it to a custom value to cascade through and set the color to a setting of your own without customizing the entire theme.
111+
112+
>caption Custom loader color without customizing the Telerik Theme
113+
114+
![Custom loader color](images/loader-custom-color.png)
115+
116+
````CSHTML
117+
<style>
118+
.k-loader-custom-color .k-loader-segment::after {
119+
background-color: cyan;
120+
}
121+
</style>
122+
<TelerikLoader ThemeColor="custom-color"></TelerikLoader>
123+
````
124+
125+
## See Also
126+
127+
* [Live Demo: Loader Overview](https://demos.telerik.com/blazor-ui/loader/overview)
128+
* [Live Demo: Loader Appearance](https://demos.telerik.com/blazor-ui/loader/appearance)
8.83 KB
Loading
432 Bytes
Loading
26.9 KB
Loading
3.41 KB
Loading
206 KB
Loading
37 KB
Loading
108 KB
Loading

components/loader/overview.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
title: Overview
3+
page_title: Loader Overview
4+
description: Overview of the Loading indicator for Blazor.
5+
slug: loader-overview
6+
tags: telerik,blazor,loader,overview
7+
published: True
8+
position: 0
9+
---
10+
11+
# Loader Overview
12+
13+
This article provides information about the Blazor Loader component and its core features.
14+
15+
The Loader component provides an animated indicator that you can use to show your users that the app is working on something and they should wait.
16+
17+
## Basic Loading Indicator
18+
19+
To add a Telerik Loader to your Blazor app, use the `<TelerikLoader>` tag and show it when needed by your app. You can also control its [visual appearance]({%slug loader-appearance%}) through parameters.
20+
21+
![](images/loader-overview.gif)
22+
23+
````CSHTML
24+
@if (IsLoading)
25+
{
26+
<TelerikLoader />
27+
}
28+
else
29+
{
30+
@Data
31+
}
32+
33+
@code {
34+
public bool IsLoading { get; set; }
35+
public string Data { get; set; }
36+
37+
protected override async Task OnInitializedAsync()
38+
{
39+
await LoadData();
40+
}
41+
42+
async Task LoadData()
43+
{
44+
IsLoading = true;
45+
await Task.Delay(2000);
46+
IsLoading = false;
47+
Data = "Your data goes here";
48+
}
49+
}
50+
````
51+
52+
## Visible Parameter
53+
54+
You can control whether the indicator is shown through its `Visible` parameter. This can be useful for integrating it into other components and/or for shortening the razor syntax.
55+
56+
>caption Loading indicator in a single click button
57+
58+
![single click button integration](images/loader-visible-parameter-integration.gif)
59+
60+
````CSHTML
61+
@* Toggling the Loader and the Enabled state of the button through a single flag while working lets you implement a single-click button with a loading indicator *@
62+
63+
<TelerikButton Primary="true" OnClick="@GenerateReport" Enabled="@(!IsGeneratingReport)">
64+
<TelerikLoader Visible="@IsGeneratingReport" ThemeColor="light"></TelerikLoader>
65+
@( IsGeneratingReport ? "Generating Report" : "Generate Report" )
66+
</TelerikButton>
67+
68+
@code {
69+
public bool IsGeneratingReport { get; set; }
70+
71+
public async Task GenerateReport()
72+
{
73+
IsGeneratingReport = true;
74+
await Task.Delay(2000); // do actual work here
75+
IsGeneratingReport = false;
76+
}
77+
}
78+
````
79+
80+
## Sample Loading Panel
81+
82+
The `TelerikLoader` component is an animated icon that use can use in your apps. Sometimes, however, you may want to overlay a lot of content with a panel to show the user something is happening with it and to prevent an interaction with it. For example, while fetching data for a grid.
83+
84+
You can devise such a loading panel as needed by your app, and place a Telerik Loading Indicator inside to show the user something is happening. An example follows.
85+
86+
>caption Sample Loading Panel used twice in bootstrap columns
87+
88+
![sample loading panel](images/loading-panel-sample.gif)
89+
90+
````CSHTML
91+
@* for a real case - adjust styling as needed, and extract into a separate component and add the CSS rules to your site stylesheet *@
92+
93+
<div class="container">
94+
<div class="row">
95+
<div class="col">
96+
@if (isLoadingData)
97+
{
98+
@* sample loading panel, styles are at the end *@
99+
<div class="loading-panel-wrapper">
100+
<div class="loading-panel-overlay"></div>
101+
<TelerikLoader Size="@LoaderSize.Large" Type="@LoaderType.ConvergingSpinner" ThemeColor="@ThemeColors.Tertiary" />
102+
</div>
103+
}
104+
<TelerikGrid Data="@GridData" Height="500px" Pageable="true" AutoGenerateColumns="true">
105+
</TelerikGrid>
106+
</div>
107+
<div class="col">
108+
@if (isLoadingData)
109+
{
110+
@* In a real app, you should make this a component and put its styles in the app stylesheet
111+
here we just copy it to showcase the concept of showing a loading sign *@
112+
<div class="loading-panel-wrapper">
113+
<div class="loading-panel-overlay"></div>
114+
<TelerikLoader Size="@LoaderSize.Large" Type="@LoaderType.ConvergingSpinner" ThemeColor="@ThemeColors.Tertiary" />
115+
</div>
116+
}
117+
<p>some other content</p>
118+
<TelerikButton OnClick="@FetchData">Reload data</TelerikButton>
119+
</div>
120+
</div>
121+
</div>
122+
123+
@code {
124+
bool isLoadingData { get; set; }
125+
126+
protected override async Task OnInitializedAsync()
127+
{
128+
await FetchData();
129+
}
130+
131+
async Task FetchData()
132+
{
133+
Console.WriteLine("called");
134+
isLoadingData = true;
135+
await Task.Delay(2000); // simulate long operation
136+
GridData = Enumerable.Range(1, 30).Select(x => new SampleData
137+
{
138+
Id = x,
139+
Name = "name " + x,
140+
Team = "team " + x % 5,
141+
HireDate = DateTime.Now.AddDays(-x).Date
142+
});
143+
isLoadingData = false;
144+
}
145+
146+
public IEnumerable<SampleData> GridData { get; set; } = Enumerable.Empty<SampleData>();
147+
public class SampleData
148+
{
149+
public int Id { get; set; }
150+
public string Name { get; set; }
151+
public string Team { get; set; }
152+
public DateTime HireDate { get; set; }
153+
}
154+
}
155+
156+
<style>
157+
.loading-panel-wrapper {
158+
/* size and appearance that try to match its container with as little CSS as possible,
159+
you can alter them as necessary for your use case and as per your preferences
160+
*/
161+
width: 100%;
162+
height: 100%;
163+
min-height: 200px;
164+
position: absolute;
165+
z-index: 123456;
166+
/* one way center the loading indicator inside */
167+
display: flex;
168+
justify-content: center;
169+
align-items: center;
170+
}
171+
172+
.loading-panel-wrapper .loading-panel-overlay {
173+
background: gray;
174+
position: absolute;
175+
width: 100%;
176+
height: 100%;
177+
opacity: 0.5;
178+
}
179+
</style>
180+
````
181+
182+
## See Also
183+
184+
* [Live Demo: Loader](https://demos.telerik.com/blazor-ui/loader/overview)
185+
* [Appearance Settings]({%slug loader-appearance%})
186+
* [API Reference](https://docs.telerik.com/blazor-ui/api/Telerik.Blazor.Components.TelerikLoader)
187+

0 commit comments

Comments
 (0)