Skip to content

Commit

Permalink
Merge branch 'main' into tf-fix-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
albal authored Oct 13, 2023
2 parents a5aa7a2 + 3e750fc commit 976fbe0
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class EntityResolverTests
[TestCase("imageCard", typeof(ImageCard))]
[TestCase("linkCard", typeof(LinkCard))]
[TestCase("linkListCard", typeof(LinkListCard))]
[TestCase("pdfFileResource", typeof(PdfFileResource))]
[TestCase("resource", typeof(Resource))]
[TestCase("richTextBlock", typeof(RichTextBlock))]
[TestCase("roleList", typeof(RoleList))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class PartialsFactoryTests
{
new object[] { new AreaOfPractice(), "_AreaOfPractice" },
new object[] { new AreaOfPracticeList(), "_AreaOfPracticeList" },
new object[] { new AudioResource(), "_AudioResource" },
new object[] { new AudioResource(), "_AudioResource" },
new object[] { new ColumnLayout(), "_ColumnLayout" },
new object[] { new Content(), "_Content" },
new object[] { new ContentLink(), "_ContentLink" },
Expand All @@ -24,6 +24,7 @@ public partial class PartialsFactoryTests
new object[] { new LinkCard(), "_LinkCard" },
new object[] { new ImageCard(), "_ImageCard" },
new object[] { new LinkListCard(), "_LinkListCard" },
new object[] { new PdfFileResource(), "_PdfFileResource" },
new object[] { new Resource(), "_Resource" },
new object[] { new RichTextBlock(), "_RichTextBlock" },
new object[] { new RoleList(), "_RoleList" },
Expand Down
1 change: 1 addition & 0 deletions Childrens-Social-Care-CPD/Contentful/EntityResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public Type Resolve(string contentTypeId)
"imageCard" => typeof(ImageCard),
"linkCard" => typeof(LinkCard),
"linkListCard" => typeof(LinkListCard),
"pdfFileResource" => typeof(PdfFileResource),
"resource" => typeof(Resource),
"richTextBlock" => typeof(RichTextBlock),
"roleList" => typeof(RoleList),
Expand Down
12 changes: 12 additions & 0 deletions Childrens-Social-Care-CPD/Contentful/Models/PdfFileResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Contentful.Core.Models;

namespace Childrens_Social_Care_CPD.Contentful.Models;

public class PdfFileResource : IContent
{
public string Id { get; set; }
public Asset File { get; set; }
public Asset FileThumbnail { get; set; }
public string FileDescription { get; set; }
public int PageCount { get; set; }
}
1 change: 1 addition & 0 deletions Childrens-Social-Care-CPD/Contentful/PartialsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static string GetPartialFor(IContent item)
ImageCard => "_ImageCard",
LinkCard => "_LinkCard",
LinkListCard => "_LinkListCard",
PdfFileResource => "_PdfFileResource",
Resource => "_Resource",
RichTextBlock => "_RichTextBlock",
RoleList => "_RoleList",
Expand Down
30 changes: 30 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_PdfFileResource.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@using Childrens_Social_Care_CPD.Contentful.Models;

@model PdfFileResource

<div class="govuk-!-margin-top-8">
<div class="govuk-grid-column-three-quarter">
<div class="govuk-grid-row">
<ul class="ons-document-list">
<li class="ons-document-list__item">
<div class="ons-document-list__item-image ons-document-list__item-image--file" aria-hidden="true">
<a class="ons-document-list__image-link ons-document-list__image-link--placeholder" style="background-image:url('@Model.FileThumbnail.File.Url')" href="@Model.File.File.Url" tabindex="-1">
</a>
</div>
<div class="ons-document-list__item-content">
<h2><a href="@Model.File.File.Url">@Model.Id</a></h2>
<ul class="course-details govuk-list">
<li>
@{
var fileSize = Math.Round(Decimal.Divide(Model.File.File.Details.Size, 1024), 0).ToString();
}
<span class="govuk-!-font-size-16 govuk-!-font-weight-bold">PDF document download, @fileSize.ToString() KB, @Model.PageCount page(s)</span>
</li>
<div class="ons-document-list__item-description">@Model.FileDescription</div>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
175 changes: 175 additions & 0 deletions Childrens-Social-Care-CPD/styles/scss/overrides/_site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,179 @@

.iframe-border-width {
border-width: 0px;
}

/* ONS document list */
.ons-document-list {
margin-bottom: 0;
}

.ons-document-list__item {
border-bottom: 1px solid var(--ons-color-borders-list);
margin: 0 0 1.5rem;
padding: 0 0 1.5rem;
}

@media (min-width: 400px) {
.ons-document-list__item {
-webkit-box-align: start;
align-items: flex-start;
display: -webkit-box;
display: flex;
}
}

.ons-document-list__item:last-of-type {
border-bottom: 0;
margin: 0;
}

.ons-document-list__item-image {
-webkit-box-flex: 0;
flex: 0 0 auto;
margin-bottom: 1rem;
width: 136px;
}

@media (min-width: 400px) {
.ons-document-list__item-image {
margin-right: 1.5rem;
}
}

@media (min-width: 740px) {
.ons-document-list__item-image {
margin-bottom: 0;
}
}

.ons-document-list__item-image .ons-document-list__image-link--placeholder {
height: 96px;
}

.ons-document-list__item-image--file {
width: 96px;
}

.ons-document-list__item-image--file .ons-document-list__image-link {
border-color: var(--ons-color-borders-document-image);
}

.ons-document-list__item-image--file .ons-document-list__image-link--placeholder {
height: 120px;
}

.ons-document-list__image-link {
border: 2px solid transparent;
-webkit-box-sizing: content-box;
box-sizing: content-box;
display: block;
width: 100%;
}

.ons-document-list__image-link:focus {
background-color: var(--ons-color-placeholder) !important;
border: 2px solid var(--ons-color-borders-document-image-focus);
-webkit-box-shadow: none;
box-shadow: none;
outline: 4px solid var(--ons-color-focus) !important;
outline-offset: 0;
}

.ons-document-list__image-link--placeholder {
background-clip: padding-box;
background-color: var(--ons-color-borders-document-image);
background-position: center;
background-repeat: no-repeat;
background-size: 120px;
height: 100%;
}

.ons-document-list__item-metadata {
line-height: 1.2 !important;
}

.ons-document-list__item-attribute {
color: var(--ons-color-text-metadata);
display: inline-block;
margin: 0 1rem 0 0;
}

.ons-document-list__attribute-link {
color: inherit;
}

.ons-document-list__attribute-link:hover {
color: var(--ons-color-text-metadata);
-webkit-text-decoration: underline solid var(--ons-color-text-metadata) 2px;
text-decoration: underline solid var(--ons-color-text-metadata) 2px;
}

.ons-document-list__item-description {
margin-bottom: 0;
max-width: 660px;
}

.ons-document-list__item-description p:last-of-type {
margin-bottom: 0;
}

.ons-document-list__item--featured {
background-color: var(--ons-color-banner-bg);
border-bottom: none;
display: block;
outline: 2px solid transparent;
outline-offset: -2px;
padding: 2rem;
}

@media (min-width: 740px) {
.ons-document-list__item--featured {
-webkit-box-align: start;
align-items: flex-start;
display: -webkit-box;
display: flex;
}

.ons-document-list__item--featured .ons-container {
display: -webkit-box;
display: flex;
}
}

.ons-document-list__item--featured .ons-document-list__item-image {
width: 248px;
}

.ons-document-list__item--featured .ons-document-list__item-image .ons-document-list__item--featured .ons-document-list__item-image__image-link--placeholder {
height: 96px;
}

@media (min-width: 740px) {
.ons-document-list__item--featured .ons-document-list__item-image {
margin-right: 2.5rem;
width: 379px;
}

.ons-document-list__item--featured .ons-document-list__item-image .ons-document-list__item--featured .ons-document-list__item-image__image-link--placeholder {
height: 248px;
}
}

.ons-document-list__item--featured .ons-document-list__item-header--reverse {
display: -webkit-box;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: reverse;
flex-direction: column-reverse;
margin-bottom: 0.5rem;
}

.ons-document-list__item--featured + .ons-document-list__item {
border-top: none;
margin-top: 0;
}

.ons-document-list__item--full-width {
padding: 2rem 0;
}
Loading

0 comments on commit 976fbe0

Please sign in to comment.