-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspired by code in byline.js (same parent component) and footer.js (also parses Markdown) Markdown loads lazily, but I think it will be useful to support Markdown format instead of just plain text (which could be loaded earlier).
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { Suspense, lazy } from "react"; | ||
import { connect } from "react-redux"; | ||
import styled from 'styled-components'; | ||
import { FaExclamationTriangle } from "react-icons/fa"; | ||
import { withTranslation } from 'react-i18next'; | ||
|
||
const MarkdownDisplay = lazy(() => import("../markdownDisplay")); | ||
|
||
const WarningContainer = styled.div` | ||
background-color: #FFF1D1; | ||
display: flex; | ||
align-items: stretch; | ||
`; | ||
|
||
const WarningIconContainer = styled.div` | ||
background-color: #FFC641; | ||
padding: 0 7px; | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
const WarningIcon = styled.div` | ||
padding-top: 3px; | ||
color: white; | ||
font-size: 24px; | ||
`; | ||
|
||
const WarningText = styled.div` | ||
padding-left: 7px; | ||
font-size: 15px; | ||
`; | ||
|
||
/** | ||
* React component for the warning of the current dataset. | ||
*/ | ||
@connect((state) => { | ||
return { | ||
warning: state.metadata.warning | ||
}; | ||
}) | ||
class Warning extends React.Component { | ||
render() { | ||
const { warning } = this.props; | ||
|
||
if (warning === undefined) return null; | ||
|
||
return ( | ||
<Suspense fallback={null}> | ||
<WarningContainer> | ||
<WarningIconContainer> | ||
<WarningIcon> | ||
<FaExclamationTriangle /> | ||
</WarningIcon> | ||
</WarningIconContainer> | ||
<WarningText> | ||
<MarkdownDisplay mdstring={warning} /> | ||
</WarningText> | ||
</WarningContainer> | ||
</Suspense> | ||
); | ||
} | ||
} | ||
|
||
const WithTranslation = withTranslation()(Warning); | ||
export default WithTranslation; |