-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #671 from CodeForAfrica/feat/charterafrica_longfor…
…m_mediablock @/charterafrica MediaBlock
- Loading branch information
Showing
8 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
FROM codeforafrica/charterafrica-ui:0.1.17 | ||
FROM codeforafrica/charterafrica-ui:0.1.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "charterafrica", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"private": true, | ||
"author": "Code for Africa <[email protected]>", | ||
"description": "This is the official code for https://charter.africa site", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Figure | ||
ImageProps={{ | ||
src: image.url, | ||
alt: image.alt || caption, | ||
// We're going to set img size directly using style https://nextjs.org/docs/api-reference/next/image#style | ||
fill: false, | ||
height: 0, | ||
width: 0, | ||
style: { width: "100%", height: "auto" }, | ||
}} | ||
sx={{ | ||
my: 2, | ||
...sx, | ||
}} | ||
ref={ref} | ||
> | ||
<RichTypography | ||
component="figcaption" | ||
html={false} | ||
variant="caption" | ||
sx={{ | ||
mt: 1, | ||
typography: { | ||
md: "p2", | ||
}, | ||
}} | ||
> | ||
{caption} | ||
</RichTypography> | ||
</Figure> | ||
); | ||
}, | ||
); | ||
|
||
export default LongFormMediaBlock; |
27 changes: 27 additions & 0 deletions
27
apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.snap.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<LongFormMediaBlock /> renders unchanged 1`] = ` | ||
<div> | ||
<figure | ||
class="MuiBox-root css-g1fxym" | ||
> | ||
<img | ||
alt="Featured Post" | ||
class="css-g98gbd" | ||
data-nimg="1" | ||
decoding="async" | ||
height="0" | ||
loading="lazy" | ||
src="/_next/image?url=https%3A%2F%2Fcharterafrica.dev.codeforafrica.org%2Fmedia%2Fa20443263ce3904ad42cc5c7934e1040.jpeg&w=16&q=75" | ||
srcset="/_next/image?url=https%3A%2F%2Fcharterafrica.dev.codeforafrica.org%2Fmedia%2Fa20443263ce3904ad42cc5c7934e1040.jpeg&w=16&q=75 1x" | ||
style="color: transparent; width: 100%; height: auto;" | ||
width="0" | ||
/> | ||
<figcaption | ||
class="MuiTypography-root MuiTypography-caption css-18iyh8o-MuiTypography-root" | ||
> | ||
Image caption. | ||
</figcaption> | ||
</figure> | ||
</div> | ||
`; |
29 changes: 29 additions & 0 deletions
29
apps/charterafrica/src/components/LongFormMediaBlock/LongFormMediaBlock.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<LongFormMediaBlock />", () => { | ||
it("renders unchanged", () => { | ||
const { container } = render(<LongFormMediaBlock {...defaultProps} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
apps/charterafrica/src/components/LongFormMediaBlock/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import LongFormMediaBlock from "./LongFormMediaBlock"; | ||
|
||
export default LongFormMediaBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters