+
@ChildContent
}
diff --git a/src/Connected.Components/Components/Drawer/DrawerHeader.razor.cs b/src/Connected.Components/Components/Drawer/DrawerHeader.razor.cs
index f600f53..58216f5 100644
--- a/src/Connected.Components/Components/Drawer/DrawerHeader.razor.cs
+++ b/src/Connected.Components/Components/Drawer/DrawerHeader.razor.cs
@@ -1,34 +1,58 @@
-using Connected.Annotations;
-using Connected.Utilities;
+using Connected.Utilities;
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class DrawerHeader : UIComponent
{
- protected string Classname =>
- new CssBuilder("drawer-header")
- .AddClass($"drawer-header-dense", Dense)
- .AddClass(AdditionalClassList)
- .Build();
+ #region Event callbacks
+ #endregion
+
+ #region Content placeholders
///
/// If true, compact padding will be used, same as the Appbar.
///
[Parameter]
- [Category(CategoryTypes.Drawer.Appearance)]
public bool Dense { get; set; }
///
/// Child content of component.
///
[Parameter]
- [Category(CategoryTypes.Drawer.Behavior)]
public RenderFragment ChildContent { get; set; }
///
/// If true, the component will link to index page with an a element instead of div.
///
[Parameter]
- [Category(CategoryTypes.Drawer.Behavior)]
public bool LinkToIndex { get; set; }
+
+ #endregion
+
+ #region Styling properties
+
+ ///
+ /// A space separated list of class names, added on top of the default class list.
+ ///
+ [Parameter]
+ public string? ClassList { get; set; }
+
+ ///
+ /// A space separated list of class names, added on top of the default class list.
+ ///
+ [Parameter]
+ public string? StyleList { get; set; }
+
+ #endregion
+
+ protected virtual CssBuilder CompiledClassList
+ {
+ get
+ {
+ return new CssBuilder("drawer-header")
+ .AddClass($"drawer-header-dense", Dense)
+ .AddClass(ClassList);
+ }
+ }
+
}
diff --git a/src/Connected.Components/Components/Layout/Layout.razor b/src/Connected.Components/Components/Layout/Layout.razor
index b10b31c..40db62b 100644
--- a/src/Connected.Components/Components/Layout/Layout.razor
+++ b/src/Connected.Components/Components/Layout/Layout.razor
@@ -1,7 +1,7 @@
@namespace Connected.Components
@inherits DrawerContainer
-
+
@ChildContent
diff --git a/src/Connected.Components/Components/Layout/Layout.razor.cs b/src/Connected.Components/Components/Layout/Layout.razor.cs
index e9afeb6..917832b 100644
--- a/src/Connected.Components/Components/Layout/Layout.razor.cs
+++ b/src/Connected.Components/Components/Layout/Layout.razor.cs
@@ -1,13 +1,33 @@
using Connected.Utilities;
+using System.Net;
namespace Connected.Components;
public partial class Layout : DrawerContainer
{
- protected override string Classname =>
- new CssBuilder("layout")
- .AddClass(base.Classname)
- .Build();
+ protected virtual CssBuilder CompiledClassList
+ {
+ get
+ {
+ return new CssBuilder("layout")
+ .AddClass(base.ClassList);
+ }
+ }
+
+ protected StyleBuilder CompiledStyleList
+ {
+ get
+ {
+ return new StyleBuilder()
+ .AddStyle(base.StyleList);
+ //.AddStyle("width", Width, !string.IsNullOrWhiteSpace(Width) && !Fixed)
+ //.AddStyle("--mud-drawer-width", Width, !string.IsNullOrWhiteSpace(Width) && (!Fixed || Variant == DrawerVariant.Temporary))
+ //.AddStyle("height", Height, !string.IsNullOrWhiteSpace(Height))
+ //.AddStyle("--mud-drawer-content-height",string.IsNullOrWhiteSpace(Height) ? _height.ToPx() : Height,Anchor == Anchor.Bottom || Anchor == Anchor.Top)
+ //.AddStyle("visibility", "hidden", string.IsNullOrWhiteSpace(Height) && _height == 0 && (Anchor == Anchor.Bottom || Anchor == Anchor.Top));
+
+ }
+ }
public Layout()
{
diff --git a/src/Connected.Components/Navigation.cs b/src/Connected.Components/Navigation.cs
new file mode 100644
index 0000000..2c5ec49
--- /dev/null
+++ b/src/Connected.Components/Navigation.cs
@@ -0,0 +1,119 @@
+using Microsoft.AspNetCore.Components;
+using Microsoft.JSInterop;
+
+namespace Connected;
+internal class Navigation
+{
+ private const int MaxPagesOnList = 256;
+ private readonly NavigationManager _navigationManager;
+
+ [Inject]
+ private IJSRuntime JS { get; set; }
+
+ private List
_backPages;
+ private List _forwardPages;
+
+ public Navigation(NavigationManager navigationManager)
+ {
+ _navigationManager = navigationManager;
+ _backPages = new List();
+ _forwardPages = new List();
+ }
+
+ ///
+ /// Navigates to the specified url.
+ ///
+ /// The destination url (relative or absolute).
+ public async Task NavigateTo(string url, Target target=Target._self)
+ {
+ if (!target.Equals("_self"))
+ {
+ if (!url.Equals(_navigationManager.Uri))
+ _backPages.Add(_navigationManager.Uri);
+ _navigationManager.NavigateTo(url);
+ } else
+ {
+ if (JS is not null)
+ await JS.InvokeVoidAsync("open", url, target.ToString());
+ }
+ }
+
+ ///
+ /// Returns true if it is possible to navigate to the previous url.
+ ///
+ private bool CanNavigateBack()
+ {
+ return (_backPages.Count > 1);
+ }
+
+ private bool CanNavigateForward()
+ {
+ return (_forwardPages.Count > 1);
+ }
+
+ private void UpdateBackPageList()
+ {
+ string url = _navigationManager.Uri;
+ _backPages.Add(url);
+ if (_backPages.Count() > MaxPagesOnList)
+ {
+ _backPages.RemoveAt(0);
+ }
+ }
+
+ private string GetFromBackPageList()
+ {
+ string result = _backPages.Last();
+ _backPages.RemoveAt(_backPages.Count()-1);
+ return result;
+ }
+
+ private string GetFromForwardPageList()
+ {
+ string result = _forwardPages.Last();
+ _forwardPages.RemoveAt(_forwardPages.Count() - 1);
+ return result;
+ }
+
+ private void UpdateForwardPageList()
+ {
+ string url = _navigationManager.Uri;
+ _forwardPages.Add(url);
+ if (_forwardPages.Count() > MaxPagesOnList)
+ {
+ _forwardPages.RemoveAt(0);
+ }
+ }
+
+ ///
+ /// Navigates to the previous url if possible or does nothing if it is not.
+ ///
+ public void Back()
+ {
+ if (!CanNavigateBack()) return;
+ var backPageUrl = GetFromBackPageList();
+ UpdateForwardPageList();
+
+ NavigateTo(backPageUrl);
+ }
+
+ ///
+ /// Navigates to the forward url if possible or does nothing if it is not.
+ ///
+ public void Forward()
+ {
+ if (!CanNavigateForward()) return;
+ var forwardPageUrl = GetFromForwardPageList();
+ UpdateBackPageList();
+
+ NavigateTo(forwardPageUrl);
+ }
+}
+
+enum Target
+{
+ _self,
+ _blank,
+ _parent,
+ _top
+}