From 9f1214fd9f0859e8e9fea5417cd17ca1ccdbbd6a Mon Sep 17 00:00:00 2001 From: stm Date: Wed, 11 Jan 2023 14:15:10 +0100 Subject: [PATCH] DrawerContainer - Clipping fix --- .../Components/Drawer/Drawer.razor.cs | 2 +- .../Drawer/DrawerContainer.razor.cs | 6 ++-- .../Components/Image/Image.razor | 2 +- .../Components/Image/Image.razor.cs | 35 ++++++++++--------- .../Components/Main/MainContent.razor.cs | 1 + 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/Connected.Components/Components/Drawer/Drawer.razor.cs b/src/Connected.Components/Components/Drawer/Drawer.razor.cs index 84f0a11..48514dc 100644 --- a/src/Connected.Components/Components/Drawer/Drawer.razor.cs +++ b/src/Connected.Components/Components/Drawer/Drawer.razor.cs @@ -152,7 +152,7 @@ public partial class Drawer : UIComponent, IDisposable, INavigationEventReceiver #region Styling properties //old - private CssBuilder CompiledClassList + public CssBuilder CompiledClassList { get { diff --git a/src/Connected.Components/Components/Drawer/DrawerContainer.razor.cs b/src/Connected.Components/Components/Drawer/DrawerContainer.razor.cs index 9e0680d..7bf5c7a 100644 --- a/src/Connected.Components/Components/Drawer/DrawerContainer.razor.cs +++ b/src/Connected.Components/Components/Drawer/DrawerContainer.razor.cs @@ -24,10 +24,12 @@ public partial class DrawerContainer : UIComponent private string GetDrawerClass(Drawer drawer) { + if (drawer == null) return string.Empty; + else return drawer.CompiledClassList.Build(); - var className = $"drawer-{(drawer.Open ? "open" : "close")}-{drawer.Variant.ToDescription()}"; + /*var className = $"drawer-{(drawer.Open ? "open" : "close")}-{drawer.Variant.ToDescription()}"; if (drawer.Variant is DrawerVariant.Responsive or DrawerVariant.Mini) { className += $"-{drawer.Breakpoint.ToDescription()}"; @@ -36,7 +38,7 @@ public partial class DrawerContainer : UIComponent className += $"drawer-{drawer.GetPosition()}-clipped-{drawer.ClipMode.ToDescription()}"; - return className; + return className;*/ } private Drawer FindLeftDrawer() diff --git a/src/Connected.Components/Components/Image/Image.razor b/src/Connected.Components/Components/Image/Image.razor index 994588c..13d5db2 100644 --- a/src/Connected.Components/Components/Image/Image.razor +++ b/src/Connected.Components/Components/Image/Image.razor @@ -1,4 +1,4 @@ @namespace Connected.Components @inherits UIComponent -@Alt \ No newline at end of file +@Alt \ No newline at end of file diff --git a/src/Connected.Components/Components/Image/Image.razor.cs b/src/Connected.Components/Components/Image/Image.razor.cs index e9feb7d..c08b2b4 100644 --- a/src/Connected.Components/Components/Image/Image.razor.cs +++ b/src/Connected.Components/Components/Image/Image.razor.cs @@ -11,68 +11,71 @@ namespace Connected.Components; public partial class Image : UIComponent { - protected string Classname => - new CssBuilder("image") - .AddClass("fluid", Fluid) - .AddClass($"object-{ObjectFit.ToDescription()}") - .AddClass($"object-{ObjectPosition.ToDescription()}") - .AddClass($"elevation-{Elevation}", Elevation > 0) - .AddClass(AdditionalClassList) - .Build(); + + private CssBuilder CompiledClassList + { + get + { + return new CssBuilder("image") + .AddClass("fluid", Fluid) + .AddClass($"object-{ObjectFit.ToDescription()}") + .AddClass($"object-{ObjectPosition.ToDescription()}") + .AddClass($"elevation-{Elevation}", Elevation > 0) + .AddClass(ClassList); + } + } /// /// Applies the fluid class so the image scales with the parent width. /// [Parameter] - [Category(CategoryTypes.Image.Behavior)] public bool Fluid { get; set; } /// /// Specifies the path to the image. /// [Parameter] - [Category(CategoryTypes.Image.Behavior)] public string Src { get; set; } /// /// Specifies an alternate text for the image. /// [Parameter] - [Category(CategoryTypes.Image.Behavior)] public string Alt { get; set; } /// /// Specifies the height of the image in px. /// [Parameter] - [Category(CategoryTypes.Image.Appearance)] public int? Height { get; set; } /// /// Specifies the width of the image in px. /// [Parameter] - [Category(CategoryTypes.Image.Appearance)] public int? Width { get; set; } /// /// The higher the number, the heavier the drop-shadow. /// [Parameter] - [Category(CategoryTypes.Image.Appearance)] public int Elevation { set; get; } /// /// Controls how the image should be resized. /// [Parameter] - [Category(CategoryTypes.Image.Appearance)] public ObjectFit ObjectFit { set; get; } = ObjectFit.Fill; /// /// Controls how the image should positioned within its container. /// [Parameter] - [Category(CategoryTypes.Image.Appearance)] public Position ObjectPosition { set; get; } = Position.Center; + + /// + /// A space separated list of class names, added on top of the default class list. + /// + [Parameter] + public string? ClassList { get; set; } } diff --git a/src/Connected.Components/Components/Main/MainContent.razor.cs b/src/Connected.Components/Components/Main/MainContent.razor.cs index f98e584..c29709c 100644 --- a/src/Connected.Components/Components/Main/MainContent.razor.cs +++ b/src/Connected.Components/Components/Main/MainContent.razor.cs @@ -12,6 +12,7 @@ public partial class MainContent .AddClass(ClassList); } } + [Parameter] public RenderFragment ChildContent { get; set; }