parent
53d57c982b
commit
b1cc8d178c
@ -0,0 +1,9 @@
|
|||||||
|
<h3>Card</h3>
|
||||||
|
@typeparam TItem
|
||||||
|
|
||||||
|
<div class="card text-center">
|
||||||
|
@CardHeader(Item)
|
||||||
|
@CardBody(Item)
|
||||||
|
@CardFooter
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
<div class="item"
|
||||||
|
ondragover="event.preventDefault();"
|
||||||
|
draggable="true"
|
||||||
|
@ondragstart="@OnDragStart"
|
||||||
|
@ondrop="@OnDrop"
|
||||||
|
@ondragenter="@OnDragEnter"
|
||||||
|
@ondragleave="@OnDragLeave">
|
||||||
|
|
||||||
|
@if (Item != null)
|
||||||
|
{
|
||||||
|
@Item.DisplayName
|
||||||
|
}
|
||||||
|
</div>
|
@ -0,0 +1,14 @@
|
|||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public MyRootComponent RootComponent { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
<div style="border: 1px solid black; padding: 10px;">
|
||||||
|
<strong>MyFirstChildComponent - @RootComponent.Text</strong>
|
||||||
|
<div>
|
||||||
|
@ChildContent
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,16 @@
|
|||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Text { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
<div style="border: 1px solid black; padding: 10px;">
|
||||||
|
<strong>MyRootComponent - @Text</strong>
|
||||||
|
<div>
|
||||||
|
<CascadingValue Value="@this">
|
||||||
|
@ChildContent
|
||||||
|
</CascadingValue>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,14 @@
|
|||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public MyRootComponent RootComponent { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
<div style="border: 1px solid black; padding: 10px;">
|
||||||
|
<strong>MySecondChildComponent - @RootComponent.Text</strong>
|
||||||
|
<div>
|
||||||
|
@ChildContent
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,11 @@
|
|||||||
|
@typeparam TItem
|
||||||
|
|
||||||
|
<div>
|
||||||
|
@if ((Items?.Count ?? 0) != 0)
|
||||||
|
{
|
||||||
|
@foreach (var item in Items)
|
||||||
|
{
|
||||||
|
@ShowTemplate(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
@ -0,0 +1,7 @@
|
|||||||
|
<h3>TestRenderFragment</h3>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
<div class="simple-form">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Are you sure you want to delete @item.DisplayName ?
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button @onclick="ConfirmDelete" class="btn btn-primary">Delete</button>
|
||||||
|
|
||||||
|
<button @onclick="Cancel" class="btn btn-secondary">Cancel</button>
|
||||||
|
</div>
|
@ -1,9 +1,48 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
@using System.Globalization
|
||||||
|
@using BlazorApp.Components
|
||||||
|
|
||||||
<PageTitle>Index</PageTitle>
|
<PageTitle>Index</PageTitle>
|
||||||
|
|
||||||
<h1>Hello, world!</h1>
|
<h1>Hello, world!</h1>
|
||||||
|
|
||||||
Welcome to your new app.
|
<!--
|
||||||
|
<ShowItems Items="Cakes">
|
||||||
|
<ShowTemplate Context="CakeContext">
|
||||||
|
<div class="card text-center">
|
||||||
|
<div class="card-header">
|
||||||
|
Cake Token Id - @CakeContext.Id
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">@CakeContext.Name</h5>
|
||||||
|
<p class="card-text">Price $@CakeContext.Cost</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-muted">
|
||||||
|
Click Here
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ShowTemplate>
|
||||||
|
</ShowItems>
|
||||||
|
|
||||||
<SurveyPrompt Title="How is Blazor working for you?" />
|
|
||||||
|
<MyRootComponent Text="RootComponentText">
|
||||||
|
<MyFirstChildComponent>
|
||||||
|
<MySecondChildComponent>
|
||||||
|
<div>MySecondChildComponent - Content</div>
|
||||||
|
</MySecondChildComponent>
|
||||||
|
</MyFirstChildComponent>
|
||||||
|
</MyRootComponent>
|
||||||
|
|
||||||
|
|
||||||
|
<TestRenderFragment>
|
||||||
|
<div>Content of my TestRenderFragment</div>
|
||||||
|
</TestRenderFragment>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture
|
||||||
|
</p>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Crafting Items="Items" Recipes="Recipes" />
|
||||||
|
</div>
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
@page "/pets1"
|
||||||
|
|
||||||
|
<h1>Pets</h1>
|
||||||
|
|
||||||
|
<TableTemplate Items="pets" Context="pet">
|
||||||
|
<TableHeader>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</TableHeader>
|
||||||
|
<RowTemplate>
|
||||||
|
<td>@pet.PetId</td>
|
||||||
|
<td>@pet.Name</td>
|
||||||
|
</RowTemplate>
|
||||||
|
</TableTemplate>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Pet> pets = new()
|
||||||
|
{
|
||||||
|
new Pet { PetId = 2, Name = "Mr. Bigglesworth" },
|
||||||
|
new Pet { PetId = 4, Name = "Salem Saberhagen" },
|
||||||
|
new Pet { PetId = 7, Name = "K-9" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private class Pet
|
||||||
|
{
|
||||||
|
public int PetId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
@page "/pets2"
|
||||||
|
|
||||||
|
<h1>Pets</h1>
|
||||||
|
|
||||||
|
<TableTemplate Items="pets">
|
||||||
|
<TableHeader>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</TableHeader>
|
||||||
|
<RowTemplate Context="pet">
|
||||||
|
<td>@pet.PetId</td>
|
||||||
|
<td>@pet.Name</td>
|
||||||
|
</RowTemplate>
|
||||||
|
</TableTemplate>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Pet> pets = new()
|
||||||
|
{
|
||||||
|
new Pet { PetId = 2, Name = "Mr. Bigglesworth" },
|
||||||
|
new Pet { PetId = 4, Name = "Salem Saberhagen" },
|
||||||
|
new Pet { PetId = 7, Name = "K-9" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private class Pet
|
||||||
|
{
|
||||||
|
public int PetId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
@page "/pets3"
|
||||||
|
|
||||||
|
<h1>Pets</h1>
|
||||||
|
|
||||||
|
<TableTemplate Items="pets">
|
||||||
|
<TableHeader>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</TableHeader>
|
||||||
|
<RowTemplate>
|
||||||
|
<td>@context.PetId</td>
|
||||||
|
<td>@context.Name</td>
|
||||||
|
</RowTemplate>
|
||||||
|
</TableTemplate>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Pet> pets = new()
|
||||||
|
{
|
||||||
|
new Pet { PetId = 2, Name = "Mr. Bigglesworth" },
|
||||||
|
new Pet { PetId = 4, Name = "Salem Saberhagen" },
|
||||||
|
new Pet { PetId = 7, Name = "K-9" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private class Pet
|
||||||
|
{
|
||||||
|
public int PetId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
@page "/pets4"
|
||||||
|
|
||||||
|
<h1>Pets</h1>
|
||||||
|
|
||||||
|
<TableTemplate Items="pets" TItem="Pet">
|
||||||
|
<TableHeader>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</TableHeader>
|
||||||
|
<RowTemplate>
|
||||||
|
<td>@context.PetId</td>
|
||||||
|
<td>@context.Name</td>
|
||||||
|
</RowTemplate>
|
||||||
|
</TableTemplate>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Pet> pets = new()
|
||||||
|
{
|
||||||
|
new Pet { PetId = 2, Name = "Mr. Bigglesworth" },
|
||||||
|
new Pet { PetId = 4, Name = "Salem Saberhagen" },
|
||||||
|
new Pet { PetId = 7, Name = "K-9" }
|
||||||
|
};
|
||||||
|
|
||||||
|
private class Pet
|
||||||
|
{
|
||||||
|
public int PetId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace BlazorApp.Resources {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// This class was generated by MSBuild using the GenerateResource task.
|
||||||
|
/// To add or remove a member, edit your .resx file then rerun MSBuild.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Build.Tasks.StronglyTypedResourceBuilder", "15.1.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Pages_List {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Pages_List() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BlazorApp.Resources.Pages.List", typeof(Pages_List).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
|
|
@ -0,0 +1,43 @@
|
|||||||
|
@using System.Globalization
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
Select your locale:
|
||||||
|
<select @bind="Culture">
|
||||||
|
@foreach (var culture in supportedCultures)
|
||||||
|
{
|
||||||
|
<option value="@culture">@culture.DisplayName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private CultureInfo[] supportedCultures = new[]
|
||||||
|
{
|
||||||
|
new CultureInfo("en-US"),
|
||||||
|
new CultureInfo("fr-FR")
|
||||||
|
};
|
||||||
|
|
||||||
|
private CultureInfo Culture
|
||||||
|
{
|
||||||
|
get => CultureInfo.CurrentCulture;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (CultureInfo.CurrentUICulture == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var culture = value.Name.ToLower(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
var uri = new Uri(this.NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
|
||||||
|
var query = $"?culture={Uri.EscapeDataString(culture)}&" + $"redirectUri={Uri.EscapeDataString(uri)}";
|
||||||
|
|
||||||
|
// Redirect the user to the culture controller to set the cookie
|
||||||
|
this.NavigationManager.NavigateTo("/Culture/SetCulture" + query, forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
@typeparam TItem
|
||||||
|
@using System.Diagnostics.CodeAnalysis
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>@TableHeader</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Items)
|
||||||
|
{
|
||||||
|
if (RowTemplate is not null)
|
||||||
|
{
|
||||||
|
<tr>@RowTemplate(item)</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment? TableHeader { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment<TItem>? RowTemplate { get; set; }
|
||||||
|
|
||||||
|
[Parameter, AllowNull]
|
||||||
|
public IReadOnlyList<TItem> Items { get; set; }
|
||||||
|
}
|
After Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in new issue