-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bumped SDK version, implemented Navigation Component (#8)
This PR increases the version of the SDK used to v0.0.9 - in order to leverage the new `CustomComponent` binding functionality. This functionality is used to implement the `Navigation` component included here. ## Description / Motivation Implementation of the Navigation component now means that the Skate Park template is now completely supported. ## Terms <!-- Place an X in the [] to check. --> <!-- The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it. --> - [x] I agree to follow this project's [Code of Conduct](CODE_OF_CONDUCT.md). Closes #2
- Loading branch information
Showing
7 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
headapps/aspnet-core-starter/Models/Navigation/Navigation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Sitecore.AspNetCore.SDK.LayoutService.Client.Serialization.Converter; | ||
using Sitecore.AspNetCore.SDK.RenderingEngine.Binding.Attributes; | ||
|
||
namespace Sitecore.AspNetCore.Starter.Models.Navigation; | ||
|
||
public class Navigation : BaseModel | ||
{ | ||
public Navigation() { } | ||
|
||
public Navigation(List<NavigationItem>? navigationItems, int? menuLevel) | ||
{ | ||
NavigationItems = navigationItems; | ||
MenuLevel = menuLevel; | ||
} | ||
|
||
[SitecoreComponentField(Name = FieldParser.CustomContentFieldKey)] | ||
public List<NavigationItem>? NavigationItems { get; set; } | ||
|
||
public int? MenuLevel { get; set; } | ||
} |
19 changes: 19 additions & 0 deletions
19
headapps/aspnet-core-starter/Models/Navigation/NavigationItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model.Fields; | ||
|
||
namespace Sitecore.AspNetCore.Starter.Models.Navigation | ||
{ | ||
public class NavigationItem | ||
{ | ||
public string? Id { get; set; } | ||
|
||
public List<string>? Styles { get; set; } = []; | ||
|
||
public List<NavigationItem>? Children { get; set; } = []; | ||
|
||
public string? Href { get; set; } | ||
|
||
public string? QueryString { get; set; } | ||
|
||
public TextField? NavigationTitle { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
headapps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/Navigation.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@using Sitecore.AspNetCore.Starter.Models.Navigation | ||
@model Sitecore.AspNetCore.Starter.Models.Navigation.Navigation | ||
|
||
<div class="component navigation @Model.Styles @Model.GridParameters" id="@Model.Id"> | ||
<label class="menu-mobile-navigate-wrapper"> | ||
<input type="checkbox" | ||
class="menu-mobile-navigate" /> | ||
<div class="menu-humburger" /> | ||
<div class="component-content"> | ||
<nav> | ||
@await Html.PartialAsync("./_NavigationMenu.cshtml", @Model) | ||
</nav> | ||
</div> | ||
</label> | ||
</div> |
18 changes: 18 additions & 0 deletions
18
...apps/aspnet-core-starter/Views/Shared/Components/SitecoreComponent/_NavigationMenu.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@using Sitecore.AspNetCore.Starter.Models.Navigation | ||
@model Sitecore.AspNetCore.Starter.Models.Navigation.Navigation | ||
|
||
<ul class="clearfix"> | ||
@foreach (NavigationItem navItem in @Model.NavigationItems ?? []) | ||
{ | ||
string classNames = $"{string.Join(" ", navItem.Styles ?? [])} rel-level{Model.MenuLevel}"; | ||
|
||
<li class="@classNames"> | ||
<div class="navigation-title @(navItem.Children?.Count > 0 ? "child" : "")"> | ||
<a href="@navItem.Href"> | ||
<sc-text asp-for="@navItem.NavigationTitle"></sc-text> | ||
</a> | ||
</div> | ||
@await Html.PartialAsync("./_NavigationMenu.cshtml", new Navigation(navItem.Children, Model.MenuLevel + 1)) | ||
</li> | ||
} | ||
</ul> |