|
| 1 | +@using BlazorBootstrap.Demo.RCL.Components.Pages.Demos.Preload |
| 2 | + |
| 3 | +@attribute [Route(pageUrl)] |
| 4 | +@layout DemosMainLayout |
| 5 | + |
| 6 | +<DemosPageHeadSection PageUrl="@pageUrl" |
| 7 | + PageTitle="@pageTitle" |
| 8 | + PageDescription="@pageDescription" |
| 9 | + MetaTitle="@metaTitle" |
| 10 | + MetaDescription="@metaDescription" |
| 11 | + ImageUrl="@imageUrl" /> |
| 12 | + |
| 13 | +<DocsLink Href="@DemoRouteConstants.Docs_URL_PreloadService" /> |
| 14 | + |
| 15 | +<div class="mt-3">Use Blazor PreloadService to show and hide a loading overlay from anywhere in your app.</div> |
| 16 | + |
| 17 | +<Section Size="HeadingSize.H2" Name="How it works" PageUrl="@pageUrl" Link="how-it-works"> |
| 18 | + <div class="mb-3"> |
| 19 | + <code>PreloadService</code> shows the <code>Preload</code> overlay placed in your layout while work runs, then hides it. |
| 20 | + <br /> |
| 21 | + <strong>How to use:</strong> |
| 22 | + <div class="content mb-2"> |
| 23 | + <ol> |
| 24 | + <li>Inject <code>PreloadService</code> in the page or component that starts the work.</li> |
| 25 | + <li>Call <code>Show()</code> before the work starts. Pass a <code>SpinnerColor</code> and a loading text to change how the overlay looks.</li> |
| 26 | + <li>Call <code>Hide()</code> in a <code>finally</code> block, so the overlay closes even when the work fails.</li> |
| 27 | + </ol> |
| 28 | + </div> |
| 29 | + Each button shows the overlay for 2 seconds, standing in for a call to a service or API. |
| 30 | + </div> |
| 31 | + <Demo Type="typeof(PreloadService_Demo_01_Show_And_Hide_From_Code)" /> |
| 32 | +</Section> |
| 33 | + |
| 34 | +<Section Size="HeadingSize.H2" Name="How to setup" PageUrl="@pageUrl" Link="how-to-setup"> |
| 35 | + <div class="mb-3">1. Add the <code>Preload</code> component in <code>MainLayout.razor</code> page as shown below.</div> |
| 36 | + <Demo Type="typeof(Preload_Demo_01_Global_Preload_For_Application_A)" ShowCodeOnly="true" /> |
| 37 | + |
| 38 | + <div class="mb-3">2. Inject <code>PreloadService</code>, then call the <code>Show()</code> and <code>Hide()</code> methods as shown below.</div> |
| 39 | + <Demo Type="typeof(Preload_Demo_01_Global_Preload_For_Application_B)" ShowCodeOnly="true" /> |
| 40 | +</Section> |
| 41 | + |
| 42 | +@code { |
| 43 | + private const string pageUrl = DemoRouteConstants.Demos_URL_PreloadService; |
| 44 | + private const string pageTitle = "Blazor Preload Service"; |
| 45 | + private const string pageDescription = "Use Blazor Bootstrap preload service to show and hide a loading overlay from anywhere in your app."; |
| 46 | + private const string metaTitle = "Blazor Preload Service"; |
| 47 | + private const string metaDescription = "Use Blazor Bootstrap preload service to show and hide a loading overlay from anywhere in your app."; |
| 48 | + private const string imageUrl = DemoScreenshotSrcConstants.Demos_URL_PreloadService; |
| 49 | +} |
0 commit comments