Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Amend printed page styling #162

Draft
wants to merge 3 commits into
base: Development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Dfe.ContentSupport.Web.Node/styles/scss/application.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@use "../../node_modules/govuk-frontend/dist/govuk/all.scss";
@use "../../node_modules/dfe-frontend/packages/dfefrontend.scss";
@use "../../node_modules/dfe-frontend/packages/dfefrontend.scss";
@use "./print.scss";
89 changes: 89 additions & 0 deletions src/Dfe.ContentSupport.Web.Node/styles/scss/print.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@import "../../node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss";

//Append " (opens in new tab)" to links with the appropriate class, so that we can _hide_ the text if printing
a.opens-in-new-tab::after {
content: " (opens in new tab)";
display: inline;
}

@media print {
.print-only {
visibility: visible;
display: block !important;
}

//Hide hr elements where the sections between them have been hidden
.govuk-\!-display-none-print + hr,
hr + .govuk-\!-display-none-print,
hr + div:only-child.govuk-\!-display-none-print,
div > div:only-child.govuk-\!-display-none-print + hr,
div > div.govuk-\!-display-none-print + hr,
div > div:has(> .govuk-\!-display-none-print) + hr,
div:has(div.govuk-\!-display-none-print) + hr {
display: none;
}

//Service name - i.e. Plan Technology for your School
div.dfe-header__service-name {
margin-top: 10px;
}

//Reduces padding between the page title/subtitle + main content
main.govuk-main-wrapper#main-content {
padding-top: 10px !important;
padding-bottom: 10px !important;
}

//Page title
h1.govuk-\!-margin-bottom-4.govuk-\!-margin-top-5 {
margin-top: 10px !important;
margin-bottom: 5px !important;
}

//Make links look like text
a,
a.govuk-link {
color: inherit !important;
text-decoration: none;

//Remove the "(opens in new tab)" text
.opens-in-new-tab::after {
content: "";
}

&.dfe-header__link--service {
color: black !important;
}
}

//Make page full width
div.govuk-grid-column-three-quarters {
width: 100%;
}

/*
* Accordion
*/
span.govuk-accordion__section-toggle {
display: none !important;
}

//Show content
div.govuk-accordion__section-content {
display: block !important;
padding-top: 0px !important;
padding-bottom: 0px !important;
content-visibility: visible !important;
}

div.govuk-accordion__controls {
display: none !important;
}

