diff --git a/Source/Enter.Ui/Components/Drawer/EntDrawer.razor b/Source/Enter.Ui/Components/Drawer/EntDrawer.razor index c9fb2d4..34a3118 100644 --- a/Source/Enter.Ui/Components/Drawer/EntDrawer.razor +++ b/Source/Enter.Ui/Components/Drawer/EntDrawer.razor @@ -1,7 +1,7 @@ @namespace Enter.Ui.Components @using Enter.Ui.Components.Drawer @using Enter.Ui.Cores.Core -@inherits Enter.Ui.Bases.EntBaseComponent +@inherits Enter.Ui.Bases.EntResponsiveComponent @@ -20,10 +20,11 @@ .AddClass("ent-drawer--close", !Open); base.BuildClasses(builder); } + protected override void BuildStyles(StyleBuilder builder) { - builder.AddStyle($"--ent-drawer-width: {Width}px"); + builder.AddStyle($"--ent-drawer-width: {DrawerContainer?.DrawersWidth}px"); base.BuildStyles(builder); } @@ -43,20 +44,25 @@ protected override void OnAfterRender(bool firstRender) { - if (WidthType is not null && firstRender) + if (firstRender) { - switch (WidthType) + if (Responsive) + { + Mode = EntDrawerMode.Overlay; + } + + switch (DrawerContainer.DrawersWidthType) { case EntDrawerWidthType.Custom: break; case EntDrawerWidthType.Full: - Width = DrawerContainer?.BoundingClientRect.ScrollWidth ?? 0; + DrawerContainer.DrawersWidth = DrawerContainer?.BoundingClientRect.ScrollWidth ?? 0; break; case EntDrawerWidthType.Half: - Width = DrawerContainer?.BoundingClientRect.ScrollWidth / 2 ??0; + DrawerContainer.DrawersWidth = DrawerContainer?.BoundingClientRect.ScrollWidth / 2 ??0; break; case EntDrawerWidthType.Quarter: - Width = DrawerContainer?.BoundingClientRect.ScrollWidth / 4 ??0; + DrawerContainer.DrawersWidth = DrawerContainer?.BoundingClientRect.ScrollWidth / 4 ??0; break; case null: break; @@ -74,15 +80,11 @@ [Parameter] public EntDrawerMode Mode { get; set; } = EntDrawerMode.Behavior; - - [Parameter] - public EntDrawerWidthType? WidthType { get; set; } = EntDrawerWidthType.Custom; - - [Parameter] - public double Width { get; set; } = 300; - + + + [CascadingParameter] - public EntDrawerContainer? DrawerContainer { get; set; } + public EntDrawerContainer DrawerContainer { get; set; } = default!; private bool _open = false; diff --git a/Source/Enter.Ui/Components/Drawer/EntDrawerContainer.razor b/Source/Enter.Ui/Components/Drawer/EntDrawerContainer.razor index 96139f3..5d77973 100644 --- a/Source/Enter.Ui/Components/Drawer/EntDrawerContainer.razor +++ b/Source/Enter.Ui/Components/Drawer/EntDrawerContainer.razor @@ -11,7 +11,8 @@ @using Enter.Ui.Cores.Contracts @using Enter.Ui.Cores.Core @using Enter.Ui.Cores.Models -@inherits Enter.Ui.Bases.EntBaseComponent +@using Enter.Ui.Components.Drawer +@inherits Enter.Ui.Bases.EntResponsiveComponent @code { @@ -21,6 +22,13 @@ [Inject] public IEntSharedJsService SharedJsService { get; set; } = default!; + [Parameter] + public EntDrawerWidthType? DrawersWidthType { get; set; } = EntDrawerWidthType.Custom; + + [Parameter] + public double DrawersWidth { get; set; } = 300; + + public BoundingClientRect BoundingClientRect { get; set; } = default!; public override string ComponentName => nameof(EntDrawerContainer); @@ -30,7 +38,12 @@ builder.AddClass("ent-drawer-container"); base.BuildClasses(builder); } - + protected override void BuildStyles(StyleBuilder builder) + { + builder.AddStyle($"--ent-drawer-width: {DrawersWidth}px"); + base.BuildStyles(builder); + + } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) diff --git a/Source/Enter.Ui/Enter.UI.csproj b/Source/Enter.Ui/Enter.UI.csproj index 24f3c13..1c47c31 100644 --- a/Source/Enter.Ui/Enter.UI.csproj +++ b/Source/Enter.Ui/Enter.UI.csproj @@ -5,7 +5,7 @@ enable enable Enter.Ui - 1.0.94 + 1.0.95 Akbar Ahmadi AhmadiCo Readme.md diff --git a/example/Enter.Dashboard/Shared/DocumentLayout.razor b/example/Enter.Dashboard/Shared/DocumentLayout.razor index d7c62fd..18c91ae 100644 --- a/example/Enter.Dashboard/Shared/DocumentLayout.razor +++ b/example/Enter.Dashboard/Shared/DocumentLayout.razor @@ -18,7 +18,7 @@ - +