Skip to content

Commit

Permalink
Merge pull request #239 from microbiomedata/issue-199-guide-content-r…
Browse files Browse the repository at this point in the history
…efresh

Refresh Guide tab content
  • Loading branch information
pkalita-lbl authored Feb 28, 2025
2 parents c885927 + ce373c0 commit 2287106
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 258 deletions.
4 changes: 0 additions & 4 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { IonRouterOutlet } from "@ionic/react";
import { Redirect, Route } from "react-router-dom";
import TokenPage from "./pages/TokenPage/TokenPage";
import WelcomePage from "./pages/WelcomePage/WelcomePage";
import ChecklistPage from "./pages/ChecklistPage/ChecklistPage";
import AuthRoute from "./components/AuthRoute/AuthRoute";
import HomePage from "./pages/HomePage/HomePage";
import StudyViewPage from "./pages/StudyViewPage/StudyViewPage";
Expand Down Expand Up @@ -34,9 +33,6 @@ const Router: React.FC = () => {
<Route exact path={paths.welcome}>
<WelcomePage />
</Route>
<Route exact path={paths.checklist}>
<ChecklistPage />
</Route>

{/*
TAB ROUTES
Expand Down
21 changes: 0 additions & 21 deletions src/components/Checklist/Checklist.module.css

This file was deleted.

71 changes: 0 additions & 71 deletions src/components/Checklist/Checklist.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/components/Checklist/md-in-js/fieldwork-001.md.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/components/Checklist/md-in-js/fieldwork-002.md.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/components/Checklist/md-in-js/fieldwork-003.md.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/components/Checklist/md-in-js/fieldworkChecklist.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/Checklist/md-in-js/util.tsx

This file was deleted.

29 changes: 29 additions & 0 deletions src/components/Markdown/Markdown.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.markdown {
font-size: var(--nmdc-font-size-sm);
line-height: 1.5;

a {
text-decoration: none;
}

ul {
padding-inline-start: 1.25em;
}

li {
margin: 10px 0;
}

li::marker {
color: var(--ion-color-primary);
font-size: 1.25em;
line-height: 0;
}

blockquote {
margin: 0;
border-left: 4px solid var(--ion-color-primary);
padding-left: 1em;
opacity: 0.8;
}
}
33 changes: 33 additions & 0 deletions src/components/Markdown/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import SectionHeader, { Variant } from "../SectionHeader/SectionHeader";
import ReactMarkdown from "react-markdown";

import styles from "./Markdown.module.css";

interface MarkdownProps {
/** The markdown content to render. */
children: string;

/** A CSS class name to apply to the container element */
className?: string;
}

const Markdown: React.FC<MarkdownProps> = ({ children, className }) => {
return (
<ReactMarkdown
className={`ion-padding ${styles.markdown} ${className}`}
components={{
h1: ({ children }) => (
<SectionHeader variant={Variant.NoMargin}>{children}</SectionHeader>
),
blockquote: ({ children }) => (
<blockquote className={styles.blockquote}>{children}</blockquote>
),
}}
>
{children}
</ReactMarkdown>
);
};

export default Markdown;
16 changes: 12 additions & 4 deletions src/components/SectionHeader/SectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styles from "./SectionHeader.module.css";
export enum Variant {
Default, // receives default styling
WithinListHeader, // receives custom styling that compensates for `<IonListHeader>` styling
NoMargin, // receives no margin
}

interface Props extends HTMLAttributes<PropsWithChildren> {
Expand All @@ -17,12 +18,19 @@ const SectionHeader: React.FC<Props> = ({
variant = Variant.Default,
}) => {
// Customize the `className` value based upon the specified variant.
let classNameVal = `${styles.header} ion-margin ${className}`;
if (variant === Variant.WithinListHeader) {
classNameVal = `${styles.header} ${styles.withinListHeader} ${className}`;
const classNameSet = new Set([styles.header]);
if (className) {
classNameSet.add(className);
}
if (variant === Variant.Default) {
classNameSet.add("ion-margin");
} else if (variant === Variant.WithinListHeader) {
classNameSet.add(styles.withinListHeader);
} else if (variant === Variant.NoMargin) {
classNameSet.add("ion-no-margin");
}

return <div className={classNameVal}>{children}</div>;
return <div className={[...classNameSet].join(" ")}>{children}</div>;
};

export default SectionHeader;
16 changes: 0 additions & 16 deletions src/pages/ChecklistPage/ChecklistPage.stories.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions src/pages/ChecklistPage/ChecklistPage.tsx

This file was deleted.

6 changes: 4 additions & 2 deletions src/pages/GuidePage/GuidePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";
import { IonContent, IonHeader, IonPage, IonTitle } from "@ionic/react";
import Checklist from "../../components/Checklist/Checklist";
import ThemedToolbar from "../../components/ThemedToolbar/ThemedToolbar";
import Markdown from "../../components/Markdown/Markdown";

import guidePageMd from "./md/guide-page.md?raw";

const GuidePage: React.FC = () => {
return (
Expand All @@ -12,7 +14,7 @@ const GuidePage: React.FC = () => {
</ThemedToolbar>
</IonHeader>
<IonContent>
<Checklist />
<Markdown>{guidePageMd}</Markdown>
</IonContent>
</IonPage>
);
Expand Down
Loading

0 comments on commit 2287106

Please sign in to comment.