Skip to content

Commit

Permalink
feat: creation of Print this Page component
Browse files Browse the repository at this point in the history
  • Loading branch information
mattb-hippo committed Nov 8, 2024
1 parent e53c4e7 commit cfcdb87
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Childrens-Social-Care-CPD/Contentful/Models/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ public static class ContentTypes
public const string Resource = "Resource";
}

public static class PrintThisPageLocations
{
public const string BeforeFeedback = "Before Feedback";
public const string BeforeCreditBlock = "Before Credit Block";
public const string BottomOfPage = "Bottom of Page";
}

public class Content : IContent
{
public string Id { get; set; }
Expand All @@ -24,6 +31,7 @@ public class Content : IContent
public int? EstimatedReadingTime { get; set; }
public List<Content> ParentPages { get; set; }
public string BreadcrumbText { get; set; }
public string PrintThisPageLocation { get; set; }

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

switch (item)
{
case Feedback feedback: if (Model.PrintThisPageLocation == PrintThisPageLocations.BeforeFeedback) {
<partial name="_PrintThisPage" />
}; break;

case CreditBlock creditBlock: if (Model.PrintThisPageLocation == PrintThisPageLocations.BeforeCreditBlock) {
<partial name="_PrintThisPage" />
}; break;
}

await Html.RenderContentfulPartialAsync(item);
}
}

model.ContentStack.Pop();

if (Model.PrintThisPageLocation == PrintThisPageLocations.BottomOfPage) {
<partial name="_PrintThisPage" />
}
}
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>
15 changes: 15 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,19 @@
/* 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;
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.
15 changes: 15 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.

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

const contentTypeId = "content";

migration
.editContentType(contentTypeId)
.createField("printThisPageLocation")
.name("Print this Page Location")
.type("Symbol")
.localized(false)
.required(false)
.validations([
{
in: [
"Before Feedback",
"Before Credit Block",
"Bottom of Page",
"None",
],
},
])
.defaultValue({
"en-US": "None",
})
.disabled(false)
.omitted(false);

migration
.editContentType(contentTypeId)
.changeFieldControl("printThisPageLocation", "builtin", "radio", {
helpText: "Where should a Print this Page component be located?",
});
};
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 cfcdb87

Please sign in to comment.