Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds an optional dialog and markdown support (#2728)
Adds the option of showing a dialog and adds markdown support to it, could be useful to show changelogs inside Unleash in the future. ![image](https://user-images.githubusercontent.com/14320932/209147164-ed19c9ab-fae5-452b-9aab-075d058ba10e.png)
- Loading branch information
Showing
4 changed files
with
627 additions
and
40 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
36 changes: 36 additions & 0 deletions
36
frontend/src/component/common/MessageBanner/MessageBannerDialog/MessageBannerDialog.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,36 @@ | ||
import { styled } from '@mui/material'; | ||
import { Dialogue } from 'component/common/Dialogue/Dialogue'; | ||
import ReactMarkdown from 'react-markdown'; | ||
|
||
const StyledReactMarkdown = styled(ReactMarkdown)(({ theme }) => ({ | ||
'h1, h2, h3': { | ||
margin: theme.spacing(2, 0), | ||
}, | ||
})); | ||
|
||
interface IMessageBannerDialogProps { | ||
title: string; | ||
open: boolean; | ||
setOpen: React.Dispatch<React.SetStateAction<boolean>>; | ||
children: string; | ||
} | ||
|
||
export const MessageBannerDialog = ({ | ||
open, | ||
setOpen, | ||
title, | ||
children, | ||
}: IMessageBannerDialogProps) => { | ||
return ( | ||
<Dialogue | ||
title={title} | ||
open={open} | ||
secondaryButtonText="Close" | ||
onClose={() => { | ||
setOpen(false); | ||
}} | ||
> | ||
<StyledReactMarkdown>{children}</StyledReactMarkdown> | ||
</Dialogue> | ||
); | ||
}; |
Oops, something went wrong.