From 88710e4e3b79350a4b10550e1cb52440a0cab1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Wed, 21 Dec 2022 15:51:12 +0100 Subject: [PATCH] Refactor the alert component All styling properties and classes have been removed in favor of named subcomponents. Any and all component styling should be through classes. --- .../Components/Alert/Alert.razor | 4 +- .../Components/Alert/Alert.razor.cs | 46 ++----------------- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/src/Connected.Components/Components/Alert/Alert.razor b/src/Connected.Components/Components/Alert/Alert.razor index 6d2452f..3507094 100644 --- a/src/Connected.Components/Components/Alert/Alert.razor +++ b/src/Connected.Components/Components/Alert/Alert.razor @@ -6,12 +6,12 @@ class="@CompiledClassList" @attributes="CustomAttributes" @onclick="Clicked"> -
+
@if (GlyphVisible) {
- +
} diff --git a/src/Connected.Components/Components/Alert/Alert.razor.cs b/src/Connected.Components/Components/Alert/Alert.razor.cs index 64cff52..d73010b 100644 --- a/src/Connected.Components/Components/Alert/Alert.razor.cs +++ b/src/Connected.Components/Components/Alert/Alert.razor.cs @@ -6,18 +6,6 @@ namespace Connected.Components; public partial class Alert : UIComponent { - /// - /// Defines the classlist used in aligning the alert content internally. - /// - private CssBuilder CompiledAlignmentClassList - { - get - { - return new CssBuilder("alert-position") - .AddClass($"justify-sm-{HorizontalAlignment.GetAbsolute(RightToLeft)}"); - } - } - /// /// Contains the default container classlist and the user defined classes. /// @@ -27,9 +15,6 @@ public partial class Alert : UIComponent { return new CssBuilder("alert") .AddClass($"alert-{Variant}-{Severity}") - .AddClass($"dense", Dense) - .AddClass($"square", Square) - .AddClass($"elevation-{Elevation}") .AddClass(ClassList); } } @@ -64,16 +49,10 @@ public partial class Alert : UIComponent /// Custom glyph, leave unset to use the standard glyph which depends on the Severity. /// [Parameter] - public string CustomGlyph { get; set; } = default!; + public string Glyph { get; set; } = default!; #endregion #region Styling properties - /// - /// Sets the horizontal alignement of the text. Start and end depend on the property. - /// - [Parameter] - public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Start; - /// /// A space separated list of class names, added on top of the default class list. /// @@ -86,18 +65,6 @@ public partial class Alert : UIComponent [Parameter] public bool CloseGlyphVisible { get; set; } - /// - /// If true, compact padding will be used. - /// - [Parameter] - public bool Dense { get; set; } - - /// - /// The higher the number, the heavier the drop-shadow. 0 for no shadow. - /// - [Parameter] - public int Elevation { set; get; } = 0; - /// /// If true, no alert glyph will be used. /// @@ -107,6 +74,7 @@ public partial class Alert : UIComponent /// /// Specifies the control's display style /// + //TODO: Implement in DOM [CascadingParameter(Name = "RightToLeft")] public bool RightToLeft { get; set; } @@ -116,12 +84,6 @@ public partial class Alert : UIComponent [Parameter] public Severity Severity { get; set; } = Severity.Normal; - /// - /// If true, rounded corners are disabled. - /// - [Parameter] - public bool Square { get; set; } - /// /// The variant to use. /// @@ -131,10 +93,10 @@ public partial class Alert : UIComponent protected override void OnParametersSet() { - if (!string.IsNullOrEmpty(CustomGlyph)) + if (!string.IsNullOrEmpty(Glyph)) return; - CustomGlyph = GetGlyphForSeverity(Severity); + Glyph = GetGlyphForSeverity(Severity); } private string GetGlyphForSeverity(Severity severity)