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

Render markdown #424

Merged
merged 5 commits into from May 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
883 changes: 882 additions & 1 deletion .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -47,6 +47,7 @@
"react-dom": "18.2.0",
"react-hook-form": "^7.45.4",
"react-keycloak-js": "^1.0.3",
"react-markdown": "^9.0.1",
"react-oidc-context": "^2.3.0",
"react-router-dom": "6.11.1",
"react-scroll": "^1.8.9",
Expand Down
11 changes: 11 additions & 0 deletions src/App.tsx
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
import { useQuery } from '@tanstack/react-query';
import { MarkdownText } from 'MarkdownTest';
import { fetchUserProfile } from 'api/requests';
import useSblAuth from 'api/useSblAuth';
import classNames from 'classnames';
Expand Down Expand Up @@ -189,6 +190,16 @@ export default function App(): ReactElement {
<Routes>
<Route path='/' element={<BasicLayout />}>
<Route path='/' element={<FilingHome />} />
{import.meta.env.DEV ? (
<Route
path='/markdown'
element={
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<MarkdownText />
</ProtectedRoute>
}
/>
) : null}
<Route
path='/filing/:year/:lei/upload'
element={
Expand Down
59 changes: 59 additions & 0 deletions src/MarkdownTest.tsx
@@ -0,0 +1,59 @@
/* eslint-disable react/jsx-curly-brace-presence */
/* eslint-disable prettier/prettier */
import { Grid } from 'design-system-react';
import type { JSXElement } from 'design-system-react/dist/types/jsxElement';
import Markdown from 'react-markdown';
import { useFilingAndSubmissionInfo } from 'utils/useFilingAndSubmissionInfo';

export function MarkdownText(): JSXElement {
const { submission } = useFilingAndSubmissionInfo({
lei: '123456789TESTBANK123',
filingPeriod: '2024',
});

return (
<Grid.Wrapper center>
<Grid.Row>
<Grid.Column width={8} className='u-mt15'>
MARKDOWN TEST
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column width={8} className='u-mt15'>
{submission?.validation_json?.logic_warnings?.details?.map(
({ validation }) => {
return (
<div key={validation.id} className='u-mb30'>
<div>{validation.id}</div>
<div>
<Markdown>{validation.description}</Markdown>
</div>
</div>
);
},
)}
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column width={8} className='u-mt15'>
<Markdown>
{`# H1\n## H2\n### H3`}
</Markdown>
<Markdown>{`**bold text**\n\n*italicized text*\n\n> blockquote\n`}</Markdown>
<Markdown>{`~~strikethrough~~`}</Markdown>
<Markdown>{`1. First item\n2. Second item\n4. Third item`}</Markdown>
<Markdown>{`- First item\n- Second item\n- Third item`}</Markdown>
{/* // eslint-disable-next-line react/jsx-curly-brace-presence */}
<Markdown>{"`code`"}</Markdown>
<Markdown>{"---"}</Markdown>
<Markdown>{"[Markdown Guide](https://www.markdownguide.org)"}</Markdown>
<Markdown>{"![alt text](https://www.markdownguide.org/assets/images/tux.png)"}</Markdown>
<Markdown>{`## Table\n\n| Syntax | Description |\n| ----------- | ----------- |\n| Header | Title |\n| Paragraph | Text |\n\n`}</Markdown>
<Markdown>{"## Codeblock\n\n```\n{\n'firstName': 'John',\n 'lastName': 'Smith',\n 'age': 25\n}\n```"}</Markdown>
</Grid.Column>
</Grid.Row>
</Grid.Wrapper>
);
}

export default MarkdownText;