diff --git a/src/Connected.Components.Showcase.Runner/Pages/Index.razor b/src/Connected.Components.Showcase.Runner/Pages/Index.razor index 883720b..7df32d4 100644 --- a/src/Connected.Components.Showcase.Runner/Pages/Index.razor +++ b/src/Connected.Components.Showcase.Runner/Pages/Index.razor @@ -6,14 +6,21 @@

SelectedValue: @SelectedValue.ToString()

- - - - - - - - + + + + + + + + + + + + + + + @code { int SelectedValue; diff --git a/src/Connected.Components/Components/Radio.razor b/src/Connected.Components/Components/Radio.razor new file mode 100644 index 0000000..18e385e --- /dev/null +++ b/src/Connected.Components/Components/Radio.razor @@ -0,0 +1,8 @@ +@using Connected.Models; + +@inherits InputBase; + +
+ + +
\ No newline at end of file diff --git a/src/Connected.Components/Components/Radio.razor.cs b/src/Connected.Components/Components/Radio.razor.cs new file mode 100644 index 0000000..a86a940 --- /dev/null +++ b/src/Connected.Components/Components/Radio.razor.cs @@ -0,0 +1,31 @@ +using Connected.Models; +using Microsoft.AspNetCore.Components; + +namespace Connected.Components; +public partial class Radio: InputBase +{ + [CascadingParameter] + public RadioGroup? ParentRadioGroup { get; set; } + + [Parameter] + public bool Checked { get; set; } = false; + + [Parameter, EditorRequired] + public string Id { get; set; } + + [Parameter] + public EventCallback CheckedChange { get; set; } + public async Task OnChange(ChangeEventArgs args) + { + Checked = (bool)args.Value; + CheckedChange.InvokeAsync(Checked); + } + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + if (ParentRadioGroup.Disabled) Disabled = true; + if (!InputAttributes.ContainsKey("disabled")) + InputAttributes.Add("disabled", Disabled); + } +} diff --git a/src/Connected.Components/Components/RadioGroup.razor b/src/Connected.Components/Components/RadioGroup.razor new file mode 100644 index 0000000..b842c61 --- /dev/null +++ b/src/Connected.Components/Components/RadioGroup.razor @@ -0,0 +1,15 @@ +@using Connected.Models; + +@inherits InputBase; + + +
+ @if (!string.IsNullOrEmpty(Name)) + { +
@Name
+ } +
+ @ChildContent +
+
+
\ No newline at end of file diff --git a/src/Connected.Components/Components/RadioGroup.razor.cs b/src/Connected.Components/Components/RadioGroup.razor.cs new file mode 100644 index 0000000..7b07360 --- /dev/null +++ b/src/Connected.Components/Components/RadioGroup.razor.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Components; + +namespace Connected.Components; +public partial class RadioGroup +{ + [Parameter, EditorRequired] + public string Name { get; set; } + + [Parameter] + public RenderFragment ChildContent { get; set; } + +}