Skip to content

Instantly share code, notes, and snippets.

@xakpc
Created October 13, 2020 14:31
Show Gist options
  • Save xakpc/5edb41886f12b695edfc694a54280360 to your computer and use it in GitHub Desktop.
Save xakpc/5edb41886f12b695edfc694a54280360 to your computer and use it in GitHub Desktop.
Blazor Essentials
@using System.Windows.Input
<button type="button" class="@($"btn {Class}")" @onclick="Callback" @attributes="InputAttributes">@ChildContent</button>
@code {
[Parameter]
public ICommand Command { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public string Class { get; set; } = "btn-primary";
[Parameter]
public object Parameter { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string, object> InputAttributes { get; set; } = new Dictionary<string, object>();
private void Callback()
{
Command?.Execute(Parameter);
}
}
<div class="progress @Class" style="@(Height == null ? "" : $"height: {Height}px")">
<div class="progress-bar" role="progressbar" style="@($"width: {Progress}%")" aria-valuenow="@Progress" aria-valuemin="0" aria-valuemax="100">@ChildContent</div>
</div>
@code {
[Parameter]
public string Class {get;set;}
[Parameter]
public int Progress {get;set;}
[Parameter]
public int? Height {get;set;}
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string, object> InputAttributes { get; set; } = new Dictionary<string, object>();
}
@using System.Windows.Input
<div class="btn-group" role="group" aria-label="Basic example">
<CommandButton class="btn-sm btn-primary" Command="EditCommand" Parameter="Parameter">Edit</CommandButton>
<CommandButton class="btn-sm btn-danger" Command="DeleteCommand" Parameter="Parameter">Delete</CommandButton>
</div>
@code {
[Parameter]
public ICommand EditCommand { get; set; }
[Parameter]
public ICommand DeleteCommand { get; set; }
[Parameter]
public object Parameter { get; set; }
}
<div class="spinner-border @Class" role="status">
<span class="sr-only">@Text</span>
</div>
@code {
[Parameter]
public string Class { get; set; }
[Parameter]
public string Text { get; set; } = "Loading...";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment