diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6980ab422..a99b9fd19 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Not released
+- Bar & Histogram & Formula & ComparativeFormula Widgets: Add a skeleton for loading state [#674](https://github.com/CartoDB/carto-react/pull/674)
+
## 2.0
## 2.0.4 (2023-05-19)
diff --git a/packages/react-ui/__tests__/widgets/BarWidgetUI.test.js b/packages/react-ui/__tests__/widgets/BarWidgetUI.test.js
index db5e29700..f956698cc 100644
--- a/packages/react-ui/__tests__/widgets/BarWidgetUI.test.js
+++ b/packages/react-ui/__tests__/widgets/BarWidgetUI.test.js
@@ -1,6 +1,6 @@
import React from 'react';
import { render, fireEvent, screen } from '../widgets/utils/testUtils';
-import BarWidgetUI from '../../src/widgets/BarWidgetUI';
+import BarWidgetUI from '../../src/widgets/BarWidgetUI/BarWidgetUI';
import { mockEcharts } from './testUtils';
describe('BarWidgetUI', () => {
diff --git a/packages/react-ui/__tests__/widgets/FormulaWidgetUI.test.js b/packages/react-ui/__tests__/widgets/FormulaWidgetUI.test.js
index 899ba8edb..04532bfa3 100644
--- a/packages/react-ui/__tests__/widgets/FormulaWidgetUI.test.js
+++ b/packages/react-ui/__tests__/widgets/FormulaWidgetUI.test.js
@@ -1,6 +1,6 @@
import React from 'react';
import { render, screen } from '../widgets/utils/testUtils';
-import FormulaWidgetUI from '../../src/widgets/FormulaWidgetUI';
+import FormulaWidgetUI from '../../src/widgets/FormulaWidgetUI/FormulaWidgetUI';
import { currencyFormatter } from './testUtils';
describe('FormulaWidgetUI', () => {
diff --git a/packages/react-ui/__tests__/widgets/WrapperWidgetUI.test.js b/packages/react-ui/__tests__/widgets/WrapperWidgetUI.test.js
index fe143aaf6..966cd9ac4 100644
--- a/packages/react-ui/__tests__/widgets/WrapperWidgetUI.test.js
+++ b/packages/react-ui/__tests__/widgets/WrapperWidgetUI.test.js
@@ -6,7 +6,7 @@ import {
waitForElementToBeRemoved
} from '../widgets/utils/testUtils';
import WrapperWidgetUI from '../../src/widgets/WrapperWidgetUI';
-import FormulaWidgetUI from '../../src/widgets/FormulaWidgetUI';
+import FormulaWidgetUI from '../../src/widgets/FormulaWidgetUI/FormulaWidgetUI';
describe('WrapperWidgetUI', () => {
const TITLE = 'test';
diff --git a/packages/react-ui/src/index.d.ts b/packages/react-ui/src/index.d.ts
index ba1bab35f..9093088cb 100644
--- a/packages/react-ui/src/index.d.ts
+++ b/packages/react-ui/src/index.d.ts
@@ -1,8 +1,8 @@
import { theme, cartoThemeOptions, CartoTheme } from './theme/carto-theme';
import WrapperWidgetUI from './widgets/WrapperWidgetUI';
import CategoryWidgetUI from './widgets/CategoryWidgetUI';
-import FormulaWidgetUI from './widgets/FormulaWidgetUI';
-import BarWidgetUI from './widgets/BarWidgetUI';
+import FormulaWidgetUI from './widgets/FormulaWidgetUI/FormulaWidgetUI';
+import BarWidgetUI from './widgets/BarWidgetUI/BarWidgetUI';
import HistogramWidgetUI from './widgets/HistogramWidgetUI/HistogramWidgetUI';
import PieWidgetUI from './widgets/PieWidgetUI';
import LegendWidgetUI, { LEGEND_TYPES } from './widgets/legend/LegendWidgetUI';
@@ -35,7 +35,7 @@ import SelectField, { SelectFieldProps } from './components/atoms/SelectField';
import UploadField, {
UploadFieldProps
} from './components/molecules/UploadField/UploadField';
-import AppBar, {AppBarProps} from './components/organisms/AppBar/AppBar';
+import AppBar, { AppBarProps } from './components/organisms/AppBar/AppBar';
import LabelWithIndicator, {
LabelWithIndicatorProps
} from './components/atoms/LabelWithIndicator';
@@ -92,7 +92,6 @@ export {
UploadFieldProps,
AppBar,
AppBarProps,
-
LabelWithIndicator,
LabelWithIndicatorProps,
getCartoColorStylePropsForItem,
diff --git a/packages/react-ui/src/index.js b/packages/react-ui/src/index.js
index 99fd88069..93770d7ff 100644
--- a/packages/react-ui/src/index.js
+++ b/packages/react-ui/src/index.js
@@ -1,8 +1,8 @@
import { theme, cartoThemeOptions } from './theme/carto-theme';
import WrapperWidgetUI from './widgets/WrapperWidgetUI';
import CategoryWidgetUI from './widgets/CategoryWidgetUI';
-import FormulaWidgetUI from './widgets/FormulaWidgetUI';
-import BarWidgetUI from './widgets/BarWidgetUI';
+import FormulaWidgetUI from './widgets/FormulaWidgetUI/FormulaWidgetUI';
+import BarWidgetUI from './widgets/BarWidgetUI/BarWidgetUI';
import HistogramWidgetUI from './widgets/HistogramWidgetUI/HistogramWidgetUI';
import PieWidgetUI from './widgets/PieWidgetUI';
import LegendWidgetUI, { LEGEND_TYPES } from './widgets/legend/LegendWidgetUI';
diff --git a/packages/react-ui/src/theme/sections/components/feedback.js b/packages/react-ui/src/theme/sections/components/feedback.js
index 10665a608..bd04fa653 100644
--- a/packages/react-ui/src/theme/sections/components/feedback.js
+++ b/packages/react-ui/src/theme/sections/components/feedback.js
@@ -1,3 +1,6 @@
+import { getSpacing } from '../../themeUtils';
+import { commonPalette } from '../palette';
+
export const feedbackOverrides = {
// SnackBar
MuiSnackbar: {
@@ -7,5 +10,30 @@ export const feedbackOverrides = {
horizontal: 'center'
}
}
+ },
+
+ // Skeleton
+ MuiSkeleton: {
+ defaultProps: {
+ animation: 'wave',
+ variant: 'rounded'
+ },
+
+ styleOverrides: {
+ root: {
+ backgroundColor: commonPalette.black[8]
+ },
+ rounded: {
+ borderRadius: getSpacing(0.5)
+ },
+ text: {
+ borderRadius: getSpacing(0.5)
+ },
+ wave: {
+ '&::after': {
+ background: `linear-gradient( 90deg, transparent, ${commonPalette.black[4]}, transparent )`
+ }
+ }
+ }
}
};
diff --git a/packages/react-ui/src/types.d.ts b/packages/react-ui/src/types.d.ts
index 3ee799b4f..b0f2e942a 100644
--- a/packages/react-ui/src/types.d.ts
+++ b/packages/react-ui/src/types.d.ts
@@ -38,6 +38,7 @@ export type FormulaWidgetUIData =
export type FormulaWidgetUI = {
data: FormulaWidgetUIData;
formatter?: Function;
+ isLoading?: boolean;
};
export type HistogramWidgetUIData = number[];
@@ -51,6 +52,7 @@ export type HistogramWidgetUI = {
name?: string;
onSelectedBarsChange?: Function;
height?: number;
+ isLoading?: boolean;
};
export type BarWidgetUI = {
@@ -69,6 +71,7 @@ export type BarWidgetUI = {
height?: string | number;
filterable?: boolean;
animation?: boolean;
+ isLoading?: boolean;
};
export type PieWidgetUIData = { name: string; value: number }[];
@@ -223,6 +226,7 @@ export type ComparativeFormulaWidgetUI = {
animated?: boolean;
animationOptions?: AnimationOptions;
formatter?: (n: number) => React.ReactNode;
+ isLoading?: boolean;
};
export enum ORDER_TYPES {
diff --git a/packages/react-ui/src/widgets/BarWidgetUI/BarSkeleton.js b/packages/react-ui/src/widgets/BarWidgetUI/BarSkeleton.js
new file mode 100644
index 000000000..f1c66968c
--- /dev/null
+++ b/packages/react-ui/src/widgets/BarWidgetUI/BarSkeleton.js
@@ -0,0 +1,22 @@
+import { Box, Skeleton } from '@mui/material';
+import { SkeletonBarsGrid, SkeletonBarItem, SKELETON_HEIGHT } from '../SkeletonWidgets';
+
+const BarSkeleton = ({ height }) => {
+ return (
+ <>
+