Skip to content
Open
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
2 changes: 1 addition & 1 deletion 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": "1.1.11",
"version": "1.1.12",
"private": false,
"main": "dist/bundle.js",
"license": "MIT",
Expand Down
66 changes: 36 additions & 30 deletions src/atoms/Aside/Aside.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
import React from 'react';
import React, { useEffect } from 'react';
import Traverse from '../../utils/Traverse';

const Aside = (props) => {
return (
<>
<style>
{`
useEffect(() => {
// Inject styles into document head when component mounts
// This ensures styles work when used as an npm package
const styleId = 'apm-aside-styles';

if (!document.getElementById(styleId)) {
const style = document.createElement('style');
style.id = styleId;
style.textContent = `
.apm-aside-custom {
float: right;
width: 300px;
margin: 0 0 20px 20px;
padding: 0px 15px;
background-color: #f8f9fa;
color: #000;
border: 1px solid #dee2e6;
border-radius: 8px;
line-height: 1.4;
}

.apm-aside-custom p {
font-size: 13px;
}

@media (max-width: 957px) {
.apm-aside-custom {
float: right;
width: 300px;
margin: 0 0 20px 20px;
padding: 0px 15px;
background-color: #f8f9fa;
color: #000;
border: 1px solid #dee2e6;
border-radius: 8px;
line-height: 1.4;
float: none;
width: 100%;
margin: 20px 0;
}
}
`;
document.head.appendChild(style);
}
}, []);

.apm-aside-custom p {
font-size: 13px;
}

@media (max-width: 957px) {
.apm-aside-custom {
float: none;
width: 100%;
margin: 20px 0;
}
}
`}
</style>
<aside className="apm-aside-custom">{Traverse(props)}</aside>
</>
);
return <aside className="apm-aside-custom">{Traverse(props)}</aside>;
};

export default Aside;
28 changes: 3 additions & 25 deletions src/atoms/Aside/Aside.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,7 @@ const doc = {
test('It renders a body from a Prosemirror doc', () => {
const { container } = render(<Body nodeData={doc} />);

expect(container.innerHTML).toEqual(`<style>
.apm-aside-custom {
float: right;
width: 300px;
margin: 0 0 20px 20px;
padding: 0px 15px;
background-color: #f8f9fa;
color: #000;
border: 1px solid #dee2e6;
border-radius: 8px;
line-height: 1.4;
}

.apm-aside-custom p {
font-size: 13px;
}

@media (max-width: 957px) {
.apm-aside-custom {
float: none;
width: 100%;
margin: 20px 0;
}
}
</style><aside class="apm-aside-custom"><p>An aside.</p></aside>`);
expect(container.innerHTML).toEqual(
`<aside class="apm-aside-custom"><p>An aside.</p></aside>`
);
});