diff --git a/apps/charterafrica/contrib/dokku/Dockerfile b/apps/charterafrica/contrib/dokku/Dockerfile index 219c3172c..cf7da23f0 100644 --- a/apps/charterafrica/contrib/dokku/Dockerfile +++ b/apps/charterafrica/contrib/dokku/Dockerfile @@ -1 +1 @@ -FROM codeforafrica/charterafrica-ui:0.1.17 +FROM codeforafrica/charterafrica-ui:0.1.18 diff --git a/apps/charterafrica/package.json b/apps/charterafrica/package.json index 76aadd6c3..9230d3b71 100644 --- a/apps/charterafrica/package.json +++ b/apps/charterafrica/package.json @@ -1,6 +1,6 @@ { "name": "charterafrica", - "version": "0.1.17", + "version": "0.1.18", "private": true, "author": "Code for Africa ", "description": "This is the official code for https://charter.africa site", diff --git a/apps/charterafrica/src/components/LongForm/LongForm.js b/apps/charterafrica/src/components/LongForm/LongForm.js index b5d81508d..3cb2f7ab8 100644 --- a/apps/charterafrica/src/components/LongForm/LongForm.js +++ b/apps/charterafrica/src/components/LongForm/LongForm.js @@ -3,9 +3,11 @@ import { Box } from "@mui/material"; import React from "react"; import { secondary } from "@/charterafrica/colors"; +import LongFormMediaBlock from "@/charterafrica/components/LongFormMediaBlock"; import LongFormRichText from "@/charterafrica/components/LongFormRichText"; const COMPONENT_BY_LONG_FORM_TYPE = { + mediaBlock: LongFormMediaBlock, richText: LongFormRichText, }; @@ -30,10 +32,10 @@ const LongForm = React.forwardRef(function LongForm(props, ref) { py: { xs: 5, md: "74.5px" }, }} > - {content.map((c) => { + {content.map((c, i) => { const Component = COMPONENT_BY_LONG_FORM_TYPE[c.slug]; if (Component) { - return ; + return ; } return null; })} diff --git a/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.js b/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.js new file mode 100644 index 000000000..ac63939ce --- /dev/null +++ b/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.js @@ -0,0 +1,44 @@ +import { RichTypography } from "@commons-ui/core"; +import { Figure } from "@commons-ui/next"; +import React from "react"; + +const LongFormMediaBlock = React.forwardRef( + function LongFormMediaBlock(props, ref) { + const { mediaBlockFields: { image, caption } = {}, sx } = props; + + return ( +
+ + {caption} + +
+ ); + }, +); + +export default LongFormMediaBlock; diff --git a/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.snap.js b/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.snap.js new file mode 100644 index 000000000..52c00bb08 --- /dev/null +++ b/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.snap.js @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders unchanged 1`] = ` +
+
+ Featured Post +
+ Image caption. +
+
+
+`; diff --git a/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.test.js b/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.test.js new file mode 100644 index 000000000..6d9a38d8c --- /dev/null +++ b/apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.test.js @@ -0,0 +1,29 @@ +import { createRender } from "@commons-ui/testing-library"; +import React from "react"; + +import LongFormMediaBlock from "./LongFormMediaBlock"; + +import theme from "@/charterafrica/theme"; + +// eslint-disable-next-line testing-library/render-result-naming-convention +const render = createRender({ theme }); + +const defaultProps = { + mediaBlockFields: { + image: { + id: "63e238816b52a21599ce6c70", + alt: "Featured Post", + url: "https://charterafrica.dev.codeforafrica.org/media/a20443263ce3904ad42cc5c7934e1040.jpeg", + }, + caption: "Image caption.", + }, + id: "63fc4ec5aca2d71a6679674f", + slug: "mediaBlock", +}; + +describe("", () => { + it("renders unchanged", () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/apps/charterafrica/src/components/LongFormMediaBlock/index.js b/apps/charterafrica/src/components/LongFormMediaBlock/index.js new file mode 100644 index 000000000..8181a245f --- /dev/null +++ b/apps/charterafrica/src/components/LongFormMediaBlock/index.js @@ -0,0 +1,3 @@ +import LongFormMediaBlock from "./LongFormMediaBlock"; + +export default LongFormMediaBlock; diff --git a/apps/charterafrica/src/payload/blocks/MediaBlock.js b/apps/charterafrica/src/payload/blocks/MediaBlock.js index 08b2530a6..886fda0bc 100644 --- a/apps/charterafrica/src/payload/blocks/MediaBlock.js +++ b/apps/charterafrica/src/payload/blocks/MediaBlock.js @@ -15,6 +15,13 @@ const MediaBlock = { mimeType: { contains: "image" }, }, }, + { + name: "caption", + type: "text", + label: { en: "Caption", fr: "Légende", pt: "Legenda" }, + required: false, + localized: true, + }, ], }), ],