Skip to content

Commit

Permalink
Merge pull request #558 from DFE-Digital/SFSW-2024-Create-component-t…
Browse files Browse the repository at this point in the history
…o-print-this-page

Print this page component
  • Loading branch information
mattb-hippo authored Nov 15, 2024
2 parents b3c6ef8 + bd0bd87 commit 771d4d5
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 6 deletions.
1 change: 1 addition & 0 deletions Childrens-Social-Care-CPD/Contentful/Models/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Content : IContent
public int? EstimatedReadingTime { get; set; }
public List<Content> ParentPages { get; set; }
public string BreadcrumbText { get; set; }
public bool ShowPrintThisPage { get; set; }

[JsonProperty("$metadata")]
public ContentfulMetadata Metadata { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_Content.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
continue;
}

if (item is Feedback && Model.ShowPrintThisPage)
{
<partial name="_PrintThisPage" />
}

await Html.RenderContentfulPartialAsync(item);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@
}
else if (preferenceSet)
{
var consentVerb = consentState == AnalyticsConsentState.Accepted ? "accepted" : "rejected";

<div class="govuk-cookie-banner" id="divCookieBannerId" data-nosnippet="" role="region" aria-label="@headingText">
<div class="govuk-cookie-banner__message govuk-width-container" id="divCookieMessageActioned">
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<div class="govuk-cookie-banner__content">
<p>Youve rejected essential and analytics cookies. You can
@_contentLinkRenderer.Render(new ContentLink() { Name = "change your cookie settings", Uri = cookiesUrl }))
<p>Youve @consentVerb analytics cookies. You can
@_contentLinkRenderer.Render(new ContentLink() { Name = "change your cookie settings", Uri = cookiesUrl })
at any time.</p>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_PrintThisPage.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="govuk-grid-row">
<button class="govuk-link print-link-button" data-module="print-link" onclick="window.print()">
Print this page
</button>
</div>
16 changes: 16 additions & 0 deletions Childrens-Social-Care-CPD/styles/scss/overrides/_site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,20 @@
/* feedback component tweaks */
div#page-feedback a {
cursor: pointer;
}

/* print this page button */
.print-link-button {
background: url(/assets/images/icon-print.png) no-repeat 10px 50%;
background-size: 16px 18px;
padding: 10px 10px 10px 36px;
border: 1px solid #b1b4b6;
color: #1d70b8;
cursor: pointer;
margin: 0;
margin-bottom: 40px;
margin-left: 15px;
font-weight: 400;
font-size: 19px;
line-height: 1.1429;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Childrens-Social-Care-CPD/wwwroot/css/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/wwwroot/css/application.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/wwwroot/css/application.min.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions Contentful-Schema/migrations/0013-print-page-component.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = async function (migration, { makeRequest }) {

const contentTypeId = "content";

migration
.editContentType(contentTypeId)
.createField("showPrintThisPage")
.name("Show Print this Page")
.type("Boolean")
.localized(false)
.required(false)
.validations([])
.defaultValue({
"en-US": true,
})
.disabled(false)
.omitted(false);

migration
.editContentType(contentTypeId)
.changeFieldControl("showPrintThisPage", "builtin", "boolean", {
helpText:
"Should this page include a Print this Page component? It requires that a Feedback component is included in the page's items.",
trueLabel: "Yes",
falseLabel: "No",
});
};
3 changes: 2 additions & 1 deletion Contentful-Schema/migrations/manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
0009-asset-download-component.cjs
0010-breadcrumbs.cjs
0011-create-agency-standards-page-category.cjs
0012-credit-block-component.cjs
0012-credit-block-component.cjs
0013-print-page-component.cjs
Binary file modified Contentful-Schema/migrations/migrations.tar.gz
Binary file not shown.

0 comments on commit 771d4d5

Please sign in to comment.