Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Akbar Ahmadi Saray committed Dec 4, 2023
1 parent 3ea225c commit 13e23ca
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
32 changes: 17 additions & 15 deletions Source/Enter.Ui/Components/Drawer/EntDrawer.razor
Original file line number Diff line number Diff line change
@@ -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


<aside class="@ClassNames" style="@StyleNames">@ChildContent</aside>
Expand All @@ -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);

}
Expand All @@ -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;
Expand All @@ -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;

Expand Down
17 changes: 15 additions & 2 deletions Source/Enter.Ui/Components/Drawer/EntDrawerContainer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Source/Enter.Ui/Enter.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PackageId>Enter.Ui</PackageId>
<Version>1.0.94</Version>
<Version>1.0.95</Version>
<Authors>Akbar Ahmadi</Authors>
<Company>AhmadiCo</Company>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
Expand Down
2 changes: 1 addition & 1 deletion example/Enter.Dashboard/Shared/DocumentLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<EntButton @onclick="@(() => _isSideDrawerOpen = !_isSideDrawerOpen)" Icon="EntIconName.Note"/>
</EntAppBar>
<EntDrawerContainer class="flex-grow-1">
<EntDrawer Width="300" HasBackdrop="HasBackdrop" @bind-Open="_isDrawerOpen" Direction="EntDrawerDirection.Start" Mode="_drawerMode" >
<EntDrawer Width="300" HasBackdrop="HasBackdrop" @bind-Open="_isDrawerOpen" Direction="EntDrawerDirection.Start" AutoResponsive>
<EntNavMenu class="border-0">
<EntNavMenuTextItem Icon="@EntIconName.Dashboard" Text="Buttons" Click="NewTab"/>
<EntNavMenuGroup Icon="@EntIconName.Dashboard" Title="Documents">
Expand Down

0 comments on commit 13e23ca

Please sign in to comment.