Enterprise-level component library based on Bootstrap and Blazor
gitee
version
license
download
repo
commit
build
coverage

Timeline

Visualize time flow information

Timeline can be split into multiple activities arranged in positive or reverse order of timestamps, which are an important feature that distinguishes them from other controls, and should be used with care to distinguish them from steps bar.

Demo
sort:
  • Creation time
    2022-08-13
  • Approved
    2022-08-14
  • The event starts on schedule
    2022-08-15

You can customize the node color according to the actual scene, or use the icon directly.

Demo
  • The default style of the node
    2022-08-13
  • Support for custom colors
    2022-08-15
  • Icons are supported
    2022-08-16

Content takes turns appearing on the left side of the timeline

Demo

Control the content appearing on the left side of the timeline by setting the IsLeft property

  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
  • Network problems being solved 2015-09-01
  • Create a services site 2015-09-01

内容在时间轴两侧轮流出现

Demo

Control the alternating timeline left and right by setting the IsAlternate property

  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
  • Network problems being solved 2015-09-01
  • Create a services site 2015-09-01

Custom components are displayed on the timeline

Demo

Control the custom components that the timeline displays by setting the CustomerComponent of the TimelineItem

  • Monitor
    8/13/2022 11:56:20 AM +08:00: Dispatch Message
    Real-time output
  • Counter

    Current count: 0

    Counter
  • Weather forecast

    This component demonstrates fetching data from a service.

    Date Temp. (C) Temp. (F) Summary
    8/14/2022 36 96 Cool
    8/15/2022 26 78 Freezing
    8/16/2022 42 107 Mild
    8/17/2022 -19 -2 Bracing
    8/18/2022 48 118 Balmy
    Weather forecast information

Attributes

Loading...

TimelineItem attributes

Loading...
@page "/timelines"
@inject IStringLocalizer<Timelines> Localizer

<h3>Timeline</h3>

<h4>Visualize time flow information</h4>

<DemoBlock Title="Basic usage" Introduction="Timeline can be split into multiple activities arranged in positive or reverse order of timestamps, which are an important feature that distinguishes them from other controls, and should be used with care to distinguish them from steps bar." Name="Normal">
    <div class="d-flex mb-3 align-items-center">
        <div class="text-nowrap me-1">sort:</div>
        <RadioList class="flex-fill" TValue="SelectedItem" OnSelectedChanged="@OnStateChanged" Items="@Items"></RadioList>
    </div>
    <Timeline Items="TimelineItems" IsReverse="@IsReverse"></Timeline>
</DemoBlock>

<DemoBlock Title="Customize the node style" Introduction="You can customize the node color according to the actual scene, or use the icon directly." Name="CutomNodeStyle">
    <Timeline Items="CustomerTimelineItems" />
</DemoBlock>

<DemoBlock Title="Shown on the left" Introduction="Content takes turns appearing on the left side of the timeline" Name="Left">
    <p>Control the content appearing on the left side of the timeline by setting the <code>IsLeft</code> property</p>
    <Timeline Items="AlternateTimelineItems" IsLeft="true" />
</DemoBlock>

<DemoBlock Title="Alternate presentations" Introduction="内容在时间轴两侧轮流出现" Name="Alternate">
    <p>Control the alternating timeline left and right by setting the <code>IsAlternate</code> property</p>
    <Timeline Items="AlternateTimelineItems" IsAlternate="true" />
</DemoBlock>

<DemoBlock Title="Show custom components" Introduction="Custom components are displayed on the timeline" Name="DispalyCustomComponent">
    <p>Control the custom components that the timeline displays by setting the <code>CustomerComponent</code> of the <code>TimelineItem</code></p>
    <Timeline Items="GetCustomerComponentTimelineItems()" />
</DemoBlock>

<AttributeTable Items="GetAttributes()" />

<AttributeTable Items="GetTimelineItemAttributes()" Title="TimelineItem attributes" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Common;
using BootstrapBlazor.Shared.Components;
using System.Collections.Concurrent;

