Sparc.UI
6.3.0
dotnet add package Sparc.UI --version 6.3.0
NuGet\Install-Package Sparc.UI -Version 6.3.0
<PackageReference Include="Sparc.UI" Version="6.3.0" />
paket add Sparc.UI --version 6.3.0
#r "nuget: Sparc.UI, 6.3.0"
// Install Sparc.UI as a Cake Addin #addin nuget:?package=Sparc.UI&version=6.3.0 // Install Sparc.UI as a Cake Tool #tool nuget:?package=Sparc.UI&version=6.3.0
Sparc.UI
The Sparc.UI
library is the main framework library for the UI Project in your Sparc solution.
What is a UI Project?
A UI Project is where you put all shared Blazor Pages and Components for your Web and MAUI projects to use.
If your project is multi-platform (i.e. web + desktop and/or mobile), this project should exist so that you are only writing the UI codebase once and sharing it across every platform.
All UI responsiveness is handled through CSS media queries, as a mobile web application would handle it.
In short: Write your UI as a mobile-responsive web application, and you get Desktop & Mobile apps "for free".
Get Started with a UI Project
- Add a Razor Class Library project to your solution (preferably called [YourProject].UI).
- Reference your UI Project from your Web and MAUI Projects (as a Project Reference).
- Write your user interface within your UI Project as Blazor Pages and Components.
Connect your UI to your Features
One of the best aspects of Sparc.Kernel is its ability to auto-generate a client method for every Feature you write, with zero configuration.
Every time your solution is built, Sparc.Kernel automatically creates the following, for every feature:
- An entire API surface for all of your Features (eg.
/api/DoSomething
) - An auto-generated client class with a method for each Feature, which automatically calls the API at the correct URL and with the correct authentication headers:
public async Task<GetOrderResponse> DoSomethingAsync(GetOrderRequest request);
To set this up, you need to point your UI Project to the swagger.json
file in your Features Project, and configure it as an OpenAPI reference:
- Right-click your UI Project → Add Connected Service → Add Service Reference → OpenAPI
- Choose the "File" Radio button, and navigate and select the
swagger.json
file generated inside your Features Project. - Type in any namespace and class name you desire for your client-side Api class.
- Click OK. The Api class will now be generated for you, and will regenerate automatically on every new build.
If you ever need to manually regenerate this class, simply open the Connected Service → Regenerate.
To use this Api class in your Blazor components:
- Inject the Api class into your app (preferably in the
_Imports.razor
global file):@inject PointOfSaleApi Api
- Use the Api class throughout your application.
var orders = await Api.GetAllOrdersAsync();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Components (>= 6.0.4)
- Microsoft.AspNetCore.Components.Authorization (>= 6.0.4)
- Microsoft.AspNetCore.Components.Web (>= 6.0.4)
- Newtonsoft.Json (>= 13.0.1)
- NSwag.ApiDescription.Client (>= 13.15.10)
- Sparc.Core (>= 6.3.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Sparc.UI:
Package | Downloads |
---|---|
Sparc.Platforms.Web
Web platform Sparc package |
|
Sparc.Platforms.Maui
MAUI Sparc package |
GitHub repositories
This package is not used by any popular GitHub repositories.