Compare commits

..

No commits in common. '33311058119b06c00436f18709a2c4f77c8f29c4' and 'd6ee4bc164facd918731a498178a4bfcff8c69ee' have entirely different histories.

@ -1,29 +0,0 @@
@page "/formwizard"
@using Connected.Classes.FormWizard;
@using Connected.Components;
@using Connected.Enums;
@using Connected.Models.Modal;
@using Connected.Models;
@using Connected.Services;
@using Connected.Utilities;
<h1 style="text-align:center;">FORM WIZARD EXAMPLE</h1>
<FormWizard Options="@options">
<FormWizardStep>
Step 1
</FormWizardStep>
<FormWizardStep>
Step2
</FormWizardStep>
<FormWizardStep>
Step3
</FormWizardStep>
<FormWizardStep>
Step4
</FormWizardStep>
</FormWizard>
@code {
FormWizardOptions options = new(false, "Naslednji", "Prejšnji", "Končaj", "Prekliči");
}

@ -38,7 +38,7 @@
* *
*/ */
@<div> @<div>
<div>Change the number input and watch the value variable behind the modal change</div> <div>Change the number input aand watch the value variable behind the modal change</div>
<NumberInput @bind-Value=@value></NumberInput> <NumberInput @bind-Value=@value></NumberInput>
</div>, </div>,

@ -1,25 +0,0 @@
@page "/toggleglyph"
@using Connected.Components;
@using Connected.Enums;
@using Connected.Models.Modal;
@using Connected.Models;
@using Connected.Services;
@using Connected.Utilities;
@inject ModalDialogService modalDialog;
<h1 style="text-align:center;">DATE PICKER EXAMPLE</h1>
<ToggleGlyphButton Glyph="@Icons.Material.Filled.Close" ToggledGlyph="@Icons.Material.Filled.Check" @bind-Toggled=toggle>
TGB
</ToggleGlyphButton>
<h4>Toggled: @toggle</h4>
@code {
bool toggle = false;
}

@ -10,12 +10,10 @@
<h1 style="text-align:center;">Component Example page</h1> <h1 style="text-align:center;">Component Example page</h1>
<ul> <ul>
<li><Link Class="m-1" Url="modal" Text="Modal dialog" Target="Target.Self" /></li> <li><Link Class="m-1" Url="modal" Text="Modal dialog" Target="Target.Self" /></li>
<li><Link Class="m-1" Url="button" Text="Button" Target="Target.Self" /></li> <li><Link Class="m-1" Url="button" Text="Button" Target="Target.Self" /></li>
<li><Link Class="m-1" Url="datepicker" Text="Date picker" Target="Target.Self" /></li> <li><Link Class="m-1" Url="datepicker" Text="Date picker" Target="Target.Self" /></li>
<li><Link Class="m-1" Url="datagrid" Text="Data Grid" Target="Target.Self" /></li> <li><Link Class="m-1" Url="datagrid" Text="Data Grid" Target="Target.Self" /></li>
<li><Link Class="m-1" Url="toggleglyph" Text="Toggle Glyph Button" Target="Target.Self" /></li>
<li><Link Class="m-1" Url="formwizard" Text="Form wizzard" Target="Target.Self" /></li>
</ul> </ul>
} else } else
{ {

@ -14,7 +14,6 @@ internal class Program
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddModalDialogService(); builder.Services.AddModalDialogService();
builder.Services.AddStateManagementService();
await builder.Build().RunAsync(); await builder.Build().RunAsync();
} }

@ -1,33 +0,0 @@
namespace Connected.Classes.FormWizard;
public class FormWizardOptions
{
public bool DisableNavigationOnFinish { get; set; } = false;
public string NextButtonText { get; set; } = "Next";
public string PreviousButtonText { get; set; } = "Previous";
public string FinishButtonText { get; set; } = "Finish";
public string CancelButtonText { get; set; } = "Cancel";
public FormWizardOptions(
bool DisableNavigationOnFinish=false,
string NextButtonText = "Next",
string PreviousButtonText = "Previous",
string FinishButtonText="Finish",
string CancelButtonText="Cancel")
{
this.DisableNavigationOnFinish = DisableNavigationOnFinish;
this.NextButtonText = NextButtonText;
this.PreviousButtonText = PreviousButtonText;
this.FinishButtonText = FinishButtonText;
this.CancelButtonText = CancelButtonText;
}
public FormWizardOptions(FormWizardOptions options)
{
DisableNavigationOnFinish = options.DisableNavigationOnFinish;
NextButtonText = options.NextButtonText;
PreviousButtonText = options.PreviousButtonText;
FinishButtonText = options.FinishButtonText;
CancelButtonText = options.CancelButtonText;
}
}

