// Copyright (c) MudBlazor 2021 // MudBlazor licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Connected.Annotations; using Connected.Extensions; using Connected.Utilities; using Microsoft.AspNetCore.Components; namespace Connected.Components; public partial class TimelineItem : UIComponent, IDisposable { protected string Classnames => new CssBuilder("mud-timeline-item") .AddClass($"mud-timeline-item-{TimelineAlign.ToDescriptionString()}") .AddClass(Class) .Build(); protected string DotClassnames => new CssBuilder("mud-timeline-item-dot") .AddClass($"mud-timeline-dot-size-{Size.ToDescriptionString()}") .AddClass($"mud-elevation-{Elevation.ToString()}") .Build(); protected string DotInnerClassnames => new CssBuilder("mud-timeline-item-dot-inner") .AddClass($"mud-timeline-dot-fill", Variant == Variant.Filled) .AddClass($"mud-timeline-dot-{Color.ToDescriptionString()}") .Build(); [CascadingParameter] protected internal ItemsControlBase Parent { get; set; } /// /// Dot Icon /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public string Icon { get; set; } /// /// Variant of the dot. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public Variant Variant { get; set; } = Variant.Outlined; /// /// User styles, applied to the lineItem dot. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public string DotStyle { get; set; } /// /// Color of the dot. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public ThemeColor Color { get; set; } = ThemeColor.Default; /// /// Size of the dot. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public Size Size { get; set; } = Size.Small; /// /// Elevation of the dot. The higher the number, the heavier the drop-shadow. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public int Elevation { set; get; } = 1; /// /// Overrides Timeline Parents default sorting method in Default and Reverse mode. /// [Parameter] [Category(CategoryTypes.Timeline.Behavior)] public TimelineAlign TimelineAlign { get; set; } /// /// If true, dot will not be displayed. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public bool HideDot { get; set; } /// /// If used renders child content of the ItemOpposite. /// [Parameter] [Category(CategoryTypes.Timeline.Behavior)] public RenderFragment ItemOpposite { get; set; } /// /// If used renders child content of the ItemContent. /// [Parameter] [Category(CategoryTypes.Timeline.Behavior)] public RenderFragment ItemContent { get; set; } /// /// If used renders child content of the ItemDot. /// [Parameter] [Category(CategoryTypes.Timeline.Dot)] public RenderFragment ItemDot { get; set; } /// /// Optional child content if no other RenderFragments is used. /// [Parameter] [Category(CategoryTypes.Timeline.Behavior)] public RenderFragment ChildContent { get; set; } protected override Task OnInitializedAsync() { Parent?.Items.Add(this); return Task.CompletedTask; } private void Select() { var myIndex = Parent?.Items.IndexOf(this); Parent?.MoveTo(myIndex ?? 0); } public void Dispose() { Parent?.Items.Remove(this); } }