From 3540dc8b54e9f5a9eefb0d1b1471bde2ece2bb52 Mon Sep 17 00:00:00 2001 From: stm Date: Mon, 13 Feb 2023 14:48:37 +0100 Subject: [PATCH] Cleanup, progress --- .../Connected.Components.Showcase.csproj | 8 ------ .../Components/Button.razor.cs | 9 +++--- .../Components/Glyph.razor | 8 ++++-- .../Components/Glyph.razor.cs | 24 +++++++++++++--- .../{InputNumber.razor => NumberInput.razor} | 4 ++- ...utNumber.razor.cs => NumberInput.razor.cs} | 28 ++++++++----------- .../{InputText.razor => TextInput.razor} | 2 +- ...{InputText.razor.cs => TextInput.razor.cs} | 5 ++-- .../Connected.Components.csproj | 20 +------------ 9 files changed, 47 insertions(+), 61 deletions(-) rename src/Connected.Components/Components/{InputNumber.razor => NumberInput.razor} (94%) rename src/Connected.Components/Components/{InputNumber.razor.cs => NumberInput.razor.cs} (82%) rename src/Connected.Components/Components/{InputText.razor => TextInput.razor} (96%) rename src/Connected.Components/Components/{InputText.razor.cs => TextInput.razor.cs} (93%) diff --git a/src/Connected.Components.Showcase/Connected.Components.Showcase.csproj b/src/Connected.Components.Showcase/Connected.Components.Showcase.csproj index acefce4..767a1cc 100644 --- a/src/Connected.Components.Showcase/Connected.Components.Showcase.csproj +++ b/src/Connected.Components.Showcase/Connected.Components.Showcase.csproj @@ -42,13 +42,5 @@ - - - - - - - - diff --git a/src/Connected.Components/Components/Button.razor.cs b/src/Connected.Components/Components/Button.razor.cs index 26f0e22..3daca4b 100644 --- a/src/Connected.Components/Components/Button.razor.cs +++ b/src/Connected.Components/Components/Button.razor.cs @@ -96,6 +96,10 @@ public partial class Button [Parameter] public string Style { get; set; } = string.Empty; + #endregion + + #region Events + /// /// Button click event. /// Options: any MouseEventCallback event @@ -103,13 +107,9 @@ public partial class Button [Parameter] public EventCallback OnClick { get; set; } - #endregion - - #region Events protected async Task Click(MouseEventArgs e) { await OnClick.InvokeAsync(e); - } #endregion @@ -146,5 +146,4 @@ public partial class Button #endregion - } diff --git a/src/Connected.Components/Components/Glyph.razor b/src/Connected.Components/Components/Glyph.razor index b8c55fa..cc4073f 100644 --- a/src/Connected.Components/Components/Glyph.razor +++ b/src/Connected.Components/Components/Glyph.razor @@ -1,4 +1,6 @@ -
- + +
+ @((MarkupString)SVG) - \ No newline at end of file + +
\ No newline at end of file diff --git a/src/Connected.Components/Components/Glyph.razor.cs b/src/Connected.Components/Components/Glyph.razor.cs index 8c26764..62d88d3 100644 --- a/src/Connected.Components/Components/Glyph.razor.cs +++ b/src/Connected.Components/Components/Glyph.razor.cs @@ -13,11 +13,27 @@ namespace Connected.Components public string Color { get; set; } = "#000000"; [Parameter] - public int Width { get; set; } = 25; + public int Width { get; set; } = 24; [Parameter] - public int Height { get; set; } = 25; + public int Height { get; set; } = 24; - [Parameter] + private string WidthString + { + get + { + return Width.ToString() + "px"; + } + } + + private string HeightString + { + get + { + return Width.ToString() + "px"; + } + } + + [Parameter] public string Class { get; set; } = string.Empty; private string GlyphClassList @@ -32,7 +48,7 @@ namespace Connected.Components [Parameter] /// - /// Button click event. + /// Glyph click event. /// public EventCallback Click { get; set; } protected async Task OnClick(MouseEventArgs e) diff --git a/src/Connected.Components/Components/InputNumber.razor b/src/Connected.Components/Components/NumberInput.razor similarity index 94% rename from src/Connected.Components/Components/InputNumber.razor rename to src/Connected.Components/Components/NumberInput.razor index 1a25c33..c451fdf 100644 --- a/src/Connected.Components/Components/InputNumber.razor +++ b/src/Connected.Components/Components/NumberInput.razor @@ -11,10 +11,12 @@ disabled="@Disabled" readonly="@Readonly" @onmousewheel="@OnMouseWheel" + @onwheel="@OnMouseWheel" @oninput=@ChangeValueAsync - @bind-value="@_value" + @bind-value="@Value" @attributes="@InputAttributes"> + diff --git a/src/Connected.Components/Components/InputNumber.razor.cs b/src/Connected.Components/Components/NumberInput.razor.cs similarity index 82% rename from src/Connected.Components/Components/InputNumber.razor.cs rename to src/Connected.Components/Components/NumberInput.razor.cs index 911d9bb..00c1d8b 100644 --- a/src/Connected.Components/Components/InputNumber.razor.cs +++ b/src/Connected.Components/Components/NumberInput.razor.cs @@ -3,9 +3,10 @@ using Connected.Utilities; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using System.Numerics; +using static Connected.Colors; namespace Connected.Components; -public partial class InputNumber:InputBase where NumberType : INumber +public partial class NumberInput:InputBase where NumberType : INumber { private double _step =1; [Parameter] @@ -40,7 +41,7 @@ public partial class InputNumber:InputBase where NumberType : INumbe } protected async Task OnMouseWheel(WheelEventArgs obj) { - if (!DisableMouseWheel) + if (DisableMouseWheel==false) { if (!obj.ShiftKey || Disabled || Readonly) return; @@ -55,19 +56,12 @@ public partial class InputNumber:InputBase where NumberType : INumbe } } - private NumberType _value; [Parameter] public NumberType Value { - get - { - return _value; - } - set - { - _value = AdjustDecimalPlaces(value); - } + get; + set; } [Parameter] @@ -81,13 +75,13 @@ public partial class InputNumber:InputBase where NumberType : INumbe { if (args.Value is not null) { - NumberType value = (NumberType)Convert.ChangeType(args.Value, typeof(NumberType)); - if (value.ToString().Length <= 0) - { + NumberType value = (NumberType)Convert.ChangeType(args.Value, typeof(NumberType)); + if (value.ToString().Length <= 0) + { - value = (NumberType)Convert.ChangeType(0, typeof(NumberType)); - } - await ValueChanged.InvokeAsync((NumberType)Convert.ChangeType(AdjustDecimalPlaces(value), typeof(NumberType))); + value = (NumberType)Convert.ChangeType(0, typeof(NumberType)); + } + await ValueChanged.InvokeAsync((NumberType)Convert.ChangeType(AdjustDecimalPlaces(value), typeof(NumberType))); } } diff --git a/src/Connected.Components/Components/InputText.razor b/src/Connected.Components/Components/TextInput.razor similarity index 96% rename from src/Connected.Components/Components/InputText.razor rename to src/Connected.Components/Components/TextInput.razor index 3a848fc..cf84831 100644 --- a/src/Connected.Components/Components/InputText.razor +++ b/src/Connected.Components/Components/TextInput.razor @@ -41,7 +41,7 @@ } - @if (Clearable && Value.ToString().Length>0) + @if (Clearable && !string.IsNullOrEmpty(Value)) { diff --git a/src/Connected.Components/Components/InputText.razor.cs b/src/Connected.Components/Components/TextInput.razor.cs similarity index 93% rename from src/Connected.Components/Components/InputText.razor.cs rename to src/Connected.Components/Components/TextInput.razor.cs index 43d4399..7dd294f 100644 --- a/src/Connected.Components/Components/InputText.razor.cs +++ b/src/Connected.Components/Components/TextInput.razor.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Components; namespace Connected.Components; -public partial class InputText: InputBase +public partial class TextInput: InputBase { [Parameter] @@ -31,7 +31,7 @@ public partial class InputText: InputBase [Parameter] - public string Value { get; set; } + public string Value { get; set; } = string.Empty; private string inputType { @@ -42,7 +42,6 @@ public partial class InputText: InputBase } } - [Parameter] public EventCallback ValueChanged { get; set; } diff --git a/src/Connected.Components/Connected.Components.csproj b/src/Connected.Components/Connected.Components.csproj index 1a59b61..10b55ec 100644 --- a/src/Connected.Components/Connected.Components.csproj +++ b/src/Connected.Components/Connected.Components.csproj @@ -20,13 +20,6 @@ - - - - - - - @@ -39,9 +32,6 @@ - - - True \ @@ -86,19 +76,11 @@ - - - - - - - - - + -- 2.36.3