From fb85499a6ef3b862e8fe2ffd24b268a3fef1860a Mon Sep 17 00:00:00 2001 From: markosteger Date: Fri, 10 Mar 2023 11:25:00 +0100 Subject: [PATCH 1/3] NumberStepper - simple working concept --- .../Pages/Index.razor | 6 ++ .../Components/Grid.razor.cs | 1 - .../Components/NumberStepper.razor | 17 ++++ .../Components/NumberStepper.razor.cs | 98 +++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 src/Connected.Components/Components/NumberStepper.razor create mode 100644 src/Connected.Components/Components/NumberStepper.razor.cs diff --git a/src/Connected.Components.Showcase.Runner/Pages/Index.razor b/src/Connected.Components.Showcase.Runner/Pages/Index.razor index 9ed0882..3a7dd11 100644 --- a/src/Connected.Components.Showcase.Runner/Pages/Index.razor +++ b/src/Connected.Components.Showcase.Runner/Pages/Index.razor @@ -42,8 +42,14 @@ CloseOnDateSelect=true + +

Selected date is @date.ToString()

+

Number is: @number.ToString()

+ @code { DateTime date = DateTime.Today; + + int number = 0; } \ No newline at end of file diff --git a/src/Connected.Components/Components/Grid.razor.cs b/src/Connected.Components/Components/Grid.razor.cs index 563db2a..fe820dd 100644 --- a/src/Connected.Components/Components/Grid.razor.cs +++ b/src/Connected.Components/Components/Grid.razor.cs @@ -37,5 +37,4 @@ public partial class Grid: ComponentBase .Build(); } } - } diff --git a/src/Connected.Components/Components/NumberStepper.razor b/src/Connected.Components/Components/NumberStepper.razor new file mode 100644 index 0000000..042ae57 --- /dev/null +++ b/src/Connected.Components/Components/NumberStepper.razor @@ -0,0 +1,17 @@ +@typeparam NumberType + +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/Connected.Components/Components/NumberStepper.razor.cs b/src/Connected.Components/Components/NumberStepper.razor.cs new file mode 100644 index 0000000..55bfb42 --- /dev/null +++ b/src/Connected.Components/Components/NumberStepper.razor.cs @@ -0,0 +1,98 @@ +using Connected.Utilities; +using Microsoft.AspNetCore.Components; +using System.Numerics; + +namespace Connected.Components +{ + public partial class NumberStepper where NumberType : INumber + + { + [Parameter] + public string Class { get; set; } = string.Empty; + + /// + /// Increase 'Value' for the 'Step' + /// + /// 'Value' increased for the 'Step' parameter + private async Task StepUp() + { + try + { + var num = Helper.ConvertToType(Value); + + num += Step; + + Value=Helper.ConvertToType(num); + + } + catch + { + Value = default; + } + + await ValueChanged.InvokeAsync(Value); + } + + /// + /// Decrease 'Value' for the 'Step' + /// + /// 'Value' decreased for the 'Step' parameter + private async Task StepDown() + { + try + { + var num = Helper.ConvertToType(Value); + + num -= Step; + + Value = Helper.ConvertToType(num); + + } + catch + { + Value = default; + } + + await ValueChanged.InvokeAsync(Value); + } + + [Parameter] + public NumberType? Value + { + get + { + + try + { + return Helper.ConvertToType(_value); + } + catch + { + return default; + } + } + set + { + _value = Helper.ConvertToType(value); + } + } + private double _value { get; set; } = 0; + + /// + /// Value change event + /// + [Parameter] + public EventCallback ValueChanged { get; set; } + + [Parameter] + public double Step { get; set; } = 1; + + public async Task Change(ChangeEventArgs args) + { + if (args.Value is not null) + Value = (Helper.ConvertToType(args.Value)); + + await ValueChanged.InvokeAsync(Value); + } + } +} \ No newline at end of file From b51801b3baaeff7a7feea75e8af1979c78db4186 Mon Sep 17 00:00:00 2001 From: markosteger Date: Fri, 10 Mar 2023 14:18:02 +0100 Subject: [PATCH 2/3] FormWizzard - footer buttons spacing fix --- src/Connected.Components/Components/FormWizard.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Connected.Components/Components/FormWizard.razor b/src/Connected.Components/Components/FormWizard.razor index 661bed1..ecb2844 100644 --- a/src/Connected.Components/Components/FormWizard.razor +++ b/src/Connected.Components/Components/FormWizard.razor @@ -5,9 +5,9 @@ @ChildContent -
+
-
+
From 9806a21f48c56b1ede4ea1e474d471d43b4bacc3 Mon Sep 17 00:00:00 2001 From: markosteger Date: Thu, 16 Mar 2023 14:09:47 +0100 Subject: [PATCH 3/3] Datepicker fix, NumberInput fix, ToggleGlyphButton fix --- .../Pages/Index.razor | 24 +- .../Components/DatePicker.razor | 12 +- .../Components/DatePicker.razor.cs | 33 +-- .../Components/FormWizard.razor | 3 +- .../Components/NumberInput.razor | 50 ++-- .../Components/NumberInput.razor.cs | 213 ++++++++++-------- .../Components/NumberStepper.razor | 2 +- .../Components/ToggleGlyphButton.razor | 4 +- .../Components/ToggleGlyphButton.razor.cs | 10 + .../Connected.Components.csproj | 2 +- 10 files changed, 205 insertions(+), 148 deletions(-) diff --git a/src/Connected.Components.Showcase.Runner/Pages/Index.razor b/src/Connected.Components.Showcase.Runner/Pages/Index.razor index 3a7dd11..4183816 100644 --- a/src/Connected.Components.Showcase.Runner/Pages/Index.razor +++ b/src/Connected.Components.Showcase.Runner/Pages/Index.razor @@ -36,20 +36,36 @@ Step4 - + - + + + + +

Selected date is @date.ToString()

Number is: @number.ToString()

+

DNumber is: @dnumber.ToString()

@code { DateTime date = DateTime.Today; + double dnumber = 0; + int number = 0; + + string ErrorText = ""; + + public void ChangeErrorText() + { + if (string.IsNullOrEmpty(ErrorText)) + ErrorText = "Test string: Error has ocurred!"; + else + ErrorText = string.Empty; + //StateHasChanged(); + } } \ No newline at end of file diff --git a/src/Connected.Components/Components/DatePicker.razor b/src/Connected.Components/Components/DatePicker.razor index b1e13ff..763b407 100644 --- a/src/Connected.Components/Components/DatePicker.razor +++ b/src/Connected.Components/Components/DatePicker.razor @@ -5,9 +5,9 @@
- -
Some helping Text
-
At least 6 characters required
+ +
@HelperText
+
@ErrorText
@@ -20,7 +20,6 @@
- @if (Shown) { @@ -96,6 +95,11 @@
@CalendarStart.AddDays(i).ToString("ddd").Substring(0,1)
} + @for (int i=0; i
+ } + @foreach (var Date in ShowingDates) {