Skip to content

Commit

Permalink
Merge pull request #4 from skclusive/develop
Browse files Browse the repository at this point in the history
5.1.0 release
  • Loading branch information
skclusive authored Nov 21, 2020
2 parents 12840a8 + 2007fb1 commit ea96d1c
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 67 deletions.
2 changes: 1 addition & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<!-- <clear /> -->
<add key="blazor" value="https://dotnet.myget.org/f/blazor-dev/api/v3/index.json" />
<add key="aspnet" value="https://dotnet.myget.org/f/dotnet-core/api/v3/index.json" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
Expand Down
25 changes: 2 additions & 23 deletions src/Extension/LayoutExtension.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Skclusive.Core.Component;
using Skclusive.Material.Core;
using Skclusive.Material.Baseline;
using Skclusive.Material.Icon;
using Skclusive.Material.Avatar;
using Skclusive.Material.Typography;
using Skclusive.Material.Toolbar;
using Skclusive.Material.Hidden;
using Skclusive.Material.Grid;
using Skclusive.Material.AppBar;
using Skclusive.Material.Button;
using Skclusive.Material.List;
using Skclusive.Material.Drawer;
using Skclusive.Material.Component;

namespace Skclusive.Material.Layout
{
public static class LayoutExtension
{
public static void TryAddLayoutServices(this IServiceCollection services, ILayoutConfig config)
{
services.TryAddBaselineServices(config);
services.TryAddIconServices(config);
services.TryAddAvatarServices(config);
services.TryAddTypographyServices(config);
services.TryAddToolbarServices(config);
services.TryAddGridServices(config);
services.TryAddAppBarServices(config);
services.TryAddButtonServices(config);
services.TryAddListServices(config);
services.TryAddDrawerServices(config);
services.TryAddHiddenServices(config);
services.TryAddMaterialServices(config);

services.TryAddScoped<ILayoutConfig>((p) => config);

Expand Down
31 changes: 5 additions & 26 deletions src/Layout.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<VersionPrefix>5.0.1</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<TargetFramework>net5.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<RazorLangVersion>3.0</RazorLangVersion>
<AssemblyName>Skclusive.Material.Layout</AssemblyName>
<PackageId>Skclusive.Material.Layout</PackageId>
<RootNamespace>Skclusive.Material.Layout</RootNamespace>
Expand All @@ -16,32 +17,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Skclusive.Material.Baseline" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Icon" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Avatar" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Hidden" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Typography" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Toolbar" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Hidden" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Grid" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.AppBar" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Button" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.List" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Drawer" Version="5.0.1" />
<PackageReference Include="Skclusive.Material.Component" Version="5.1.0" />
</ItemGroup>

<!-- <ItemGroup>
<ProjectReference Include="..\..\Skclusive.Material.Component\Baseline\src\Baseline.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Icon\src\Icon.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Avatar\src\Avatar.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Hidden\src\Hidden.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Typography\src\Typography.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Toolbar\src\Toolbar.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Hidden\src\Hidden.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Grid\src\Grid.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\AppBar\src\AppBar.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Button\src\Button.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\List\src\List.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Drawer\src\Drawer.csproj" Version="5.0.1" />
<ProjectReference Include="..\..\Skclusive.Material.Component\Material\src\Material.csproj" Version="5.1.0" />
</ItemGroup> -->
</Project>
4 changes: 2 additions & 2 deletions src/MainLayout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
Class="@SidebarClass"
Style="@SidebarStyle"
OnClose="@HandleSidebarClose"
Open="@SidebarOpen"
Variant="@SidebarVariant"
OpenPersistent="@SidebarOpenPersistent"
OpenTemporary="@SidebarOpenTemporary"
OnClick="@HandleSidebarClick">
@SidebarContent
</Sidebar>
Expand Down
49 changes: 43 additions & 6 deletions src/MainLayout/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public MainLayout() : base("MainLayout")

protected bool IsDesktop { set; get; } = false;

protected bool SidebarOpen { set; get; } = false;
protected bool SidebarOpenPersistent { set; get; } = false;

protected bool SidebarOpenTemporary { set; get; } = false;

protected override IEnumerable<string> Classes
{
Expand Down Expand Up @@ -109,13 +111,17 @@ protected virtual IEnumerable<string> ContentClasses

protected void HandleSidebarClose()
{
SidebarOpen = false;
System.Console.WriteLine($"HandleSidebarClose");

SidebarOpenTemporary = false;

StateHasChanged();
}

protected void HandleSidebarClick()
{
System.Console.WriteLine($"HandleSidebarClick");

if (!IsDesktop)
{
HandleSidebarClose();
Expand All @@ -124,7 +130,9 @@ protected void HandleSidebarClick()

protected void HandleSidebarToggle()
{
SidebarOpen = true;
System.Console.WriteLine($"HandleSidebarToggle");

SidebarOpenTemporary = true;

OnSidebarClick?.Invoke();

Expand All @@ -137,19 +145,46 @@ protected override Task OnInitializedAsync()

if (LayoutConfig.Responsive)
{
TimeoutDisposal = ExecutionPlan.Delay(500, () => {
TimeoutDisposal = SetTimeout(() => {
_ = MediaQueryMatcher.InitAsync("(min-width:1280px)");
});
}, 500);
}

return Task.CompletedTask;
}

private IDisposable MediaChangeDisposable;

protected void OnMediaQueryChanged(object sender, bool match)
{
IsDesktop = match;

SidebarOpen = IsDesktop;
System.Console.WriteLine($"OnMediaQueryChanged IsDesktop: {IsDesktop}");

MediaChangeDisposable?.Dispose();
MediaChangeDisposable = null;

if (IsDesktop)
{
System.Console.WriteLine($"Desktop. disabling temporary");

SidebarOpenTemporary = false;

MediaChangeDisposable = SetTimeout(() =>
{
SidebarOpenPersistent = true;

System.Console.WriteLine($"Desktop. enabling persistent");

_ = InvokeAsync(StateHasChanged);
}, 225);
}
else
{
SidebarOpenPersistent = false;

System.Console.WriteLine($"Mobile. disabling persistent");
}

_ = InvokeAsync(StateHasChanged);
}
Expand All @@ -158,6 +193,8 @@ protected override async ValueTask DisposeAsync()
{
TimeoutDisposal?.Dispose();

MediaChangeDisposable?.Dispose();

if (LayoutConfig.Responsive)
{
MediaQueryMatcher.OnChange -= OnMediaQueryChanged;
Expand Down
2 changes: 2 additions & 0 deletions src/MainLayout/MainLayoutStyle.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.MainLayout-Root {
height: 100%;
padding-top: 56px;
padding-left: 0px;
transition: padding-left 225ms cubic-bezier(0, 0, 0.2, 1) 0ms;
}

@media (min-width: 600px) {
Expand Down
22 changes: 19 additions & 3 deletions src/Sidebar/Sidebar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
@inherits MaterialComponent

<Drawer
RootRef="@RootRef"
Class="@_Class"
Style="@_Style"
Open="@Open"
Open="@OpenTemporary"
OnClose="@OnClose"
OnClick="@HandleClick"
Anchor="@Anchor.Left"
Variant="@Variant"
Variant="@DrawerVariant.Temporary"
PaperStyle="@_DrawerStyle"
PaperClass="@_DrawerClass"
@attributes="Attributes">
Expand All @@ -19,3 +18,20 @@
@ChildContent
</div>
</Drawer>
<Drawer
Class="@_Class"
Style="@_Style"
Open="@OpenPersistent"
OnClose="@OnClose"
OnClick="@HandleClick"
Anchor="@Anchor.Left"
Variant="@DrawerVariant.Persistent"
PaperStyle="@($"{_DrawerStyle};height: calc(100% - 64px);margin-top: 64px;")"
PaperClass="@_DrawerClass"
@attributes="Attributes">
<div
class="@_ContentClass"
style="@_ContentStyle">
@ChildContent
</div>
</Drawer>
12 changes: 6 additions & 6 deletions src/Sidebar/Sidebar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ public Sidebar() : base("Sidebar")
{
}

[Parameter]
public bool Open { set; get; }

[Parameter]
public DrawerVariant Variant { set; get; }

[Parameter]
public Action OnClose { set; get; }

Expand Down Expand Up @@ -47,6 +41,12 @@ public Sidebar() : base("Sidebar")
[Parameter]
public string DividerClass { set; get; }

[Parameter]
public bool OpenPersistent { set; get; }

[Parameter]
public bool OpenTemporary { set; get; }

protected virtual string _ContentStyle
{
get => CssUtil.ToStyle(ContentStyles, ContentStyle);
Expand Down

0 comments on commit ea96d1c

Please sign in to comment.