Skip to content

Commit f27a0c7

Browse files
authored
Merge branch 'master' into catalogcard
2 parents ff936b4 + 21bed8a commit f27a0c7

4 files changed

Lines changed: 47 additions & 5 deletions

File tree

src/custom/LearningCard/LearningCard.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ interface Tutorial {
2525

2626
interface Props {
2727
tutorial: Tutorial;
28-
path: string;
28+
path?: string;
2929
courseCount: number;
3030
courseType: string;
3131
}
3232

33+
const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string }>> = ({ path, children }) => {
34+
if (!path) {
35+
return <>{children}</>;
36+
}
37+
38+
return <CardLink href={path}>{children}</CardLink>;
39+
};
40+
3341
const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType }) => {
3442
return (
3543
<CardWrapper>
@@ -57,7 +65,7 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
5765
</CardParent>
5866
</Card2>
5967
) : (
60-
<CardLink href={path}>
68+
<OptionalLink path={path}>
6169
<CardActive>
6270
<CardParent style={{ borderTop: `5px solid ${tutorial.frontmatter.themeColor}` }}>
6371
<div>
@@ -88,7 +96,7 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
8896
</div>
8997
</CardParent>
9098
</CardActive>
91-
</CardLink>
99+
</OptionalLink>
92100
)}
93101
</CardWrapper>
94102
);

src/custom/Markdown/index.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import ReactMarkdown from 'react-markdown';
22
import rehypeRaw from 'rehype-raw';
33
import remarkGfm from 'remark-gfm';
44
import {
5+
BasicAnchorMarkdown,
56
StyledMarkdown,
67
StyledMarkdownBlockquote,
78
StyledMarkdownH1,
@@ -97,3 +98,27 @@ export const RenderMarkdownTooltip: React.FC<RenderMarkdownProps> = ({ content }
9798
</ReactMarkdown>
9899
);
99100
};
101+
102+
// Markdown support for notifications markdown content
103+
export const BasicMarkdown: React.FC<RenderMarkdownProps> = ({ content }) => {
104+
return (
105+
<ReactMarkdown
106+
remarkPlugins={[remarkGfm]}
107+
components={{
108+
a: ({ ...props }) => (
109+
<BasicAnchorMarkdown
110+
onClick={(e) => {
111+
window.open(props.href, '_blank');
112+
e.stopPropagation();
113+
}}
114+
as="a"
115+
>
116+
{props.children}
117+
</BasicAnchorMarkdown>
118+
)
119+
}}
120+
>
121+
{content}
122+
</ReactMarkdown>
123+
);
124+
};

src/custom/Markdown/style.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ export const StyledMarkdown = styled('a')(({ theme }) => ({
1010
cursor: 'pointer'
1111
}));
1212

13+
// anchor style for notifications markdown content
14+
export const BasicAnchorMarkdown = styled('a')(() => ({
15+
textDecoration: 'none',
16+
'&:hover': {
17+
textDecoration: 'underline'
18+
},
19+
cursor: 'pointer'
20+
}));
21+
1322
export const StyledMarkdownP = styled('p')(({ theme }) => ({
1423
color: theme.palette.text.default,
1524
marginBlock: '0px',

src/custom/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { useWindowDimensions } from './Helpers/Dimension';
3131
import { useNotificationHandler } from './Helpers/Notification';
3232
import { ColView, updateVisibleColumns } from './Helpers/ResponsiveColumns/responsive-coulmns.tsx';
3333
import { LearningCard } from './LearningCard';
34-
import { RenderMarkdown } from './Markdown';
34+
import { BasicMarkdown, RenderMarkdown } from './Markdown';
3535
import { ModalCard } from './ModalCard';
3636
import PopperListener, { IPopperListener } from './PopperListener';
3737
import PromptComponent from './Prompt';
@@ -110,7 +110,7 @@ export {
110110

111111
// Markdown
112112
export { StyledMarkdown } from './Markdown/style';
113-
export { RenderMarkdown };
113+
export { BasicMarkdown, RenderMarkdown };
114114

115115
// Stepper
116116
export { CustomizedStepper, useStepper } from './Stepper';

0 commit comments

Comments
 (0)