Skip to content

Commit

Permalink
:sparkles (sources-modal) show loading indicator when not ready to re…
Browse files Browse the repository at this point in the history
…nder
  • Loading branch information
sophiamersmann committed Nov 23, 2023
1 parent a44bb08 commit 35061fe
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions packages/@ourworldindata/grapher/src/modal/SourcesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { SourcesKeyDataTable } from "./SourcesKeyDataTable"
import { SourcesDescriptions } from "./SourcesDescriptions"
import { Tabs } from "../tabs/Tabs"
import { ExpandableTabs } from "../tabs/ExpandableTabs"
import { LoadingIndicator } from "../loadingIndicator/LoadingIndicator"

// keep in sync with variables in SourcesModal.scss
const MAX_WIDTH = 640
Expand All @@ -36,6 +37,7 @@ const TAB_FONT_SIZE = 13
const TAB_GAP = 8

export interface SourcesModalManager {
isReady?: boolean
adminBaseUrl?: string
columnsWithSourcesExtensive: CoreColumn[]
showAdminControls?: boolean
Expand Down Expand Up @@ -231,6 +233,29 @@ export class SourcesModal extends React.Component<
)
}

private renderMultipleSources(): JSX.Element {
return (
<>
<p className="note-multiple-indicators">
This chart is composed of multiple indicators. Select an
indicator for more information.
</p>
{this.renderTabs()}
{this.renderSource(this.columns[this.state.activeTabIndex])}
</>
)
}

private renderModalContent(): JSX.Element | null {
if (this.deduplicatedColumn) {
return this.renderDeduplicatedSource()
}

return this.columns.length === 1
? this.renderSource(this.columns[0])
: this.renderMultipleSources()
}

render(): JSX.Element {
return (
<Modal
Expand All @@ -241,21 +266,10 @@ export class SourcesModal extends React.Component<
isHeightFixed={true}
>
<div className="SourcesModalContent">
{this.deduplicatedColumn ? (
this.renderDeduplicatedSource()
) : this.columns.length === 1 ? (
this.renderSource(this.columns[0])
{this.manager.isReady ? (
this.renderModalContent()
) : (
<>
<p className="note-multiple-indicators">
This chart is composed of multiple indicators.
Select an indicator for more information.
</p>
{this.renderTabs()}
{this.renderSource(
this.columns[this.state.activeTabIndex]
)}
</>
<LoadingIndicator />
)}
</div>
</Modal>
Expand Down

0 comments on commit 35061fe

Please sign in to comment.