-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add generic title/content notice type (#1677)
- Loading branch information
Showing
7 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/containers/AdminDashboard/components/TitleContentNoticeCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Card from "@material-ui/core/Card"; | ||
import CardContent from "@material-ui/core/CardContent"; | ||
import CardHeader from "@material-ui/core/CardHeader"; | ||
import Announcement from "@material-ui/icons/Announcement"; | ||
import React from "react"; | ||
import type { Components } from "react-markdown"; | ||
import ReactMarkdown from "react-markdown"; | ||
|
||
type TitleContentNoticeCardProps = { | ||
title: string; | ||
avatarIcon: string; | ||
avatarColor: | ||
| "error" | ||
| "inherit" | ||
| "disabled" | ||
| "action" | ||
| "primary" | ||
| "secondary" | ||
| undefined; | ||
markdownContent: string; | ||
}; | ||
|
||
// Force links to open in a new window/tab | ||
const components: Components = { | ||
a: ({ node: _node, children, href, title, ...props }) => ( | ||
<a href={href} title={title} rel="noreferrer" target="_blank" {...props}> | ||
{children} | ||
</a> | ||
) | ||
}; | ||
|
||
const TitleContentNoticeCard: React.FC<TitleContentNoticeCardProps> = ( | ||
props | ||
) => { | ||
const avatar = | ||
props.avatarIcon === "announcement" ? ( | ||
<Announcement color={props.avatarColor} /> | ||
) : null; | ||
|
||
return ( | ||
<Card variant="outlined" style={{ marginBottom: "2em" }}> | ||
<CardHeader title={props.title} avatar={avatar} /> | ||
<CardContent> | ||
<ReactMarkdown components={components}> | ||
{props.markdownContent} | ||
</ReactMarkdown> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default TitleContentNoticeCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters