Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated .net 8 example to match .net 6 #39

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/BlazorAutoNet8/BlazorAutoNet8.Client/CodeExample.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@inject IJSRuntime JSRuntime
@rendermode RenderMode.InteractiveWebAssembly

<pre>
<code class="@($"language-{Language}")" data-prismjs-copy="Copy">
@Code
</code>
</pre>

@code {
[Parameter, EditorRequired] public string Code { get; set; } = default!;
[Parameter] public string Language { get; set; } = "razor";

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);

if (firstRender)
{
await JSRuntime.InvokeVoidAsync("Prism.highlightAll");
}
}
}
30 changes: 30 additions & 0 deletions src/BlazorAutoNet8/BlazorAutoNet8.Client/InteractiveQRCode.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@rendermode RenderMode.InteractiveWebAssembly

<button @onclick="ChangeData" class="mb-4 align-self-start">
Change!
</button>
<QRCode Data="@Data" Size="150px" />

<CodeExample Code="@(@"<button @onclick=""ChangeData"">
Change!
</button>

<QRCode Data=""@Data"" Size=""150px"" />

@code {
string Data { get; set; } = ""This is a QR code of size 150px by 150px"";

void ChangeData()
{
Data = Guid.NewGuid().ToString();
}
}")" />

@code {
string Data { get; set; } = "This is a QR code of size 150px by 150px";

void ChangeData()
{
Data = Guid.NewGuid().ToString();
}
}
27 changes: 0 additions & 27 deletions src/BlazorAutoNet8/BlazorAutoNet8.Client/Pages/Counter.razor

This file was deleted.

123 changes: 123 additions & 0 deletions src/BlazorAutoNet8/BlazorAutoNet8.Client/Pages/Playground.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
@page "/playground"
@rendermode RenderMode.InteractiveWebAssembly

<PageTitle>Playground | PinguApps.Blazor.QRCode</PageTitle>

<h3>Playground</h3>

<p>
Changing the QR code requires an interactive rendering mode, and so this page is rendered using WASM.
</p>

<div class="card p-3 line-numbers">
<QRCode Data="@Data" ErrorCorrection="ErrorCorrection" Image="@Image" Size="@Size" PaddingCells="PaddingCells" ForeColor="@ForeColor"
BackColor="@BackColor" AriaDescription="@AriaDescription" Class="@Class" Id="@Id" />

<EditForm Model="SettingsModel" OnValidSubmit="UpdateQRCode">
<div class="row">
<div class="col-lg-6">
<div class="mb-3">
<label for="data" class="form-label">Data</label>
<InputTextArea @bind-Value="SettingsModel.Data" id="data" class="form-control" />
</div>
<div class="mb-3">
<InputRadioGroup @bind-Value="SettingsModel.ErrorCorrection" Name="ec">
@foreach (var ecValue in Enum.GetValues(typeof(ErrorCorrection)))
{
<div class="form-check form-check-inline">
<InputRadio Value="ecValue" Name="ec" class="form-check-input" id="@($"ErrorCorrectionValue{ecValue}")" />
<label class="form-check-label" for="@($"ErrorCorrectionValue{ecValue}")">@ecValue.ToString()</label>
</div>
}
</InputRadioGroup>
</div>
<div class="mb-3">
<label for="image" class="form-label">Image</label>
<InputText @bind-Value="SettingsModel.Image" id="image" class="form-control" />
</div>
<div class="mb-3">
<label for="size" class="form-label">Size</label>
<InputText @bind-Value="SettingsModel.Size" id="size" class="form-control" />
</div>
<div class="mb-3">
<label for="padding" class="form-label">Padding</label>
<InputNumber @bind-Value="SettingsModel.PaddingCells" id="padding" class="form-control" />
</div>
</div>
<div class="col-lg-6">
<div class="mb-3">
<label for="fore-color" class="form-label">Fore Color</label>
<InputText @bind-Value="SettingsModel.ForeColor" id="fore-color" class="form-control" />
</div>
<div class="mb-3">
<label for="back-color" class="form-label">Back Color</label>
<InputText @bind-Value="SettingsModel.BackColor" id="back-color" class="form-control" />
</div>
<div class="mb-3">
<label for="aria-description" class="form-label">Aria Description</label>
<InputText @bind-Value="SettingsModel.AriaDescription" id="aria-description" class="form-control" />
</div>
<div class="mb-3">
<label for="class" class="form-label">Class</label>
<InputText @bind-Value="SettingsModel.Class" id="class" class="form-control" />
</div>
<div class="mb-3">
<label for="id" class="form-label">Id</label>
<InputText @bind-Value="SettingsModel.Id" id="id" class="form-control" />
</div>
</div>
<button type="submit">Update</button>
</div>
</EditForm>

</div>

@code {
Settings SettingsModel { get; set; } = new();

string Data { get; set; } = default!;
ErrorCorrection ErrorCorrection { get; set; }
string? Image { get; set; }
string Size { get; set; } = default!;
int PaddingCells { get; set; }
string ForeColor { get; set; } = default!;
string BackColor { get; set; } = default!;
string AriaDescription { get; set; } = default!;
string? Class { get; set; }
string? Id { get; set; }

protected override void OnInitialized()
{
base.OnInitialized();

UpdateQRCode();
}

void UpdateQRCode()
{
Data = SettingsModel.Data;
ErrorCorrection = SettingsModel.ErrorCorrection;
Image = SettingsModel.Image;
Size = SettingsModel.Size;
PaddingCells = SettingsModel.PaddingCells;
ForeColor = SettingsModel.ForeColor;
BackColor = SettingsModel.BackColor;
AriaDescription = SettingsModel.AriaDescription;
Class = SettingsModel.Class;
Id = SettingsModel.Id;
}

public class Settings
{
public string Data { get; set; } = "Welcome to the playground, where you are able to customise the QR code generated on this page to test the true capabilities of the library.";
public ErrorCorrection ErrorCorrection { get; set; } = ErrorCorrection.Quartile;
public string? Image { get; set; }
public string Size { get; set; } = "200px";
public int PaddingCells { get; set; } = 1;
public string ForeColor { get; set; } = "#000000";
public string BackColor { get; set; } = "#ffffff";
public string AriaDescription { get; set; } = "QR Code";
public string? Class { get; set; }
public string? Id { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/BlazorAutoNet8/BlazorAutoNet8/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="BlazorAutoNet8.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-coy.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet" />
<HeadOutlet />
</head>

<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/show-language/prism-show-language.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/inline-color/prism-inline-color.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,35 @@

<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
<h3 class="mt-2">
.Net 8.0 Static SSR & WASM
</h3>
</div>
<div class="badge-row">
<a href="https://www.nuget.org/packages/PinguApps.Blazor.QRCode" target="_blank">
<img src="https://img.shields.io/nuget/v/PinguApps.Blazor.QRCode?logo=nuget&style=for-the-badge" />
</a>
<a href="https://www.nuget.org/packages/PinguApps.Blazor.QRCode" target="_blank">
<img src="https://img.shields.io/nuget/dt/PinguApps.Blazor.QRCode?style=for-the-badge&logo=nuget" />
</a>
<a>
<img src="https://img.shields.io/badge/License-MIT-44cc11?style=for-the-badge" />
</a>
<a href="https://github.com/PinguApps/Blazor.QRCode" target="_blank">
<img src="https://img.shields.io/github/stars/PinguApps/Blazor.QRCode?style=for-the-badge&logo=github" />
</a>
<a href="https://github.com/PinguApps/Blazor.QRCode" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/PinguApps/Blazor.QRCode/main.yml?style=for-the-badge&logo=github" />
</a>

<a href="https://github.com/PinguApps/Blazor.QRCode" target="_blank">
<img src="https://img.shields.io/badge/Github-555?style=for-the-badge&logo=github" />
</a>
<a href="https://www.nuget.org/packages/PinguApps.Blazor.QRCode" target="_blank">
<img src="https://img.shields.io/badge/Nuget-555?style=for-the-badge&logo=nuget" />
</a>
<hr />
</div>
<article class="content px-4">
@Body
</article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ main {
.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
justify-content: flex-start;
height: 3.5rem;
display: flex;
align-items: center;
Expand Down Expand Up @@ -94,3 +94,18 @@ main {
right: 0.75rem;
top: 0.5rem;
}


.badge-row {
position: sticky;
top: 3.5rem;
z-index: 1;
padding: 1rem 1.5rem;
background: rgb(247, 247, 247);
background: linear-gradient(0deg, rgba(247, 247, 247, 1) 0%, rgba(224, 224, 224, 1) 100%);
border-bottom: 1px solid #d6d5d5;
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
row-gap: 0.5rem;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">BlazorAutoNet8</a>
<a class="navbar-brand" href="">PinguApps QRCode</a>
</div>
</div>

Expand All @@ -15,14 +15,14 @@
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
<NavLink class="nav-link" href="./playground">
<span class="bi bi-sliders" aria-hidden="true"></span> Playground
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
<NavLink class="nav-link" href="./docs">
<span class="bi bi-file-text-fill" aria-hidden="true"></span> Docs
</NavLink>
</div>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}

.bi-sliders {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M11.5 2a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M9.05 3a2.5 2.5 0 0 1 4.9 0H16v1h-2.05a2.5 2.5 0 0 1-4.9 0H0V3zM4.5 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M2.05 8a2.5 2.5 0 0 1 4.9 0H16v1H6.95a2.5 2.5 0 0 1-4.9 0H0V8zm9.45 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m-2.45 1a2.5 2.5 0 0 1 4.9 0H16v1h-2.05a2.5 2.5 0 0 1-4.9 0H0v-1z'/%3E%3C/svg%3E");
}

.bi-file-text-fill {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M12 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2M5 4h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1 0-1m-.5 2.5A.5.5 0 0 1 5 6h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5M5 8h6a.5.5 0 0 1 0 1H5a.5.5 0 0 1 0-1m0 2h3a.5.5 0 0 1 0 1H5a.5.5 0 0 1 0-1'/%3E%3C/svg%3E");
}

.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
Expand Down
Loading
Loading