Skip to content

Commit

Permalink
feat: Added support for playing videos on resource page.
Browse files Browse the repository at this point in the history
Added support for Video file resource
  • Loading branch information
nnagepat authored Sep 29, 2023
2 parents 9170780 + 33cd535 commit 7b5e56c
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class EntityResolverTests
[TestCase("roleList", typeof(RoleList))]
[TestCase("sideMenu", typeof(SideMenu))]
[TestCase("textBlock", typeof(TextBlock))]
[TestCase("videoResource", typeof(VideoResource))]
public void Resolves_Correctly(string contentTypeId, Type expectedType)
{
var resolver = new EntityResolver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public partial class PartialsFactoryTests
new object[] { new RoleList(), "_RoleList" },
new object[] { new SideMenu(), "_SideMenu" },
new object[] { new TextBlock(), "_TextBlock" },
new object[] { new VideoResource(), "_VideoResource" },
};

[TestCaseSource(nameof(Successful_Resolves))]
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 @@ -32,6 +32,7 @@ public Type Resolve(string contentTypeId)
"roleList" => typeof(RoleList),
"sideMenu" => typeof(SideMenu),
"textBlock" => typeof(TextBlock),
"videoResource" => typeof(VideoResource),
_ => null
};
}
Expand Down
10 changes: 10 additions & 0 deletions Childrens-Social-Care-CPD/Contentful/Models/VideoResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Contentful.Core.Models;

namespace Childrens_Social_Care_CPD.Contentful.Models;

public class VideoResource : IContent
{
public string Id { get; set; }
public Asset Video { get; set; }
public Document Transcript { 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 @@ -31,6 +31,7 @@ public static string GetPartialFor(IContent item)
RoleList => "_RoleList",
SideMenu => "_SideMenu",
TextBlock => "_TextBlock",
VideoResource => "_VideoResource",
_ => "_UnknownContentWarning",
};
}
Expand Down
17 changes: 17 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_VideoResource.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@using Childrens_Social_Care_CPD.Contentful.Models;

@model VideoResource

<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<iframe id="player" title="video" type="text/html" class="iframe-border-width" width="640" height="390" allowfullscreen src="@Model.Video.File.Url"></iframe>
<details class="govuk-details govuk-!-margin-top-3" data-module="govuk-details">
<summary class="govuk-details__summary"> <span class="govuk-details__summary-text">View transcript </span></summary>
<div class="govuk-details__text">
@{
await Html.RenderPartialAsync("_RichText", Model.Transcript);
}
</div>
</details>
</div>
</div>
4 changes: 4 additions & 0 deletions Childrens-Social-Care-CPD/styles/scss/overrides/_site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@

.image-card h2 {
@extend .govuk-heading-m
}

.iframe-border-width {
border-width: 0px;
}
4 changes: 4 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.

0 comments on commit 7b5e56c

Please sign in to comment.