Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<div class="table-attr">
<div class="table-attr">
<h4>@Title</h4>

<Table TItem="AttributeItem" Items="Items">
<Table TItem="AttributeItem" Items="Items" ShowFooter="@ShowFooter">
<TableColumns>
<TableColumn @bind-Field="@context.Name" />
<TableColumn @bind-Field="@context.Description" TextWrap="true" />
<TableColumn @bind-Field="@context.Type" />
<TableColumn @bind-Field="@context.ValueList" TextWrap="true" />
<TableColumn @bind-Field="@context.DefaultValue" />
<TableColumn @bind-Field="@context.Version" />
</TableColumns>
<TableFooter>
<TableFooterCell Text="合计:" colspan="3" Align="Alignment.Left" />
<TableFooterCell Aggregate="AggregateType.Count" Field="@nameof(AttributeItem.Name)" />
</TableFooter>
</Table>
</div>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Server.Components.Components;

/// <summary>
///
/// 组件参数表格组件
/// </summary>
public sealed partial class AttributeTable
{
Expand All @@ -15,24 +15,42 @@ public sealed partial class AttributeTable
private IStringLocalizer<AttributeTable>? Localizer { get; set; }

/// <summary>
///
/// 获得/设置 表格标题
/// </summary>
[Parameter]
[NotNull]
public string? Title { get; set; }

/// <summary>
///
/// 获得/设置 表格数据
/// </summary>
[Parameter] public IEnumerable<AttributeItem>? Items { get; set; }
[Parameter]
public IEnumerable<AttributeItem> Items { get; set; } = [];

/// <summary>
/// 获得/设置 表格关联组件类型
/// </summary>
[Parameter]
public Type? Type { get; set; }

/// <summary>
/// OnInitialized 方法
/// 是否显示合计信息 默认 false
/// </summary>
[Parameter]
public bool ShowFooter { get; set; }

/// <summary>
/// <inheritdoc/>
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();

Title ??= Localizer[nameof(Title)];

if (Type != null)
{
Items = ComponentAttributeCacheService.GetAttributes(Type);
}
}
}
22 changes: 12 additions & 10 deletions src/BootstrapBlazor.Server/Components/Samples/Circles.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@

<DemoBlock Title="@Localizer["BasicUsageTitle"]" Introduction="@Localizer["BasicUsageIntro"]" Name="Normal">
<Circle Value="@_circleValue" />
<section ignore class="btn-group mt-3 d-block">
<button class="btn btn-primary" @onclick="e => Add(10)">
<i class="fa-solid fa-plus"></i>
<span>@Localizer["IncreaseSpan"] 10</span>
</button>
<button class="btn btn-info" @onclick="e => Add(-10)">
<i class="fa-solid fa-minus"></i>
<span>@Localizer["DecreaseSpan"] 10</span>
</button>
<section ignore class="mt-3">
<div class="btn-group">
<button class="btn btn-primary" @onclick="e => Add(10)">
<i class="fa-solid fa-plus"></i>
<span>@Localizer["IncreaseSpan"] 10</span>
</button>
<button class="btn btn-info" @onclick="e => Add(-10)">
<i class="fa-solid fa-minus"></i>
<span>@Localizer["DecreaseSpan"] 10</span>
</button>
</div>
</section>
</DemoBlock>

Expand Down Expand Up @@ -53,4 +55,4 @@
</Circle>
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />
<AttributeTable Type="@typeof(Circle)" />
58 changes: 1 addition & 57 deletions src/BootstrapBlazor.Server/Components/Samples/Circles.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand All @@ -17,61 +17,5 @@ private void Add(int interval)
_circleValue += interval;
_circleValue = Math.Min(100, Math.Max(0, _circleValue));
}

/// <summary>
/// GetAttributes
/// </summary>
/// <returns></returns>
private AttributeItem[] GetAttributes() =>
[
new()
{
Name = "Width",
Description = Localizer["Width"],
Type = "int",
ValueList = "",
DefaultValue = "120"
},
new()
{
Name = "StrokeWidth",
Description = Localizer["StrokeWidth"],
Type = "int",
ValueList = "",
DefaultValue = "2"
},
new()
{
Name = "Value",
Description = Localizer["Value"],
Type = "int",
ValueList = "0-100",
DefaultValue = "0"
},
new()
{
Name = "Color",
Description = Localizer["Color"],
Type = "Color",
ValueList = "Primary / Secondary / Success / Danger / Warning / Info / Dark",
DefaultValue = "Primary"
},
new()
{
Name = "ShowProgress",
Description = Localizer["ShowProgress"],
Type = "bool",
ValueList = "true / false",
DefaultValue = "true"
},
new()
{
Name = "ChildContent",
Description = Localizer["ChildContent"],
Type = "RenderFragment",
ValueList = "",
DefaultValue = ""
}
];
}

16 changes: 7 additions & 9 deletions src/BootstrapBlazor.Server/Data/AttributeItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

using System.ComponentModel;

namespace BootstrapBlazor.Server.Data;

/// <summary>
Expand All @@ -15,30 +13,30 @@ public class AttributeItem
/// <summary>
/// 获得/设置 参数
/// </summary>
[DisplayName("参数")]
public string Name { get; set; } = "";

/// <summary>
/// 获得/设置 说明
/// </summary>
[DisplayName("说明")]
public string Description { get; set; } = "";

/// <summary>
/// 获得/设置 类型
/// </summary>
[DisplayName("类型")]
public string Type { get; set; } = "";

/// <summary>
/// 获得/设置 可选值
/// </summary>
[DisplayName("可选值")]
public string ValueList { get; set; } = "";

/// <summary>
/// 获得/设置 默认值
/// 获得/设置 版本
/// </summary>
public string Version { get; set; } = "";

/// <summary>
///
/// </summary>
[DisplayName("默认值")]
public string DefaultValue { get; set; } = "";
}
10 changes: 9 additions & 1 deletion src/BootstrapBlazor.Server/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<Project>

<Target Name="LLMs" AfterTargets="Publish" Condition="'$(TargetFramework)' == '$(RunTargetFramework)'">
<Target Name="LLMs" AfterTargets="Publish">
<Message Text="LLMs documentation generating ..." Importance="high"></Message>
<Exec Command="dotnet tool restore"></Exec>
<Exec Command="dotnet llms-docs --root=$(MSBuildThisFileDirectory) --output=$(PublishDir)"></Exec>
</Target>

<Target Name="CopyXmlDocs" AfterTargets="LLMs">
<ItemGroup>
<XmlDocsToCopy Include="%(Reference.RelativeDir)BootstrapBlazor*.xml" />
Comment thread
ArgoZhang marked this conversation as resolved.
</ItemGroup>
<Message Text="Copying XML docs to output path: $(PublishDir)" Importance="High" />
<Copy SourceFiles="@(XmlDocsToCopy)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="true" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
</Target>

</Project>
Loading