Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bar & Histogram & Formula & ComparativeFormula Widgets: Add a skeleton for loading state #674

Merged
merged 17 commits into from
May 24, 2023
Prev Previous commit
Next Next commit
minor fixes
  • Loading branch information
vmilan committed May 23, 2023
commit e9a8f07db555977e2dc1e62a7a2e5aff5cf7dfd5
1 change: 1 addition & 0 deletions packages/react-ui/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export type ComparativeFormulaWidgetUI = {
animated?: boolean;
animationOptions?: AnimationOptions;
formatter?: (n: number) => React.ReactNode;
isLoading?: boolean;
};

export enum ORDER_TYPES {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/src/widgets/BarWidgetUI/BarSkeleton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Skeleton } from '@mui/material';
import { SkeletonBarsGrid, SkeletonBarItem } from '../SkeletonWidgets';
import { SkeletonBarsGrid, SkeletonBarItem, SKELETON_HEIGHT } from '../SkeletonWidgets';

const BarSkeleton = ({ height }) => {
return (
Expand All @@ -8,7 +8,7 @@ const BarSkeleton = ({ height }) => {
<Skeleton width={48} height={8} />
</Box>

<SkeletonBarsGrid style={{ height: height }}>
<SkeletonBarsGrid style={{ height: height || SKELETON_HEIGHT }}>
<SkeletonBarItem variant='rectangular' height='20%' />
<SkeletonBarItem variant='rectangular' height='40%' />
<SkeletonBarItem variant='rectangular' height='60%' />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Box, Skeleton } from '@mui/material';
import { SkeletonGraphGrid, SkeletonThinBarItem } from '../SkeletonWidgets';
import {
SKELETON_HEIGHT,
SkeletonGraphGrid,
SkeletonThinBarItem
} from '../SkeletonWidgets';

const HistogramWidgetLoadingUI = ({ height }) => {
const HistogramSkeleton = ({ height }) => {
return (
<>
<Box mb={2}>
<Skeleton width={48} height={8} />
</Box>

<SkeletonGraphGrid style={{ height: height }}>
<SkeletonGraphGrid style={{ height: height || SKELETON_HEIGHT }}>
<SkeletonThinBarItem variant='rectangular' height='20%' />
<SkeletonThinBarItem variant='rectangular' height='40%' />
<SkeletonThinBarItem variant='rectangular' height='60%' />
Expand All @@ -26,4 +30,4 @@ const HistogramWidgetLoadingUI = ({ height }) => {
);
};

export default HistogramWidgetLoadingUI;
export default HistogramSkeleton;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { processFormatterRes } from '../utils/formatterUtils';
import detectTouchscreen from '../utils/detectTouchScreen';
import useHistogramInteractivity from './useHistogramInteractivity';
import Typography from '../../components/atoms/Typography';
import HistogramWidgetLoadingUI from './HistogramWidgetLoadingUI';
import HistogramSkeleton from './HistogramSkeleton';

const IS_TOUCH_SCREEN = detectTouchscreen();

Expand Down Expand Up @@ -264,7 +264,7 @@ function HistogramWidgetUI({
0
);

if (isLoading) return <HistogramWidgetLoadingUI height={height} />;
if (isLoading) return <HistogramSkeleton height={height} />;

return (
<div>
Expand Down