Skip to content

Commit

Permalink
Added new markdown viewer for IC about page (#921)
Browse files Browse the repository at this point in the history
* added new markdown viewer

* update css

* fix about test
  • Loading branch information
Megha-Dev-19 authored Aug 12, 2024
1 parent b6dcc1a commit b74195d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const content = props.content ?? "";
const height = props.height ?? "200px";

const code = `
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
height: ${height};
}
blockquote {
margin: 1em 0;
padding-left: 1.5em;
border-left: 4px solid #ccc;
color: #666;
font-style: italic;
font-size: inherit;
}
pre {
background-color: #f4f4f4;
border: 1px solid #ddd;
border-radius: 4px;
padding: 1em;
overflow-x: auto;
font-family: "Courier New", Courier, monospace;
}
a {
color: #3c697d;
font-weight: 500 !important;
}
</style>
</head>
<body>
<div id="content"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>
let isViewerInitialized = false;
function updateContent(content) {
document.getElementById('content').innerHTML = marked.parse(content);
}
window.addEventListener("message", (event) => {
updateContent(event.data.content);
});
</script>
</body>
</html>
`;

return (
<iframe
srcDoc={code}
message={{
content: content,
}}
style={{ height: height }}
className="w-100"
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ useEffect(() => {

function Preview() {
return (
<Tile className="p-3" style={{ background: "white" }}>
<Tile className="p-3" style={{ background: "white", minHeight: "500px" }}>
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.molecule.Markdown`}
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.SimpleMDEViewer`}
props={{
content: content,
height: "500px",
}}
/>
</Tile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ if (!profile) {
return (
<div style={{ width: "-webkit-fill-available" }} className="p-3">
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.molecule.Markdown`}
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.SimpleMDEViewer`}
props={{
content: profile.description,
height: "70vh",
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ test.describe("Wallet is connected", () => {
const aboutHeaderLink = await page.getByRole("link", { name: "About" });
await expect(aboutHeaderLink).toBeVisible();
await aboutHeaderLink.click();
await expect(await page.locator(".content-container")).toContainText(
"Introduction"
);
await expect(
page.frameLocator("iframe").getByRole("heading", { name: "Introduction" })
).toBeVisible();

const proposalsHeaderLink = await page.getByRole("link", {
name: "Proposals",
Expand Down

0 comments on commit b74195d

Please sign in to comment.