Skip to content

Commit

Permalink
feat: addition of quotebox component
Browse files Browse the repository at this point in the history
  • Loading branch information
mattb-hippo committed Nov 22, 2024
1 parent 34168b6 commit 43d5705
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class EntityResolverTests
[TestCase("pageContents", typeof(PageContents))]
[TestCase("pageContentsItem", typeof(PageContentsItem))]
[TestCase("pdfFileResource", typeof(PdfFileResource))]
[TestCase("quoteBox", typeof(QuoteBox))]
[TestCase("richTextBlock", typeof(RichTextBlock))]
[TestCase("roleList", typeof(RoleList))]
[TestCase("navigationMenu", typeof(NavigationMenu))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public partial class PartialsFactoryTests
new object[] { new PageContents(), "_PageContents" },
new object[] { new PageContentsItem(), "_PageContentsItem" },
new object[] { new PdfFileResource(), "_PdfFileResource" },
new object[] { new QuoteBox(), "_QuoteBox" },
new object[] { new RichTextBlock(), "_RichTextBlock" },
new object[] { new RoleList(), "_RoleList" },
new object[] { new TextBlock(), "_TextBlock" },
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 @@ -39,6 +39,7 @@ public Type Resolve(string contentTypeId)
"pageContents" => typeof(PageContents),
"pageContentsItem" => typeof(PageContentsItem),
"pdfFileResource" => typeof(PdfFileResource),
"quoteBox" => typeof(QuoteBox),
"richTextBlock" => typeof(RichTextBlock),
"roleList" => typeof(RoleList),
"navigationMenu" => typeof(NavigationMenu),
Expand Down
9 changes: 9 additions & 0 deletions Childrens-Social-Care-CPD/Contentful/Models/QuoteBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Contentful.Core.Models;

namespace Childrens_Social_Care_CPD.Contentful.Models;

public class QuoteBox : IContent
{
public string Name { get; set; }
public Document QuoteText { 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 @@ -38,6 +38,7 @@ public static string GetPartialFor(IContent item)
PageContents => "_PageContents",
PageContentsItem => "_PageContentsItem",
PdfFileResource => "_PdfFileResource",
QuoteBox => "_QuoteBox",
RichTextBlock => "_RichTextBlock",
RoleList => "_RoleList",
NavigationMenu => "_NavigationMenu",
Expand Down
14 changes: 14 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_QuoteBox.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@using Childrens_Social_Care_CPD.Contentful.Models;
@using Childrens_Social_Care_CPD.Contentful;
@using Childrens_Social_Care_CPD.Contentful.Renderers;

@model QuoteBox


<div class="blockquote-container">
<blockquote class="quote">
@{
await Html.RenderPartialAsync("_RichText", Model.QuoteText);
}
</blockquote>
</div>
51 changes: 51 additions & 0 deletions Childrens-Social-Care-CPD/styles/scss/overrides/_site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,55 @@ div#page-feedback a {
font-weight: 400;
font-size: 19px;
line-height: 1.1429;
}

/* quote box */
.blockquote-container {
padding-top: 10px;
padding-bottom: 10px;
}

.blockquote-container blockquote.quote {
position: relative;
border: 3px solid #0b0c0c;
padding: 20px;
margin: 16px 20px;
}

@media (min-width: 40.0625em) {
.blockquote-container blockquote.quote {
margin: 16px 40px;
}
}

.blockquote-container blockquote.quote p {
padding: 0 0 0 10px;
margin-top: 10px;
position: relative;
z-index: 9999;
border: none;
max-width: 100%;
}

@media (min-width: 40.0625em) {
.blockquote-container blockquote.quote p {
padding-left: 40px;
}
}

.blockquote-container blockquote.quote p::before {
content: none;
}

.blockquote-container blockquote.quote::before {
position: absolute;
content: "";
font-size: 8em;
margin-top: -0.4em;
background-color: #ffffff;
line-height: 0.9;
height: 50px;
padding-left: 10px;
padding-right: 10px;
font-family: serif;
}
49 changes: 49 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.

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

const quoteBox = migration
.createContentType("quoteBox")
.name("Quote Box")
.description("Allows display of quotes in a distinctive bordered box.")
.displayField("name");
quoteBox
.createField("name")
.name("Name")
.type("Symbol")
.localized(false)
.required(true)
.validations([])
.disabled(false)
.omitted(false);

quoteBox
.createField("quoteText")
.name("Quote Text")
.type("RichText")
.localized(false)
.required(false)
.validations([
{
enabledMarks: [
"bold",
"italic",
"underline",
"code",
"superscript",
"subscript"
],

message:
"Only bold, italic, underline, code, superscript, subscript, and strikethrough marks are allowed",
},
{
enabledNodeTypes: [
"heading-1",
"heading-2",
"heading-3",
"heading-4",
"heading-5",
"heading-6",
"ordered-list",
"unordered-list",
"hr",
"blockquote",
"embedded-entry-block",
"embedded-asset-block",
"table",
"asset-hyperlink",
"embedded-entry-inline",
"entry-hyperlink",
"hyperlink",
],

message:
"Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, table, link to asset, inline entry, link to entry, and link to Url nodes are allowed",
},
{
nodes: {},
},
])
.disabled(false)
.omitted(false);

quoteBox.changeFieldControl("name", "builtin", "singleLine", {});
quoteBox.changeFieldControl("quoteText", "builtin", "richTextEditor", {});


/*
* Add quoteBox to list of content types allowed in content pages
*/
var contentTypeId = "content",
linkingFieldId = "items",
quoteBoxTypeId = "quoteBox";

var response = await makeRequest({
method: "GET",
url: `/content_types?sys.id[in]=${contentTypeId}`,
});

var validations = response.items[0].fields
.filter((field) => field.id == linkingFieldId)[0]
.items.validations.map((rule) => {
if (
rule.linkContentType &&
!rule.linkContentType.includes(quoteBoxTypeId)
) {
rule.linkContentType.push(quoteBoxTypeId);
}
return rule;
});

migration.editContentType(contentTypeId).editField(linkingFieldId).items({
type: "Link",
linkType: "Entry",
validations: validations,
});

/*
* Add quoteBox to list of content types allowed in accordion sections
*/
contentTypeId = "accordionSection";
linkingFieldId = "content";

response = await makeRequest({
method: "GET",
url: `/content_types?sys.id[in]=${contentTypeId}`,
});

validations = response.items[0].fields
.filter((field) => field.id == linkingFieldId)[0]
.items.validations.map((rule) => {
if (
rule.linkContentType &&
!rule.linkContentType.includes(quoteBoxTypeId)
) {
rule.linkContentType.push(quoteBoxTypeId);
}
return rule;
});

migration.editContentType(contentTypeId).editField(linkingFieldId).items({
type: "Link",
linkType: "Entry",
validations: validations,
});
};
3 changes: 2 additions & 1 deletion Contentful-Schema/migrations/manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
0011-create-agency-standards-page-category.cjs
0012-credit-block-component.cjs
0013-print-page-component.cjs
0014-add-type-field-to-infobox-component.cjs
0014-add-type-field-to-infobox-component.cjs
0015-quote-box-component.cjs
Binary file modified Contentful-Schema/migrations/migrations.tar.gz
Binary file not shown.

0 comments on commit 43d5705

Please sign in to comment.