diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/OffcanvasDocumentation.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/OffcanvasDocumentation.razor index 2dcf7ec27..73b877ab1 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/OffcanvasDocumentation.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/OffcanvasDocumentation.razor @@ -64,6 +64,13 @@ +
+
Set the responsive behaviour of the Offcanvas with the Responsive parameter. The default value is OffcanvasResponsive.Always.
+
Responsive offcanvas hide content outside the viewport from a specified breakpoint and down. Above that breakpoint, the contents within will behave as usual. For example, OffcanvasResponsive.LargeDown hides content in an offcanvas below the lg breakpoint, but shows the content above the lg breakpoint. Responsive offcanvas are available for each breakpoint.
+ + Both body and footer will be shown above the responsive breakpoint by default. Optionally use the FooterCssClass parameter to control visibility of the footer. +
+ @code { private const string pageUrl = DemoRouteConstants.Demos_URL_Offcanvas; private const string pageTitle = "Blazor Offcanvas"; diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/Offcanvas_Demo_07_Responsive.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/Offcanvas_Demo_07_Responsive.razor new file mode 100644 index 000000000..05d9c5518 --- /dev/null +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Offcanvas/Offcanvas_Demo_07_Responsive.razor @@ -0,0 +1,20 @@ +Resize your browser to show the responsive offcanvas button. + + + +

This is content within an Offcanvas with OffcanvasResponsive.LargeDown.

+
+ + + +
+ + + +@code { + private Offcanvas offcanvas = default!; + private async Task OnShowOffcanvasClick() => await offcanvas.ShowAsync(); +} diff --git a/blazorbootstrap/Components/Offcanvas/Offcanvas.razor b/blazorbootstrap/Components/Offcanvas/Offcanvas.razor index c88ac52e7..ec81c4607 100644 --- a/blazorbootstrap/Components/Offcanvas/Offcanvas.razor +++ b/blazorbootstrap/Components/Offcanvas/Offcanvas.razor @@ -16,7 +16,7 @@ @if (ShowCloseButton) { - + } } diff --git a/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs b/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs index f84ebc3c8..d70eb19aa 100644 --- a/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs +++ b/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs @@ -107,7 +107,7 @@ private async Task ShowAsync(string? title, Type? type, Dictionary BuildClassNames(Class, - (BootstrapClass.Offcanvas, true), + (Responsive.ToOffcanvasResponsiveClass(), true), (Placement.ToOffcanvasPlacementClass(), true), (Size.ToOffcanvasSizeClass(), true)); @@ -251,6 +251,18 @@ private async Task ShowAsync(string? title, Type? type, Dictionary + /// Gets or sets the offcanvas responsive behavior. + /// + /// + /// Default value is . + /// + [AddedVersion("3.6.0")] + [DefaultValue(OffcanvasResponsive.Always)] + [Description("Gets or sets the offcanvas responsive behavior.")] + [Parameter] + public OffcanvasResponsive Responsive { get; set; } = OffcanvasResponsive.Always; + /// /// If , modal shows close button in the header. /// diff --git a/blazorbootstrap/Constants/BootstrapClass.cs b/blazorbootstrap/Constants/BootstrapClass.cs index d8ee08c56..3355b9f55 100644 --- a/blazorbootstrap/Constants/BootstrapClass.cs +++ b/blazorbootstrap/Constants/BootstrapClass.cs @@ -114,8 +114,6 @@ public static class BootstrapClass public const string NavTabs = "nav-tabs"; public const string NavUnderline = "nav-underline"; - public const string Offcanvas = "offcanvas"; - public const string PageLoadingModal = "modal-page-loading"; public const string Pagination = "pagination"; diff --git a/blazorbootstrap/Enums/OffcanvasResponsive.cs b/blazorbootstrap/Enums/OffcanvasResponsive.cs new file mode 100644 index 000000000..b52139764 --- /dev/null +++ b/blazorbootstrap/Enums/OffcanvasResponsive.cs @@ -0,0 +1,34 @@ +namespace BlazorBootstrap; + +public enum OffcanvasResponsive +{ + /// + /// Always hide content offcanvas. + /// + Always, + + /// + /// Hide content offcanvas bellow "small" breakpoint (576px). + /// + SmallDown, + + /// + /// Hide content offcanvas bellow "medium" breakpoint (768px). + /// + MediumDown, + + /// + /// Hide content offcanvas bellow "large" breakpoint (992px). + /// + LargeDown, + + /// + /// Hide content offcanvas bellow "extra-large" breakpoint (1200px). + /// + ExtraLargeDown, + + /// + /// Hide content offcanvas bellow "XXL" breakpoint (1400px). + /// + ExtraExtraLargeDown +} diff --git a/blazorbootstrap/Extensions/EnumExtensions.cs b/blazorbootstrap/Extensions/EnumExtensions.cs index 336389fd6..b0181d4da 100644 --- a/blazorbootstrap/Extensions/EnumExtensions.cs +++ b/blazorbootstrap/Extensions/EnumExtensions.cs @@ -353,6 +353,18 @@ public static string ToOffcanvasPlacementClass(this Placement placement) => _ => "offcanvas-bottom" }; + public static string ToOffcanvasResponsiveClass(this OffcanvasResponsive offcanvasResponsive) => + offcanvasResponsive switch + { + OffcanvasResponsive.Always => "offcanvas", + OffcanvasResponsive.SmallDown => "offcanvas-sm", + OffcanvasResponsive.MediumDown => "offcanvas-md", + OffcanvasResponsive.LargeDown => "offcanvas-lg", + OffcanvasResponsive.ExtraLargeDown => "offcanvas-xl", + OffcanvasResponsive.ExtraExtraLargeDown => "offcanvas-xxl", + _ => "offcanvas" + }; + public static string ToOffcanvasSizeClass(this OffcanvasSize offcanvasSize) => offcanvasSize switch {