From 689fc41189089f92233800c055401eb64fd26bc9 Mon Sep 17 00:00:00 2001 From: juhangil Date: Wed, 18 Sep 2024 06:34:04 +0900 Subject: [PATCH] Move label component to slider and list --- .../Components/UI/LabelWithTooltip.razor | 30 ----- .../UI/ParameterListComponent.razor | 56 ++++++++++ ...d.razor => ParameterSliderComponent.razor} | 49 ++++++--- .../UI/ParameterSliderComponent.razor.css | 26 +++++ .../UI/ParametersTabComponent.razor | 103 +++++++----------- .../UI/ParametersTabComponent.razor.css | 9 -- 6 files changed, 154 insertions(+), 119 deletions(-) delete mode 100644 src/AzureOpenAIProxy.PlaygroundApp/Components/UI/LabelWithTooltip.razor create mode 100644 src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterListComponent.razor rename src/AzureOpenAIProxy.PlaygroundApp/Components/UI/{SliderWithTextfield.razor => ParameterSliderComponent.razor} (56%) create mode 100644 src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor.css delete mode 100644 src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor.css diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/LabelWithTooltip.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/LabelWithTooltip.razor deleted file mode 100644 index 88756b1d..00000000 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/LabelWithTooltip.razor +++ /dev/null @@ -1,30 +0,0 @@ -@inherits FluentComponentBase - -
- @LabelText - - @* Tooltip Image *@ - - - @TooltipText - -
- -@code { - [Parameter, EditorRequired] - public string LabelText { get; set; } = string.Empty; - - [Parameter, EditorRequired] - public string TooltipText { get; set; } = string.Empty; - - private string anchorId = string.Empty; - - protected override void OnInitialized() - { - base.OnInitialized(); - anchorId = $"{Id}-tooltip"; - } -} \ No newline at end of file diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterListComponent.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterListComponent.razor new file mode 100644 index 00000000..184f0e71 --- /dev/null +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterListComponent.razor @@ -0,0 +1,56 @@ +@inherits FluentComponentBase + +
+ + +
+ + + Create "@(context)" + + +
+
+ +@code { + [Parameter, EditorRequired] + public string LabelText { get; set; } = string.Empty; + + [Parameter, EditorRequired] + public string TooltipText { get; set; } = string.Empty; + + private IEnumerable stopSequenceValue = new List(); + private List searchTextItems = new(); + + private Task OnSearchAsync(OptionsSearchEventArgs e) + { + searchTextItems.Clear(); + if (string.IsNullOrEmpty(e.Text) || stopSequenceValue.Contains(e.Text)) + return Task.CompletedTask; + + searchTextItems.Add(e.Text); + e.Items = searchTextItems; + + return Task.CompletedTask; + } +} diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/SliderWithTextfield.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor similarity index 56% rename from src/AzureOpenAIProxy.PlaygroundApp/Components/UI/SliderWithTextfield.razor rename to src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor index 1506b605..01f3c052 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/SliderWithTextfield.razor +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor @@ -1,21 +1,38 @@ @inherits FluentComponentBase @typeparam TValue where TValue : System.Numerics.INumber -
- - - - - +
+ + + + + + + @if (!hasNoError) { - + @errorText } @@ -37,8 +54,11 @@ [Parameter] public EventCallback ValueChanged { get; set; } - [Parameter] - public EventCallback OnChangeEvent { get; set; } + [Parameter, EditorRequired] + public string LabelText { get; set; } = string.Empty; + + [Parameter, EditorRequired] + public string TooltipText { get; set; } = string.Empty; public string? textFieldValue { get; set; } @@ -47,9 +67,10 @@ protected override void OnInitialized() { - base.OnInitialized(); textFieldValue = Value!.ToString(); errorText = $"Only numbers between {Min} and {Max} are permitted"; + + base.OnInitialized(); } private async Task AfterSliderChange() @@ -58,7 +79,6 @@ textFieldValue = Value!.ToString(); await ValueChanged.InvokeAsync(Value); - await OnChangeEvent.InvokeAsync(); } private async Task AfterTextFieldChange() @@ -73,6 +93,5 @@ this.Value = parsed; await ValueChanged.InvokeAsync(Value); - await OnChangeEvent.InvokeAsync(); } } diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor.css b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor.css new file mode 100644 index 00000000..9f15a73b --- /dev/null +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParameterSliderComponent.razor.css @@ -0,0 +1,26 @@ +::deep .parameter-label { + display: inline-block; + padding-left: 5px; + font-weight: bold; + font-size: 8px; +} + +::deep .parameter-slider { + width: 88%; + padding-top: 15px; +} + +::deep .parameter-textfield { + width: 12%; + font-size: 9px; + padding-right: 5px; +} + +::deep .parameter-error { + padding: 10px; + width: 95%; + margin: 5px auto; + border-color: crimson; + background-color: lightcoral; + color: black +} diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor index 58cdfa06..4ea33346 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor @@ -1,73 +1,58 @@ @using System.Linq
+ @* Past Messages Slider *@ - - - + @* Max Response Slider *@ - - - + @* Temperature Slider *@ - - - + @* Top P Slider *@ - - - + @* Stop Sequence Auto Complete *@ - - - - - Create "@(context)" - - + @* Frequency Penalty Slider *@ - - - + @* Presence Penalty Slider *@ - - - - +
@code { @@ -84,16 +69,4 @@ private IEnumerable stopSequenceValue = new List(); private List searchTextItems = new(); - - private Task OnSearchAsync(OptionsSearchEventArgs e) - { - searchTextItems.Clear(); - if (string.IsNullOrEmpty(e.Text) || stopSequenceValue.Contains(e.Text)) - return Task.CompletedTask; - - searchTextItems.Add(e.Text); - e.Items = searchTextItems; - - return Task.CompletedTask; - } } \ No newline at end of file diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor.css b/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor.css deleted file mode 100644 index acab3cf1..00000000 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ParametersTabComponent.razor.css +++ /dev/null @@ -1,9 +0,0 @@ -::deep .label-with-tooltip { - padding-left: 10px; - font-weight: bold; -} - -::deep .slider-with-text { - padding-left: 5px; - padding-right: 10px; -} \ No newline at end of file