|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the Apache 2.0 License |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | +// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone |
| 5 | + |
| 6 | +namespace BootstrapBlazor.Components; |
| 7 | + |
| 8 | +/// <summary> |
| 9 | +/// ShieldBadge component |
| 10 | +/// </summary> |
| 11 | +public partial class ShieldBadge |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Gets or sets the icon. Default is null. |
| 15 | + /// </summary> |
| 16 | + [Parameter] |
| 17 | + public string? Icon { get; set; } |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// Gets or sets the icon color. Default is null. |
| 21 | + /// </summary> |
| 22 | + [Parameter] |
| 23 | + public string? IconColor { get; set; } |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Gets or sets the text of badge. Default is null. |
| 27 | + /// </summary> |
| 28 | + [Parameter] |
| 29 | + public string? Text { get; set; } |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Gets or sets the text color. Default is null. |
| 33 | + /// </summary> |
| 34 | + [Parameter] |
| 35 | + public string? TextColor { get; set; } |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Gets or sets the text background color. Default is null. |
| 39 | + /// </summary> |
| 40 | + [Parameter] |
| 41 | + public string? TextBackgroundColor { get; set; } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Gets or sets the label of badge. Default is null. |
| 45 | + /// </summary> |
| 46 | + [Parameter] |
| 47 | + public string? Label { get; set; } |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// Gets or sets the label color of badge. Default is null. |
| 51 | + /// </summary> |
| 52 | + [Parameter] |
| 53 | + public string? LabelColor { get; set; } |
| 54 | + |
| 55 | + /// <summary> |
| 56 | + /// Gets or sets the label background color. Default is null. |
| 57 | + /// </summary> |
| 58 | + [Parameter] |
| 59 | + public string? LabelBackgroundColor { get; set; } |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Gets or sets the badge radius. Default is 3. |
| 63 | + /// </summary> |
| 64 | + [Parameter] |
| 65 | + public int Radius { get; set; } = 3; |
| 66 | + |
| 67 | + private string? ClassString => CssBuilder.Default("shield-badge") |
| 68 | + .AddClassFromAttributes(AdditionalAttributes) |
| 69 | + .Build(); |
| 70 | + |
| 71 | + private string? StyleString => CssBuilder.Default() |
| 72 | + .AddStyle("--bb-shield-badge-icon-color", IconColor, !string.IsNullOrEmpty(IconColor)) |
| 73 | + .AddStyle("--bb-shield-badge-label-color", LabelColor, !string.IsNullOrEmpty(LabelColor)) |
| 74 | + .AddStyle("--bb-shield-badge-label-bg", LabelBackgroundColor, !string.IsNullOrEmpty(LabelBackgroundColor)) |
| 75 | + .AddStyle("--bb-shield-badge-text-color", TextColor, !string.IsNullOrEmpty(TextColor)) |
| 76 | + .AddStyle("--bb-shield-badge-text-bg", TextBackgroundColor, !string.IsNullOrEmpty(TextBackgroundColor)) |
| 77 | + .AddStyle("--bb-shield-badge-radius", $"{Math.Max(0, Radius)}px", Radius != 3) |
| 78 | + .Build(); |
| 79 | + |
| 80 | + private string? IconString => CssBuilder.Default("shield-badge-icon") |
| 81 | + .AddClass(Icon, !string.IsNullOrEmpty(Icon)) |
| 82 | + .Build(); |
| 83 | +} |
0 commit comments