-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feature/feedback-banner' into fe…
…ature/feedback-banner
- Loading branch information
Showing
20 changed files
with
676 additions
and
173 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/Dfe.ContentSupport.Web.Node/styles/scss/vertical-navigation.scss
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,41 @@ | ||
:root { | ||
--govuk-link-color: #1d70b8; | ||
--govuk-black: #0b0c0c; | ||
} | ||
|
||
.dfe-vertical-nav__section-item { | ||
list-style-type: none; | ||
font-size: 1rem; | ||
} | ||
|
||
.dfe-vertical-nav__link { | ||
display: block; | ||
padding: 7px 30px 8px 10px; | ||
border-left: 4px solid #b1b4b6; | ||
text-decoration: none; | ||
} | ||
|
||
.dfe-vertical-nav__link--selected { | ||
border-left: 4px solid var(--govuk-link-color); | ||
background-color: #f3f2f1; | ||
font-weight: bold; | ||
} | ||
|
||
.dfe-vertical-nav__link, | ||
.dfe-vertical-nav__link--selected { | ||
color: var(--govuk-link-color); | ||
|
||
&:active, &:hover { | ||
background-color: #fd0; | ||
color: var(--govuk-black); | ||
border-left: 4px solid var(--govuk-black); | ||
font-weight: normal; | ||
} | ||
} | ||
|
||
.dfe-vertical-nav__theme { | ||
border-top: 1px solid var(--govuk-link-color); | ||
padding-top: 5px; | ||
margin-top: 10px; | ||
margin-left: 0; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Dfe.ContentSupport.Web.Models.Mapped | ||
{ | ||
public class PageLink | ||
{ | ||
public string? Title { get; set; } = null; | ||
public string? Subtitle { get; set; } = null; | ||
public required string Url { get; set; } | ||
public required bool IsActive { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Dfe.ContentSupport.Web.Models.Mapped; | ||
|
||
namespace Dfe.ContentSupport.Web.Services | ||
{ | ||
public interface ILayoutService | ||
{ | ||
CsPage GenerateLayout(CsPage page, HttpRequest request, string pageName); | ||
|
||
} | ||
} |
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,85 @@ | ||
using Dfe.ContentSupport.Web.Models; | ||
using Dfe.ContentSupport.Web.Models.Mapped; | ||
|
||
|
||
namespace Dfe.ContentSupport.Web.Services | ||
{ | ||
public class LayoutService : ILayoutService | ||
{ | ||
public CsPage GenerateLayout(CsPage page, HttpRequest request, string pageName) | ||
{ | ||
if (!page.ShowVerticalNavigation) return page; | ||
|
||
return new() | ||
{ | ||
Heading = GetHeading(page, pageName), | ||
MenuItems = GenerateVerticalNavigation(page, request, pageName), | ||
Content = GetVisiblePageList(page, pageName), | ||
UpdatedAt = page.UpdatedAt, | ||
CreatedAt = page.CreatedAt, | ||
HasCitation = page.HasCitation, | ||
HasBackToTop = page.HasBackToTop, | ||
IsSitemap = page.IsSitemap, | ||
ShowVerticalNavigation = page.ShowVerticalNavigation, | ||
Slug = page.Slug, | ||
}; | ||
} | ||
|
||
|
||
public Heading GetHeading(CsPage page, string pageName) | ||
{ | ||
var selectedPage = page.Content.Find(o => o.InternalName == pageName); | ||
|
||
if (selectedPage != null) | ||
return new() | ||
{ | ||
Title = selectedPage.Title ?? "", | ||
Subtitle = selectedPage.Subtitle ?? "" | ||
}; | ||
|
||
|
||
return new() | ||
{ | ||
Title = page.Content[0]?.Title ?? "", | ||
Subtitle = page.Content[0]?.Subtitle ?? "" | ||
}; | ||
} | ||
|
||
|
||
public List<PageLink> GenerateVerticalNavigation(CsPage page, HttpRequest request, string pageName) | ||
{ | ||
var baseUrl = GetNavigationUrl(request); | ||
|
||
var menuItems = page.Content.Select(o => new PageLink() | ||
{ | ||
Title = o.Title ?? "", | ||
Subtitle = o.Subtitle ?? "", | ||
Url = $"{baseUrl}/{o.InternalName}", | ||
IsActive = pageName == o.InternalName | ||
}).ToList(); | ||
|
||
if (string.IsNullOrEmpty(pageName) && menuItems.Count > 0) | ||
menuItems[0].IsActive = true; | ||
|
||
return menuItems; | ||
} | ||
|
||
|
||
public List<CsContentItem> GetVisiblePageList(CsPage page, string pageName) | ||
{ | ||
if (!string.IsNullOrEmpty(pageName)) | ||
return page.Content.Where(o => o.InternalName == pageName).ToList(); | ||
|
||
|
||
return page.Content.GetRange(0, 1); | ||
} | ||
|
||
|
||
public string GetNavigationUrl(HttpRequest request) | ||
{ | ||
var splitUrl = request.Path.ToString().Split("/"); | ||
return string.Join("/", splitUrl.Take(3)); | ||
} | ||
|
||
} | ||
} |
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
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
Oops, something went wrong.