@ -1,9 +1,8 @@
using Connected.Components; using Connected.Utilities;
using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Connected.Models; namespace Connected.Models;
public class InputBase : Base public class InputBase : ComponentBase
{ {
[Parameter] [Parameter]
public string Class { get; set; } = string.Empty; public string Class { get; set; } = string.Empty;
@ -73,7 +72,7 @@ public class InputBase : Base
/// Fired when the text value changes. /// Fired when the text value changes.
/// </summary> /// </summary>
[Parameter] public EventCallback<string> TextChanged { get; set; } [Parameter] public EventCallback<string> TextChanged { get; set; }
public string Text { get; set; } = string.Empty; public string Text { get; set; }
protected virtual async Task SetTextAsync(string text) protected virtual async Task SetTextAsync(string text)
{ {

@ -10,7 +10,7 @@ public class ModalOptions
public ModalType Type { get; set; } = ModalType.Default; public ModalType Type { get; set; } = ModalType.Default;
public ModalOptions() public ModalOptions()
{ {
} }
public ModalOptions(ModalOptions options) public ModalOptions(ModalOptions options)
@ -21,7 +21,7 @@ public class ModalOptions
Type = options.Type; Type = options.Type;
} }
public ModalOptions(bool disableEscKey = false, bool disableBackdropClick = false, bool noHeader = false, ModalType type = ModalType.Default) public ModalOptions(bool disableEscKey=false, bool disableBackdropClick=false, bool noHeader=false, ModalType type=ModalType.Default)
{ {
DisableEscKey = disableEscKey; DisableEscKey = disableEscKey;
DisableBackdropClick = disableBackdropClick; DisableBackdropClick = disableBackdropClick;

@ -1,18 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace Connected.Classes
{
public class State
{
public Type? ComponentType { get; set; }
public string Id { get; set; }
public Dictionary<string, object>? Values { get; set; }
public State()
{
ComponentType = null;
Id=string.Empty;
Values = new();
}
}
}

@ -1,5 +0,0 @@
@inherits ComponentBase
@*Base class for all components
It contains unique ID for the component used in
saving state of the component*@

@ -1,20 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace Connected.Components
{
public partial class Base : ComponentBase
{
/// <summary>
/// Unique ID for the component used in state management
/// Every component should inherit from Base class
/// </summary>
[Parameter, EditorRequired]
public string Id { get; set; } = Guid.NewGuid().ToString();
protected override void OnInitialized()
{
if (string.IsNullOrEmpty(Id))
Id = Guid.NewGuid().ToString();
}
}
}

@ -1,6 +1,4 @@
@inherits Base <button type="button"
<button type="button"
@onclick="@OnClick" @onclick="@OnClick"
disabled=@Disabled disabled=@Disabled
style="@StyleList" style="@StyleList"

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
namespace Connected.Components; namespace Connected.Components;
public partial class Button : Base public partial class Button
{ {
#region Parameters #region Parameters

@ -3,7 +3,7 @@
@inherits InputBase; @inherits InputBase;
<label class="checkbox-group" <label class="checkbox-group"
for="@base.Id"> for="@Id">
<input class="@ClassList" <input class="@ClassList"
style="@StyleList" style="@StyleList"
id="@Id" id="@Id"

@ -13,6 +13,13 @@ public partial class CheckBox : InputBase
[Parameter] [Parameter]
public bool Checked { get; set; } = false; public bool Checked { get; set; } = false;
/// <summary>
/// ID for the CheckBox
/// </summary>
[Parameter, EditorRequired]
public string? Id { get; set; }
/// <summary> /// <summary>
/// Event when the checked is changed /// Event when the checked is changed
/// </summary> /// </summary>

@ -1,6 +1,4 @@
@inherits Base <h3>Chip</h3>
<h3>Chip</h3>
@code { @code {

@ -1,5 +1,7 @@
namespace Connected.Components; using Microsoft.AspNetCore.Components;
public partial class Chip: Base namespace Connected.Components;
public partial class Chip
{ {
} }

@ -1,7 +1,5 @@
@using System.Globalization; @using System.Globalization;
@inherits Base
@if (loaded) @if (loaded)
{ {
<div id="picker"> <div id="picker">

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class DatePicker: Base public partial class DatePicker
{ {
private bool loaded = false; private bool loaded = false;

@ -1,7 +1,5 @@
@using Connected.Models @typeparam T;
@inherits Connected.Models.InputBase;
@typeparam T;
@inherits InputBase;
<div class="@InputFieldClassList"> <div class="@InputFieldClassList">
<select type="textarea" @onfocus="(()=> Open())" @onblur="(()=> Close())"> <select type="textarea" @onfocus="(()=> Open())" @onblur="(()=> Close())">

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Connected.Models; using Connected.Models;
using System.Collections.Immutable;
namespace Connected.Components; namespace Connected.Components;

@ -1,29 +1,22 @@
@inherits Base <CascadingValue Value="this">
<section id="@Id" class="@ClassList" style="@StyleList">
<div class="form-outer ">
@ChildContent
</div>
@if (loaded) <div class="btn-content justify-space-between">
{ <button type="button" href="#" class="btn btn-secondary" aria-pressed="true" disabled="@WizardFinished" @onclick="CancelClick">Cancel</button>
<CascadingValue Value="this"> <div class="btn-group">
<section id="@Id" class="@ClassList" style="@StyleList"> <button type="button" @onclick="PreviousSlide" class="btn btn-core mr-2" aria-pressed="true" disabled="@WizardFinished"><i class='bx bx-chevron-left'></i>@PreviousBtnText</button>
<div class="form-outer "> <button type="button" @onclick="NextSlide" class="btn btn-core mr-2" aria-pressed="true" disabled="@WizardFinished">@NextBtnText<i class='bx bx-chevron-right'></i></button>
@ChildContent
</div> </div>
</div>
<div class="btn-content justify-space-between"> <div class="dots d-flex justify-center gap-3">
<button type="button" href="#" class="btn btn-secondary" aria-pressed="true" disabled="@NavigationDisabled" @onclick="CancelClick">@Options.CancelButtonText</button> @foreach (var step in Steps)
<div class="btn-group"> {
<button type="button" @onclick="PreviousSlide" class="btn btn-core mr-2" aria-pressed="true" disabled="@NavigationDisabled"><i class='bx bx-chevron-left'></i>@Options.PreviousButtonText</button> <div class="dot @step.DotClass"></div>
<button type="button" @onclick="NextSlide" class="btn btn-core mr-2" aria-pressed="true" disabled="@NavigationDisabled">@NextBtnText<i class='bx bx-chevron-right'></i></button> }
</div> </div>
</div>
<div class="dots d-flex justify-center gap-3">
@foreach (var step in Steps)
{
<div class="dot @step.DotClass"></div>
}
</div>
</section> </section>
</CascadingValue> </CascadingValue>
} else {
<p>@LoadingText</p>
}

@ -1,11 +1,10 @@
using Connected.Classes.FormWizard; using Connected.Enums;
using Connected.Enums;
using Connected.Utilities; using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using System.Reflection.Metadata; using System.Reflection.Metadata;
namespace Connected.Components; namespace Connected.Components;
public partial class FormWizard: Base public partial class FormWizard
{ {
/// <summary> /// <summary>
@ -22,18 +21,6 @@ public partial class FormWizard: Base
[Parameter] [Parameter]
public List<FormWizardStep> Steps { get; set; } = new(); public List<FormWizardStep> Steps { get; set; } = new();
/// <summary>
/// Steps of type FormWizardStep
/// </summary>
[Parameter]
public string LoadingText { get; set; } = "Loading wizard...";
/// <summary>
/// Steps of type FormWizardStep
/// </summary>
[Parameter]
public bool DisableNavigationOnFinish { get; set; } = false;
/// <summary> /// <summary>
/// EventCallback for 'Finish' button click /// EventCallback for 'Finish' button click
/// </summary> /// </summary>
@ -46,19 +33,15 @@ public partial class FormWizard: Base
[Parameter] [Parameter]
public EventCallback OnCancelClick { get; set; } public EventCallback OnCancelClick { get; set; }
/// <summary>
/// Text shown inside the button
/// Options: any string variable
/// Default: string.Empty
/// </summary>
[Parameter] [Parameter]
public FormWizardOptions Options { get; set; } = new(); public string Id { get; set; } = Guid.NewGuid().ToString();
private bool NavigationDisabled { get; set; } = false; private string NextBtnText = "Next";
private string PreviousBtnText = "Previous";
private FinishedState FinishedState { get; set; } = FinishedState.Unfinished; private bool WizardFinished { get; set; } = false;
private string NextBtnText { get; set; } = "Next"; private FinishedState FinishedState { get; set; } = FinishedState.Unfinished;
[Parameter] [Parameter]
public int ActiveIndex public int ActiveIndex
@ -118,7 +101,7 @@ public partial class FormWizard: Base
{ {
FinishedState = FinishedState.Finished; FinishedState = FinishedState.Finished;
Steps[ActiveIndex].Completed = true; Steps[ActiveIndex].Completed = true;
if (DisableNavigationOnFinish) NavigationDisabled = true; WizardFinished = true;
await OnFinishedClick.InvokeAsync(); await OnFinishedClick.InvokeAsync();
} }
if (FinishedState.Equals(FinishedState.Unfinished)) if (FinishedState.Equals(FinishedState.Unfinished))
@ -133,9 +116,9 @@ public partial class FormWizard: Base
Steps[PreviousIndex].IsPrevious = true; Steps[PreviousIndex].IsPrevious = true;
if (ActiveIndex == NextIndex) if (ActiveIndex == NextIndex)
NextBtnText = Options.FinishButtonText; NextBtnText = "Finish";
else else
NextBtnText = Options.NextButtonText; NextBtnText = "Next";
} }
} }
@ -152,9 +135,9 @@ public partial class FormWizard: Base
Steps[PreviousIndex].IsPrevious = true; Steps[PreviousIndex].IsPrevious = true;
if (ActiveIndex == NextIndex) if (ActiveIndex == NextIndex)
NextBtnText = Options.FinishButtonText; NextBtnText = "Finish";
else else
NextBtnText = Options.NextButtonText; NextBtnText = "Next";
} }
if (ActiveIndex == 0) if (ActiveIndex == 0)
{ {
@ -165,9 +148,6 @@ public partial class FormWizard: Base
private async Task CancelClick() private async Task CancelClick()
{ {
ResetAllChildren(true);
ActiveIndex = 0;
Steps[0].Active = true;
await OnCancelClick.InvokeAsync(); await OnCancelClick.InvokeAsync();
} }
@ -204,14 +184,13 @@ public partial class FormWizard: Base
Steps[ChildIndex].IsPrevious = false; Steps[ChildIndex].IsPrevious = false;
} }
private void ResetAllChildren(bool reset_finished = false) private void ResetAllChildren()
{ {
foreach (var step in Steps) foreach (var step in Steps)
{ {
step.Active = false; step.Active = false;
step.IsNext = false; step.IsNext = false;
step.IsPrevious = false; step.IsPrevious = false;
if (reset_finished) step.Completed = false;
} }
} }
@ -237,23 +216,11 @@ public partial class FormWizard: Base
await base.OnParametersSetAsync(); await base.OnParametersSetAsync();
}*/ }*/
private bool loaded = false;
protected override async Task OnInitializedAsync()
{
loaded = true;
await Task.Run(StateHasChanged);
}
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) if (firstRender)
{ {
InitializeSteps(); InitializeSteps();
if (ActiveIndex == NextIndex)
NextBtnText = Options.FinishButtonText;
else
NextBtnText = Options.NextButtonText;
} }
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
} }

@ -1,5 +1,3 @@
@inherits Base <div class="@ClassList" style="@StyleList">
<div class="@ClassList" style="@StyleList">
@ChildContent @ChildContent
</div> </div>

@ -2,13 +2,19 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class FormWizardStep: Base public partial class FormWizardStep
{ {
#region Parameters #region Parameters
[CascadingParameter] [CascadingParameter]
public FormWizard Parent { get; set; } public FormWizard Parent { get; set; }
/// <summary>
/// Unique name of the step (used for properly identifying steps)
/// </summary>
[Parameter]
public string? Id { get; set; } = Guid.NewGuid().ToString();
/// <summary> /// <summary>
/// Text shown inside the button /// Text shown inside the button
/// Options: any string variable /// Options: any string variable
@ -51,6 +57,7 @@ public partial class FormWizardStep: Base
#endregion #endregion
#region Styling #region Styling
public string StyleList public string StyleList
@ -64,6 +71,7 @@ public partial class FormWizardStep: Base
} }
} }
/// <summary> /// <summary>
/// Generated class list for button based on user parameters /// Generated class list for button based on user parameters
/// </summary> /// </summary>

@ -1,5 +1,3 @@
@inherits Base <svg viewBox="0 0 24 24" class="@GlyphClassList" @onclick="@OnClick">
<svg viewBox="0 0 24 24" class="@GlyphClassList" @onclick="@OnClick">
@((MarkupString)SVG) @((MarkupString)SVG)
</svg> </svg>

@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Components.Web;
namespace Connected.Components; namespace Connected.Components;
public partial class Glyph: Base public partial class Glyph
{ {
/// <summary> /// <summary>
/// SVG markup string for glyph /// SVG markup string for glyph

@ -1,8 +1,6 @@
@attribute [CascadingTypeParameter(nameof(DataType))] @attribute [CascadingTypeParameter(nameof(DataType))]
@typeparam DataType @typeparam DataType
@inherits Base
<CascadingValue Value="this"> <CascadingValue Value="this">
<div class="@GridClassList.ToString()"> <div class="@GridClassList.ToString()">
@foreach (var Item in ItemsToShow) @foreach (var Item in ItemsToShow)

@ -1,10 +1,11 @@
using Connected.Classes.Grid; using Connected.Classes.Grid;
using Connected.Utilities; using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace Connected.Components; namespace Connected.Components;
public partial class Grid<DataType> : Base public partial class Grid<DataType> : ComponentBase
{ {
[Parameter] [Parameter]

@ -1,7 +1,5 @@
@typeparam DataType @typeparam DataType
@inherits Base
<CascadingValue Value="this"> <CascadingValue Value="this">
<div class="@GridRowClass.ToString()" id="@Guid.NewGuid()"> <div class="@GridRowClass.ToString()" id="@Guid.NewGuid()">
<div class="data-grid-select"> <div class="data-grid-select">

@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class GridRow<DataType> : Base public partial class GridRow<DataType> : ComponentBase
{ {
[CascadingParameter] [CascadingParameter]

@ -1,6 +1,4 @@
@inherits Base <a class="@LinkClassList"
<a class="@LinkClassList"
style="@LinkStyleList" style="@LinkStyleList"
href="@Url" href="@Url"
target="@_target"> target="@_target">

@ -1,9 +1,10 @@
using Connected.Enums; using Connected.Enums;
using Connected.Utilities; using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using static Connected.Colors;
namespace Connected.Components; namespace Connected.Components;
public partial class Link: Base public partial class Link
{ {
/// <summary> /// <summary>
/// URL of the link /// URL of the link

@ -1,7 +1,4 @@
@using Connected.Models.Modal; @using Connected.Models.Modal;
@inherits Base
@if (IsVisible) @if (IsVisible)
{ {
<div class="@ClassList" @onclick="@CloseIfEnabled" @onkeydown="@(e => CheckEscape(e))" tabindex="-1" @ref="@root"> <div class="@ClassList" @onclick="@CloseIfEnabled" @onkeydown="@(e => CheckEscape(e))" tabindex="-1" @ref="@root">

@ -4,9 +4,10 @@ using Connected.Services;
using Connected.Utilities; using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using System.Reflection;
namespace Connected.Components; namespace Connected.Components;
public partial class ModalDialog : Base, IDisposable public partial class ModalDialog : IDisposable
{ {
[Inject] ModalDialogService? ModalService { get; set; } [Inject] ModalDialogService? ModalService { get; set; }

@ -1,7 +1,5 @@
@typeparam NumberType @typeparam NumberType
@inherits Base
<div class="form-group-alt"> <div class="form-group-alt">
<div class="input-group-content"> <div class="input-group-content">
<div class="input-cta-icon" @onclick="StepDown"> <div class="input-cta-icon" @onclick="StepDown">

@ -4,7 +4,7 @@ using System.Numerics;
namespace Connected.Components namespace Connected.Components
{ {
public partial class NumberStepper<NumberType> where NumberType : Base, INumber<NumberType> public partial class NumberStepper<NumberType> where NumberType : INumber<NumberType>
{ {
[Parameter] [Parameter]

@ -12,6 +12,9 @@ public partial class Radio : InputBase
[Parameter] [Parameter]
public bool Checked { get; set; } = false; public bool Checked { get; set; } = false;
[Parameter, EditorRequired]
public string? Id { get; set; }
#endregion #endregion
#region Events #region Events

@ -1,7 +1,5 @@
@using Connected.Models; @using Connected.Models;
@inherits Base
<CascadingValue Value="this"> <CascadingValue Value="this">
<div> <div>
@if (!string.IsNullOrEmpty(Name)) @if (!string.IsNullOrEmpty(Name))

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class RadioGroup: Base public partial class RadioGroup
{ {
#region Parameters #region Parameters

@ -1,12 +1,21 @@
@inherits GlyphButton @inherits Button
<button type="button" <button type="button"
@onclick="@Clicked" @onclick="@Clicked"
disabled=@Disabled disabled=@Disabled
style="@StyleList" style="@StyleList"
class="@ClassList"> class="@ClassList">
<div class="@ContentClassList"> <div class="@ContentClassList">
<Glyph SVG="@_ShownGlyph" Color="@GlyphColor" /> <div style="align-items:center">
@if (GlyphPosition == Position.Top)
{
<Glyph SVG="@_ShownGlyph" Color="@GlyphColor" />
}
@ChildContent @ChildContent
@if (GlyphPosition == Position.Bottom)
{
<Glyph SVG="@_ShownGlyph" Color="@GlyphColor" />
}
</div> </div>
</div>
</button> </button>

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
namespace Connected.Components; namespace Connected.Components;
public partial class ToggleGlyphButton: GlyphButton public partial class ToggleGlyphButton: Button
{ {
#region Parameters #region Parameters
@ -15,6 +15,13 @@ public partial class ToggleGlyphButton: GlyphButton
[Parameter] [Parameter]
public bool Toggled { get; set; } = false; public bool Toggled { get; set; } = false;
/// <summary>
/// Glyph (Icon) inside the button.
/// Options: SVG string --> Icons
/// Default: string.Empty
/// </summary>
[Parameter, EditorRequired]
public string Glyph { get; set; } = string.Empty;
/// <summary> /// <summary>
/// Glyph (Icon) inside the button when tge . /// Glyph (Icon) inside the button when tge .
@ -24,25 +31,29 @@ public partial class ToggleGlyphButton: GlyphButton
[Parameter, EditorRequired] [Parameter, EditorRequired]
public string ToggledGlyph { get; set; } = string.Empty; public string ToggledGlyph { get; set; } = string.Empty;
/// <summary>
/// Position of the glyph relative to button Text parameter. If Glyph parameter == string.Empty this parameter is ignored
/// Options: Position.[left,top,right,bottom]
/// Default: Position.left
/// </summary>
[Parameter]
public Position GlyphPosition { get; set; } = Position.Left;
/// <summary> /// <summary>
/// Color for the glyph. If Glyph parameter is empty this parameter is ignored /// Color for the glyph. If Glyph parameter is empty this parameter is ignored
/// Options: Color.[Core,Primary,Secondary,Success,Info,Warning,Danger,White,Light,Dark] /// Options: Color.[Core,Primary,Secondary,Success,Info,Warning,Danger,White,Light,Dark]
/// Default: Color.Dark /// Default: Color.Dark
/// </summary> /// </summary>
[Parameter] [Parameter]
public Color ToggledGlyphColor { get; set; } = Color.Dark; public Color GlyphColor { get; set; } = Color.Dark;
/// <summary>
/// Color for the glyph. If Glyph parameter is empty this parameter is ignored
/// Options: Color.[Core,Primary,Secondary,Success,Info,Warning,Danger,White,Light,Dark]
/// Default: Color.Dark
/// </summary>
[Parameter] [Parameter]
public Color ToggledButtonColor { get; set; } = Color.Success; public Color ToggledGlyphColor { get; set; } = Color.Dark;
private Color _ButtonColor
{
get
{
if (Toggled) return ToggledButtonColor;
return base.Color;
}
}
private string _ShownGlyph private string _ShownGlyph
{ {
@ -50,7 +61,7 @@ public partial class ToggleGlyphButton: GlyphButton
{ {
if (Toggled) if (Toggled)
return ToggledGlyph; return ToggledGlyph;
return base.Glyph; return Glyph;
} }
} }
@ -83,9 +94,8 @@ public partial class ToggleGlyphButton: GlyphButton
{ {
return new CssBuilder("btn") return new CssBuilder("btn")
.AddClass("btn-" + Helper.GetEnumDescription<Size>(base.Size)) .AddClass("btn-" + Helper.GetEnumDescription<Size>(base.Size))
.AddClass("btn-" + Helper.GetEnumDescription<Color>(_ButtonColor),!base.Outlined) .AddClass("btn-" + Helper.GetEnumDescription<Color>(base.Color),!base.Outlined)
.AddClass("btn-outline-" + Helper.GetEnumDescription<Color>(_ButtonColor), base.Outlined) .AddClass("btn-outline-" + Helper.GetEnumDescription<Color>(base.Color), base.Outlined)
.AddClass("wrap")
.AddClass(base.Class) .AddClass(base.Class)
.Build(); .Build();
} }

@ -13,6 +13,9 @@ public partial class ToggleInput: InputBase
set => _checked= (bool)value; set => _checked= (bool)value;
} }
[Parameter, EditorRequired]
public string Id { get; set; }
[Parameter] [Parameter]
public EventCallback<bool> CheckedChanged { get; set; } public EventCallback<bool> CheckedChanged { get; set; }

@ -6,7 +6,4 @@ public static class ServiceCollectionExtensions
{ {
public static IServiceCollection AddModalDialogService(this IServiceCollection services) public static IServiceCollection AddModalDialogService(this IServiceCollection services)
=> services.AddScoped<ModalDialogService>(); => services.AddScoped<ModalDialogService>();
public static IServiceCollection AddStateManagementService(this IServiceCollection services)
=> services.AddSingleton<StateManagerService>();
} }

@ -1,71 +0,0 @@
using Connected.Classes;
using Connected.Components;
using System.Collections.ObjectModel;
namespace Connected.Services;
public class StateManagerService
{
public void SaveOrUpdateComponentState(Base Component)
{
var current_state = new State();
var properties = Component.GetType().GetProperties();
current_state.Id = Component.Id;
current_state.ComponentType = Component.GetType();
if (current_state.Values is null) current_state.Values = new Dictionary<string, object>();
foreach (var property in properties)
{
var value = property.GetValue(Component);
if (value is not null)
current_state.Values.Add(property.Name, value);
}
if (SavedStates is null) SavedStates = new ObservableCollection<State>();
SavedStates.Add(current_state);
}
public State? LoadComponentState(string ComponentId)
{
if (string.IsNullOrEmpty(ComponentId)) return null;
if (SavedStates is not null)
{
var Component = SavedStates.Where(state => state.Id == ComponentId).FirstOrDefault();
return Component;
}
return null;
}
public bool RemoveComponentState(string ComponentId)
{
bool result = false;
try
{
if (SavedStates is not null)
{
return SavedStates.Remove(SavedStates.FirstOrDefault(state => state.Id == ComponentId));
}
} catch (Exception ex)
{
result = false;
}
return result;
}
public bool ClearComponentStates()
{
bool result = false;
try
{
if (SavedStates is not null)
{
SavedStates.Clear();
result = true;
}
} catch
{
result = false;
}
return result;
}
private ObservableCollection<State>? SavedStates { get; set; } = new();
}
Loading…
Cancel
Save