diff --git a/src/components/progress_pill.tsx b/src/components/progress_pill.tsx new file mode 100644 index 0000000..16f6583 --- /dev/null +++ b/src/components/progress_pill.tsx @@ -0,0 +1,39 @@ +import {AppState} from '../pages/view_page'; + +interface ProgressPillProps { + loadingStatus: string; + state: AppState; +} + +/** + * ProgressPill displays a small, fixed status indicator in the bottom-left corner + * showing the current data loading or rendering status. + */ +export function ProgressPill({loadingStatus, state}: ProgressPillProps) { + if ( + !loadingStatus || + (state !== AppState.LOADING && state !== AppState.SHOWING_CHART) + ) { + return null; + } + + return ( +
+ {loadingStatus} +
+ ); +} diff --git a/src/pages/view_page.tsx b/src/pages/view_page.tsx index 73813f8..2125d46 100644 --- a/src/pages/view_page.tsx +++ b/src/pages/view_page.tsx @@ -13,6 +13,7 @@ import { printChart, } from '../chart'; import {ErrorMessage, ErrorPopup} from '../components/error_display'; +import {ProgressPill} from '../components/progress_pill'; import {DataSourceEnum, SourceSelection} from '../datasource/data_source'; import {EmbeddedSourceSpec} from '../datasource/embedded'; import { @@ -55,7 +56,7 @@ import {getI18nMessage} from '../util/error_i18n'; import {idToIndiMap, TopolaData} from '../util/gedcom_util'; import {DataSourceSpec, getArguments, getUrlForArgs} from '../util/url_args'; -enum AppState { +export enum AppState { INITIAL, LOADING, ERROR, @@ -561,31 +562,9 @@ export function ViewPage() { } } - const progressPill = - loadingStatus && - (state === AppState.LOADING || state === AppState.SHOWING_CHART) ? ( -
- {loadingStatus} -
- ) : null; - return ( <> - {progressPill} +