mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-07-17 17:21:48 +00:00
Extract ProgressPill from view_page.tsx
This commit is contained in:
39
src/components/progress_pill.tsx
Normal file
39
src/components/progress_pill.tsx
Normal file
@@ -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 (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'fixed',
|
||||||
|
bottom: 16,
|
||||||
|
left: 16,
|
||||||
|
background: 'rgba(0,0,0,0.7)',
|
||||||
|
color: '#fff',
|
||||||
|
padding: '6px 12px',
|
||||||
|
borderRadius: 4,
|
||||||
|
fontFamily: 'monospace',
|
||||||
|
fontSize: 12,
|
||||||
|
zIndex: 9999,
|
||||||
|
pointerEvents: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{loadingStatus}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
printChart,
|
printChart,
|
||||||
} from '../chart';
|
} from '../chart';
|
||||||
import {ErrorMessage, ErrorPopup} from '../components/error_display';
|
import {ErrorMessage, ErrorPopup} from '../components/error_display';
|
||||||
|
import {ProgressPill} from '../components/progress_pill';
|
||||||
import {DataSourceEnum, SourceSelection} from '../datasource/data_source';
|
import {DataSourceEnum, SourceSelection} from '../datasource/data_source';
|
||||||
import {EmbeddedSourceSpec} from '../datasource/embedded';
|
import {EmbeddedSourceSpec} from '../datasource/embedded';
|
||||||
import {
|
import {
|
||||||
@@ -55,7 +56,7 @@ import {getI18nMessage} from '../util/error_i18n';
|
|||||||
import {idToIndiMap, TopolaData} from '../util/gedcom_util';
|
import {idToIndiMap, TopolaData} from '../util/gedcom_util';
|
||||||
import {DataSourceSpec, getArguments, getUrlForArgs} from '../util/url_args';
|
import {DataSourceSpec, getArguments, getUrlForArgs} from '../util/url_args';
|
||||||
|
|
||||||
enum AppState {
|
export enum AppState {
|
||||||
INITIAL,
|
INITIAL,
|
||||||
LOADING,
|
LOADING,
|
||||||
ERROR,
|
ERROR,
|
||||||
@@ -561,31 +562,9 @@ export function ViewPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const progressPill =
|
|
||||||
loadingStatus &&
|
|
||||||
(state === AppState.LOADING || state === AppState.SHOWING_CHART) ? (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
position: 'fixed',
|
|
||||||
bottom: 16,
|
|
||||||
left: 16,
|
|
||||||
background: 'rgba(0,0,0,0.7)',
|
|
||||||
color: '#fff',
|
|
||||||
padding: '6px 12px',
|
|
||||||
borderRadius: 4,
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
fontSize: 12,
|
|
||||||
zIndex: 9999,
|
|
||||||
pointerEvents: 'none',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{loadingStatus}
|
|
||||||
</div>
|
|
||||||
) : null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{progressPill}
|
<ProgressPill loadingStatus={loadingStatus} state={state} />
|
||||||
<TopBar
|
<TopBar
|
||||||
data={data?.chartData}
|
data={data?.chartData}
|
||||||
allowAllRelativesChart={sourceSpec?.source !== DataSourceEnum.WIKITREE}
|
allowAllRelativesChart={sourceSpec?.source !== DataSourceEnum.WIKITREE}
|
||||||
|
|||||||
Reference in New Issue
Block a user