forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.razor
More file actions
30 lines (25 loc) · 1.08 KB
/
Copy pathButton.razor
File metadata and controls
30 lines (25 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@namespace ContosoSnsWebApp.Components
<button class="btn @ButtonClass @SizeClass @(Disabled ? "disabled" : "") @CssClass"
type="@Type"
disabled="@Disabled"
@onclick="OnClick">
@ChildContent
</button>
@code {
[Parameter] public RenderFragment? ChildContent { get; set; }
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
[Parameter] public string Variant { get; set; } = "primary"; // primary, secondary, outline, danger, etc.
[Parameter] public bool Small { get; set; }
[Parameter] public bool Disabled { get; set; }
[Parameter] public string Type { get; set; } = "button"; // button, submit, reset
[Parameter] public string? CssClass { get; set; } // Allow additional custom classes
private string ButtonClass => Variant switch
{
"primary" => "btn-primary",
"secondary" => "btn-secondary",
"outline" => "btn-outline-primary", // Example mapping for outline
"danger" => "btn-danger",
_ => "btn-primary" // Default
};
private string SizeClass => Small ? "btn-sm" : "";
}