diff --git a/packages/@ourworldindata/grapher/src/modal/DownloadModal.tsx b/packages/@ourworldindata/grapher/src/modal/DownloadModal.tsx index 1f7bb7984c5..2896de8b7af 100644 --- a/packages/@ourworldindata/grapher/src/modal/DownloadModal.tsx +++ b/packages/@ourworldindata/grapher/src/modal/DownloadModal.tsx @@ -9,7 +9,11 @@ import { } from "@ourworldindata/utils" import { observable, computed, action } from "mobx" import { observer } from "mobx-react" -import { Checkbox, CodeSnippet } from "@ourworldindata/components" +import { + Checkbox, + CodeSnippet, + MarkdownTextWrap, +} from "@ourworldindata/components" import { LoadingIndicator } from "../loadingIndicator/LoadingIndicator" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js" import { faDownload, faInfoCircle } from "@fortawesome/free-solid-svg-icons" @@ -43,6 +47,8 @@ export interface DownloadModalManager { framePaddingVertical?: number showAdminControls?: boolean bakedGrapherURL?: string + sourcesLine?: string + isSourcesModalOpen?: boolean } interface DownloadModalProps { @@ -237,6 +243,39 @@ export class DownloadModal extends React.Component { return this.hasDetails || !!this.manager.showAdminControls } + @computed protected get sourcesLine(): string { + return this.manager.sourcesLine?.replace(/\r\n|\n|\r/g, "") ?? "" + } + + @computed protected get sourcesText(): string { + return `**Data source:** ${this.sourcesLine}` + } + + private renderSources(): JSX.Element | null { + const sources = new MarkdownTextWrap({ + text: `**Data source:** ${this.sourcesLine}`, + fontSize: 13, + }) + + return ( +

+ {sources.renderHTML()} + {" – "} + { + e.stopPropagation() + + this.manager.isDownloadModalOpen = false + this.manager.isSourcesModalOpen = true + })} + > + Learn more about this data and citations + +

+ ) + } private renderReady(): JSX.Element { const { manager, @@ -413,7 +452,7 @@ df = pd.read_csv("${csvUrl}")`

Source

-

Source note goes here

+

{this.renderSources()}

Download