22// Copyright contributors to the kepler.gl project
33
44import React , { PropsWithChildren } from 'react' ;
5- import styled , { withTheme } from 'styled-components' ;
5+ import styled , { withTheme , keyframes } from 'styled-components' ;
66
7- import { getNumRasterTilesBeingLoaded } from '@kepler.gl/layers' ;
7+ import { getNumRasterTilesBeingLoaded , getNumVectorTilesBeingLoaded } from '@kepler.gl/layers' ;
88
99type StyledContainerProps = {
1010 $isVisible ?: boolean ;
1111 $left : number ;
1212} ;
1313
14+ const spin = keyframes `
15+ 0% { transform: rotate(0deg); }
16+ 100% { transform: rotate(360deg); }
17+ ` ;
18+
19+ const Spinner = styled . div `
20+ display: inline-block;
21+ width: 14px;
22+ height: 14px;
23+ margin-right: 8px;
24+ border: 2px solid ${ props => props . theme . textColorHl } ;
25+ border-top-color: transparent;
26+ border-radius: 50%;
27+ animation: ${ spin } 0.8s linear infinite;
28+ vertical-align: middle;
29+ ` ;
30+
1431export const StyledContainer = styled . div < StyledContainerProps > `
1532 position: absolute;
1633 left: ${ props => props . $left } px;
1734 bottom: ${ props => props . theme . sidePanel . margin . left } px;
18- z-index: 1 ;
19- color: ${ props => props . theme . textColorHl } ;
35+ z-index: 1000 ;
36+ color: ${ props => props . theme . textColor } ;
2037 opacity: ${ props => ( props . $isVisible ? 1 : 0 ) } ;
2138 transition: opacity 0.5s ease-in-out;
2239 background-color: ${ props => props . theme . sidePanelBg } ;
23- border-radius: 0px;
24- padding-left: 3px;
25- padding-right: 3px;
26- font-size: 12px;
40+ padding: 8px 12px;
41+ font-size: 13px;
42+ font-weight: 500;
43+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
44+ backdrop-filter: blur(4px);
45+ display: flex;
46+ align-items: center;
2747` ;
2848
2949type LoadingIndicatorProps = {
@@ -45,18 +65,37 @@ const LoadingIndicator: React.FC<LoadingIndicatorProps & {theme: any}> = ({
4565 ( activeSidePanel ? ( sidePanelWidth || 0 ) + LEFT_POSITION_ADJUSTMENT : 0 ) +
4666 theme . sidePanel . margin . left ;
4767
48- // Helper message to track number of raster tiles that are being loaded
68+ // Helper message to track number of tiles that are being loaded
4969 const numRasterTilesInProgress = getNumRasterTilesBeingLoaded ( ) ;
50- const extraMessage =
70+ const numVectorTilesInProgress = getNumVectorTilesBeingLoaded ( ) ;
71+
72+ const rasterMessage =
5173 numRasterTilesInProgress < 1
5274 ? ''
5375 : `${ numRasterTilesInProgress } raster tile${
5476 numRasterTilesInProgress === 1 ? ' is' : 's are'
5577 } being loaded`;
5678
79+ const vectorMessage =
80+ numVectorTilesInProgress < 1
81+ ? ''
82+ : `${ numVectorTilesInProgress } vector tile${
83+ numVectorTilesInProgress === 1 ? ' is' : 's are'
84+ } being loaded`;
85+
86+ let extraMessage = '' ;
87+ if ( rasterMessage && vectorMessage ) {
88+ extraMessage = `${ rasterMessage . replace ( ' being loaded' , '' ) } and ${ vectorMessage } ` ;
89+ } else if ( rasterMessage ) {
90+ extraMessage = rasterMessage ;
91+ } else if ( vectorMessage ) {
92+ extraMessage = vectorMessage ;
93+ }
94+
5795 return (
5896 < StyledContainer $isVisible = { isVisible } $left = { left } >
59- { `Loading... ${ extraMessage } ` }
97+ < Spinner />
98+ < span > { `Loading... ${ extraMessage } ` } </ span >
6099 </ StyledContainer >
61100 ) ;
62101} ;
0 commit comments