//Remove border from first section in accordion. Use 2nd of type, because 1st wasn't working for some reason?
div.govuk-accordion
div.govuk-accordion__section:nth-of-type(2)
button.govuk-accordion__section-button {
border-top: 0px !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ namespace Dfe.ContentSupport.Web.Models.Mapped;
[ExcludeFromCodeCoverage]
public class RichTextContentItem : CsContentItem
{
public List<RichTextContentItem> Content { get; set; } = null!;
public List<RichTextContentItem> Content { get; set; } = [];
public RichTextNodeType NodeType { get; set; } = RichTextNodeType.Unknown;
public string Value { get; set; } = null!;
public string? Value { get; set; } = null;
public List<string> Tags { get; set; } = [];

public virtual bool HaveNoContent => Content.Count == 0 || Content.TrueForAll(content => content.IsEmptyContent);
public virtual bool IsEmptyContent => HaveNoContent && string.IsNullOrEmpty(Value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ public EmbeddedEntry()
public string JumpIdentifier { get; set; } = null!;
public RichTextContentItem? RichText { get; set; }
public CustomComponent? CustomComponent { get; set; }

public override bool HaveNoContent => Content.Count == 0 || Content.TrueForAll(content => content.IsEmptyContent);
public override bool IsEmptyContent => base.IsEmptyContent && (RichText == null || RichText.IsEmptyContent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,48 @@ var ptCookieNotSet = Context.Request.Cookies["user_cookies_preferences"] is null
var showBanner = csCookieNotSet && ptCookieNotSet;
}

@if (showBanner)
{
<region id="cookieConsent" class="govuk-cookie-banner" aria-label="Cookies on Content and Support">
<div class="govuk-cookie-banner__message dfe-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
Cookies on Content and Support
</h2>
<div class="govuk-cookie-banner__content">
<p class="govuk-body">We use some essential cookies to make this service work.</p>
<p class="govuk-body">
We’d like to set additional cookies so we can remember your settings,
understand how people use the service and make improvements.
</p>
</div>
@if (!showBanner) { return; }

<region id="cookieConsent" class="govuk-cookie-banner govuk-!-display-none-print" aria-label="Cookies on Content and Support">
<div class="govuk-cookie-banner__message dfe-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
Cookies on Content and Support
</h2>
<div class="govuk-cookie-banner__content">
<p class="govuk-body">We use some essential cookies to make this service work.</p>
<p class="govuk-body">
We’d like to set additional cookies so we can remember your settings,
understand how people use the service and make improvements.
</p>
</div>
</div>
<div class="govuk-button-group">
<button value="true" type="submit" name="cookies[additional]" class="govuk-button"
data-module="govuk-button" data-cookie-string="@cookieString">
Accept additional cookies
</button>
<button value="false" type="submit" name="cookies[additional]" class="govuk-button"
data-module="govuk-button" data-cookie-string="@cookieString">
Reject additional cookies
</button>
<a class="govuk-link" href="#">View cookies</a>
</div>
</div>
</region>
<script nonce="@Context.Items["nonce"]">
(function () {
const buttons = document.querySelectorAll("#cookieConsent button[data-cookie-string]");
buttons.forEach(function (button) {
button.addEventListener("click", function (_) {
document.cookie = button.dataset.cookieString.replace(/true|false/, button.value);
const cookieContainer = document.querySelector("#cookieConsent");
cookieContainer.remove();
location.reload();
});
<div class="govuk-button-group">
<button value="true" type="submit" name="cookies[additional]" class="govuk-button"
data-module="govuk-button" data-cookie-string="@cookieString">
Accept additional cookies
</button>
<button value="false" type="submit" name="cookies[additional]" class="govuk-button"
data-module="govuk-button" data-cookie-string="@cookieString">
Reject additional cookies
</button>
<a class="govuk-link" href="#">View cookies</a>
</div>
</div>
</region>

<script nonce="@Context.Items["nonce"]">
(function () {
const buttons = document.querySelectorAll("#cookieConsent button[data-cookie-string]");
buttons.forEach(function (button) {
button.addEventListener("click", function (_) {
document.cookie = button.dataset.cookieString.replace(/true|false/, button.value);
const cookieContainer = document.querySelector("#cookieConsent");
cookieContainer.remove();
location.reload();
});
})();
});
})();
</script>
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
@model CustomAccordion

<div class="govuk-accordion" data-module="govuk-accordion" id="[email protected]">
@{
foreach (var accordion in Model.Accordions)
{
<div class="govuk-accordion__section">
<div class="govuk-accordion__section-header">
<h2 class="govuk-accordion__section-heading">
<span class="govuk-accordion__section-button" id="@accordion.InternalName-heading">
@accordion.Title
</span>
</h2>
<div class="govuk-accordion__section-summary govuk-body" id="@accordion.InternalName-summary">
@accordion.SummaryLine
</div>
</div>
<div id="@accordion.InternalName-content" class="govuk-accordion__section-content">
<partial name="RichText/_RichText" model="@accordion.Body"/>
@foreach (var accordion in Model.Accordions)
{
<div class="govuk-accordion__section">
<div class="govuk-accordion__section-header">
<h2 class="govuk-accordion__section-heading">
<span class="govuk-accordion__section-button" id="@accordion.InternalName-heading">
@accordion.Title
</span>
</h2>
<div class="govuk-accordion__section-summary govuk-body" id="@accordion.InternalName-summary">
@accordion.SummaryLine
</div>
</div>
}
<div id="@accordion.InternalName-content" class="govuk-accordion__section-content">
<partial name="RichText/_RichText" model="@accordion.Body"/>
</div>
</div>
}
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using System
@model CustomAttachment

<div class="guidance-container govuk-!-padding-8 govuk-!-margin-bottom-8">
<div class="guidance-container govuk-!-padding-8 govuk-!-margin-bottom-8 govuk-!-display-none-print">
<div class="attachment">
<div class="attachment-thumbnail govuk-!-margin-right-8">
<a href="@Model.Uri" download>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<img src="@Model.Uri" alt="@Model.Description" title="@Model.Title"/>
break;
case AssetContentType.Video:
<video controls>
<video controls class="govuk-!-display-none-print">
<source src="@Model.Uri" type="video/mp4">
Your browser does not support the video tag.
</video>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
}
else
{
<a href="@Model.Uri" target="_blank" rel="noopener noreferrer"><partial name="RichText/_Text" model="@Model.Content[0]"/></a>
var textContainsOpenInNewTab = Model.Content[0].Value?.ToLower().Contains("(opens in new tab)") ?? false;
var linkClass = textContainsOpenInNewTab ? "opens-in-new-tab" : "";
if(textContainsOpenInNewTab){
Model.Content[0].Value = Model.Content[0].Value?.Replace(" (opens in new tab)", "") ?? "";
}

<a href="@Model.Uri" target="_blank" rel="noopener noreferrer" class="@linkClass">@Model.Content[0].Value</a>
}
13 changes: 7 additions & 6 deletions src/Dfe.ContentSupport.Web/Views/Shared/RichText/_Items.cshtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@model RichTextContentItem

@if (Model.Content is not null && Model.Content.Any())
@if (Model.HaveNoContent) {
return;
}

@foreach (var childNode in Model.Content)
{
foreach (var childNode in Model.Content)
{
<partial name="RichText/_RichText" model="@childNode"/>
}
}
<partial name="RichText/_RichText" model="@childNode"/>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@model RichTextContentItem

@if(Model.IsEmptyContent){
return;
}

<p class="govuk-body">
<partial name="RichText/_Items" model="@Model"/>
</p>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var vimeoId = Model.Uri.Split('/').Last();
}

<div class="column-full vimeo-player">
<div class="column-full vimeo-player govuk-!-display-none-print">
<iframe src="https://player.vimeo.com/video/@vimeoId" width="640" height="360"
allow="autoplay; fullscreen; picture-in-picture" allowfullscreen title="embedded vimeo clip"></iframe>
</div>
12 changes: 6 additions & 6 deletions src/Dfe.ContentSupport.Web/Views/Shared/_BackToTop.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="backtotop-button">
<a class="govuk-link govuk-link--no-visited-state" href="#">
<svg class="app-back-to-top__icon" xmlns="http://www.w3.org/2000/svg" width="13" height="17" viewBox="0 0 13 17">
<path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path>
</svg> Back to top
</a>
<div id="backtotop-button" class="govuk-!-display-none-print">
<a class="govuk-link govuk-link--no-visited-state" href="#">
<svg class="app-back-to-top__icon" xmlns="http://www.w3.org/2000/svg" width="13" height="17" viewBox="0 0 13 17">
<path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path>
</svg> Back to top
</a>
</div>
2 changes: 1 addition & 1 deletion src/Dfe.ContentSupport.Web/Views/Shared/_BetaHeader.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="govuk-phase-banner noprint">
<div class="govuk-phase-banner govuk-!-display-none-print">
<p class="govuk-phase-banner__content">
@* <govuk-phase-banner-tag>Beta</govuk-phase-banner-tag> *@
<strong class="govuk-tag govuk-phase-banner__content__tag">Beta</strong>
Expand Down
4 changes: 2 additions & 2 deletions src/Dfe.ContentSupport.Web/Views/Shared/_CsHeader.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div class="dfe-width-container dfe-header__container">
<div class="dfe-header__logo">
<a class="dfe-header__link dfe-header__link--service " href="/" aria-label="DfE homepage">
<img src="/assets/images/dfe-logo.png" class="dfe-logo" alt="DfE Homepage">
<img src="/assets/images/dfe-logo-alt.png" class="dfe-logo-hover" alt="DfE Homepage">
<img src="/assets/images/dfe-logo.png" class="dfe-logo govuk-!-display-none-print" alt="DfE Homepage">
<img src="/assets/images/dfe-logo-alt.png" class="dfe-logo-hover print-only" alt="DfE Homepage">
</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Dfe.ContentSupport.Web/Views/Shared/_Feedback.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@if (track)
{
<div class="dfe-feedback-banner govuk-!-margin-top-9 govuk-visually-hidden" aria-hidden="true" id="feedback-banner">
<div class="dfe-feedback-banner govuk-!-margin-top-9 govuk-visually-hidden govuk-!-display-none-print" aria-hidden="true" id="feedback-banner">
<div class="dfe-feedback-banner--content">
<form id="feedbackForm">
<div class="dfe-feedback-banner--content-questions">
Expand Down
2 changes: 1 addition & 1 deletion src/Dfe.ContentSupport.Web/Views/Shared/_Footer.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<footer class="govuk-footer " role="contentinfo">
<footer class="govuk-footer govuk-!-display-none-print" role="contentinfo">
<div class="govuk-width-container">
<div class="govuk-footer__meta">
<div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
Expand Down
2 changes: 1 addition & 1 deletion src/Dfe.ContentSupport.Web/Views/Shared/_Print.cshtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="print-button govuk-visually-hidden" aria-hidden="true">
<div class="print-button govuk-visually-hidden govuk-!-display-none-print" aria-hidden="true">
<button class="govuk-link print-link-button" data-module="print-link" id="print-link" >Print this page</button>
</div>
2 changes: 1 addition & 1 deletion src/Dfe.ContentSupport.Web/wwwroot/css/application.css

Large diffs are not rendered by default.

Loading