Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new corrections node per #43285 #71

Merged
merged 2 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@apmg/amat",
"authors": "[Geoff Hankerson ghankerson@mpr.org, Kim Thompson kthompson@mpr.org, Jason Phan jphan@mpr.org]",
"version": "0.6.3",
"version": "0.7.0",
"private": false,
"main": "dist/bundle.js",
"license": "MIT",
Expand All @@ -28,8 +28,8 @@
"react-dom": "^16.13.0"
},
"dependencies": {
"@apmg/mimas": "0.3.3",
"@apmg/enceladus": "^0.5.6",
"@apmg/mimas": "0.3.3",
"@apmg/react-oembed-container": "git://github.com/APMG/react-oembed-container.git#twitter-load-fix",
"@nprapps/sidechain": "^1.0.13",
"classnames": "^2.2.6",
Expand Down
29 changes: 29 additions & 0 deletions src/atoms/ApmCorrection/ApmCorrection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import Traverse from '../../utils/Traverse';

const ApmCorrection = (props) => {
const {
attrs: { timestamp }
} = props.nodeData;
return (
<div className="apm-correction">
<div className="apm-correction-title">Correction</div>
<div className="apm-correction-timestamp">{timestamp}</div>
<div className="apm-correction-body">
<Traverse {...props} />
</div>
</div>
);
};

ApmCorrection.propTypes = {
nodeData: PropTypes.shape({
attrs: PropTypes.object,
content: PropTypes.arrayOf(PropTypes.object),
type: PropTypes.string
}),
components: PropTypes.object
};

export default ApmCorrection;
36 changes: 36 additions & 0 deletions src/atoms/ApmCorrection/ApmCorrection.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import Body from '../../components/Body/Body';
import { render, cleanup } from '@testing-library/react';

afterEach(cleanup);

const doc = {
type: 'doc',
version: 1,
content: [
{
attrs: {
timestamp: '2019-09-04'
},
content: [
{
content: [
{
text: 'An update would go here.',
type: 'text'
}
],
type: 'paragraph'
}
],
type: 'apm_correction'
}
]
};

test('Renders footnote list', async () => {
const { container } = render(<Body nodeData={doc} />);

const expected = `<div class="apm-correction"><div class="apm-correction-title">Correction</div><div class="apm-correction-timestamp">2019-09-04</div><div class="apm-correction-body"><p>An update would go here.</p></div></div>`;
expect(container.innerHTML).toEqual(expected);
});
2 changes: 2 additions & 0 deletions src/utils/DefaultComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ import Aside from '../atoms/Aside/Aside';
import ApmFootnoteList from '../atoms/ApmFootnoteList/ApmFootnoteList';
import ApmFootnote from '../atoms/ApmFootnote/ApmFootnote';
import ApmFootnoteListItem from '../atoms/ApmFootnoteListItem/ApmFootnoteListItem';
import ApmCorrection from '../atoms/ApmCorrection/ApmCorrection';

const DefaultComponents = () => {
return {
apm_attachment: ApmAttachment,
apm_audio: ApmAudio,
apm_correction: ApmCorrection,
apm_custom_html: CustomHtml,
apm_gallery: ApmGallery,
apm_oembed: ApmOembed,
Expand Down
Loading