namespace BootstrapBlazor.Shared.Samples;

/// <summary>
/// 
/// </summary>
public sealed partial class Timelines
{
    private readonly ConcurrentQueue<ConsoleMessageItem> _messages = new();

    private readonly CancellationTokenSource _cancelTokenSource = new();

    private readonly AutoResetEvent _locker = new(true);

    private IEnumerable<ConsoleMessageItem> Messages => _messages;

    private bool IsReverse { get; set; }

    private static Color GetColor()
    {
        var second = DateTime.Now.Second;
        return (second % 3) switch
        {
            1 => Color.Danger,
            2 => Color.Info,
            _ => Color.None
        };
    }

    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        var _ = Task.Run(async () =>
        {
            do
            {
                _locker.WaitOne();
                _messages.Enqueue(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message", Color = GetColor() });

                if (_messages.Count > 8)
                {
                    _messages.TryDequeue(out var _);
                }
                await InvokeAsync(StateHasChanged);
                _locker.Set();
                await Task.Delay(2000, _cancelTokenSource.Token);
            }
            while (!_cancelTokenSource.IsCancellationRequested);
        });

        Items = new SelectedItem[]
        {
                new SelectedItem("1", Localizer["SelectedItem1"]) { Active=true },
                new SelectedItem("2", Localizer["SelectedItem2"])
        };
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="values"></param>
    /// <param name="value"></param>

    public Task OnStateChanged(IEnumerable<SelectedItem> values, SelectedItem value)
    {
        IsReverse = value.Text == Localizer["SelectedItem2"];
        StateHasChanged();
        return Task.CompletedTask;
    }

    /// <summary>
    /// 
    /// </summary>
    private IEnumerable<SelectedItem> Items { get; set; } = Enumerable.Empty<SelectedItem>();

    /// <summary>
    /// 
    /// </summary>
    private IEnumerable<TimelineItem> TimelineItems => new TimelineItem[]
    {
        new TimelineItem
        {
            Content = Localizer["TimelineItemContent1"],
            Description = DateTime.Now.ToString("yyyy-MM-dd")
        },
        new TimelineItem
        {
            Content =  Localizer["TimelineItemContent2"],
            Description = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")
        },
        new TimelineItem
        {
            Content =  Localizer["TimelineItemContent3"],
            Description = DateTime.Now.AddDays(2).ToString("yyyy-MM-dd")
        }
    };

    /// <summary>
    /// 
    /// </summary>
    private IEnumerable<TimelineItem> CustomerTimelineItems => new TimelineItem[]
    {
        new TimelineItem
        {
            Content = Localizer["TimelineItemContent4"],
            Description = DateTime.Now.ToString("yyyy-MM-dd")
        },
        new TimelineItem
        {
            Color = Color.Success,
            Content = Localizer["TimelineItemContent5"],
            Description = DateTime.Now.AddDays(2).ToString("yyyy-MM-dd")
        },
        new TimelineItem
        {
            Color = Color.Danger,
            Icon = "fa fa-fw fa-fa",
            Content = Localizer["TimelineItemContent6"],
            Description = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd")
        }
    };

    /// <summary>
    /// 
    /// </summary>
    private IEnumerable<TimelineItem> GetCustomerComponentTimelineItems() => new TimelineItem[]
    {
        new TimelineItem
        {
            Color = Color.Success,
            Component = BootstrapDynamicComponent.CreateComponent<BootstrapBlazor.Components.Console>(new Dictionary<string, object?>
            {
                [nameof(BootstrapBlazor.Components.Console.Items)] = Messages
            }),
            Description = Localizer["Description1"]
        },
        new TimelineItem
        {
            Color = Color.Info,
            Component = BootstrapDynamicComponent.CreateComponent<Counter>(),
            Description = Localizer["Description2"]
        },
        new TimelineItem
        {
            Color = Color.Warning,
            Component = BootstrapDynamicComponent.CreateComponent<FetchData>(),
            Description = Localizer["Description3"]
        }
    };

    /// <summary>
    /// 
    /// </summary>
    private readonly IEnumerable<TimelineItem> AlternateTimelineItems = new TimelineItem[]
    {
        new TimelineItem
        {
            Content = "Create a services site 2015-09-01",
        },
        new TimelineItem
        {
            Color = Color.Success,
            Content = "Solve initial network problems 2015-09-01",
        },
        new TimelineItem
        {
            Color = Color.Danger,
            Content = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.",
        },
        new TimelineItem
        {
            Color = Color.Warning,
            Content = "Network problems being solved 2015-09-01",
        },
        new TimelineItem
        {
            Color = Color.Info,
            Content = "Create a services site 2015-09-01",
        }
    };

    /// <summary>
    /// 获得属性方法
    /// </summary>
    /// <returns></returns>
    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
        // TODO: 移动到数据库中
        new AttributeItem() {
            Name = "Items",
            Description = Localizer["Items"],
            Type = "IEnumerable<TimelineItem>",
            ValueList = "—",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "IsReverse",
            Description = Localizer["IsReverse"],
            Type = "boolean",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem() {
            Name = "IsLeft",
            Description = Localizer["IsLeft"],
            Type = "boolean",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem() {
            Name = "IsAlternate",
            Description = Localizer["IsAlternate"],
            Type = "boolean",
            ValueList = "true|false",
            DefaultValue = "false"
        }
    };

    /// <summary>
    /// 获得属性方法
    /// </summary>
    /// <returns></returns>
    private IEnumerable<AttributeItem> GetTimelineItemAttributes() => new AttributeItem[]
    {
        new AttributeItem() {
            Name = nameof(TimelineItem.Color),
            Description = Localizer["Color"],
            Type = "Color",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = nameof(TimelineItem.Content),
            Description = Localizer["Content"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = nameof(TimelineItem.Icon),
            Description = Localizer["Icon"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = nameof(TimelineItem.Description),
            Description = Localizer["Description"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = nameof(TimelineItem.Component),
            Description = Localizer["Component"],
            Type = nameof(BootstrapDynamicComponent),
            ValueList = " — ",
            DefaultValue = " — "
        }
    };
}

B 站相关视频链接

暂无

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
Themes
Bootstrap
Motronic
Ant Design (完善中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload
Seems like the connection with the server has been lost. It can be due to poor or broken network. Please hang on while we're trying to reconnect...
Oh snap! Failed to reconnect with the server. This is typically caused by a longer network outage, or if the server has been taken down. You can try to reconnect, but if that does not work, you need to reload the page.
Oh man! The server rejected the attempt to reconnect. The only option now is to reload the page, but be prepared that it won't work, since this is typically caused by a failure on the server.
Bootstrap Blazor 组件库 更新到 6.6.0

首先感谢您对本套组件的关注,本目前本套组件已经拥有超过 120 个组件,本组件是基于 Bootstrap 风格的 Blazor 企业级组件库,提供如布局、导航、表单、数据、通知、图标、语音等几大类通用组件,每一个组件都经过静心设计,具有模块化、响应式和优秀的性能。从更多实际场景出发,满足多种场景的需求,极大的减少开发者时间成本,大大缩短开发周期,大幅提高开发效率,并提供了一套 通用权限管理系统 示例工程。Bootstrap Blazor 产品是由一支专业的全职技术团队进行维护,高效的响应速度,多元化的解决方案,长期提供支持,并提供企业级支持。目前已在多家知名国企内部使用,项目最高在线 1200 人稳定运行。右侧为国内人数最多的中文 Blazor QQ 社区二维码,欢迎扫描加群。

组件更新到 6.6.0 更新日志 [传送门] 如果组件给您带来了方便,请您帮忙给项目点亮 Star github gitee

QQGroup
QQ 795206915