Skip to content

Commit

Permalink
Remove loading-indicator / lottie dependency from `@lg-charts/cor…
Browse files Browse the repository at this point in the history
…e` (#2667)

* Remove Lottie dependency

* Lint

* Changeset
  • Loading branch information
tsck authored Jan 29, 2025
1 parent 19105f5 commit 0652ac9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-spies-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-charts/core': patch
---

Removes spinner animation from `Chart` loading state
1 change: 0 additions & 1 deletion charts/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@leafygreen-ui/icon": "workspace:^",
"@leafygreen-ui/icon-button": "workspace:^",
"@leafygreen-ui/lib": "workspace:^",
"@leafygreen-ui/loading-indicator": "workspace:^",
"@leafygreen-ui/palette": "workspace:^",
"@leafygreen-ui/tokens": "workspace:^",
"@leafygreen-ui/typography": "workspace:^",
Expand Down
3 changes: 2 additions & 1 deletion charts/core/src/Chart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const defaultArgs: Omit<
| 'tooltipValueFormatter'
> = {
data: makeLineData(5),
chartState: 'unset',
horizontalGridLines: true,
verticalGridLines: false,
renderGrid: true,
Expand Down Expand Up @@ -126,7 +127,7 @@ export default {
},
chartState: {
control: 'select',
options: ['default', 'loading'],
options: ['unset', 'loading'],
description: 'The state of the chart',
table: {
category: 'Chart',
Expand Down
12 changes: 10 additions & 2 deletions charts/core/src/Chart/Chart.styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { css } from '@leafygreen-ui/emotion';
import { Theme } from '@leafygreen-ui/lib';
import { color, InteractionState, Variant } from '@leafygreen-ui/tokens';

export const chartContainerStyles = css`
display: grid;
Expand Down Expand Up @@ -28,8 +30,10 @@ export const chartStyles = css`
z-index: 0;
`;

export const loadingOverlayStyles = css`
background: white;
export const getLoadingOverlayStyles = (theme: Theme) => css`
background: ${color[theme].background[Variant.Primary][
InteractionState.Default
]};
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -38,3 +42,7 @@ export const loadingOverlayStyles = css`
width: 100%;
z-index: 1;
`;

export const getLoadingTextStyles = (theme: Theme) => css`
color: ${color[theme].text[Variant.Secondary][InteractionState.Default]};
`;
15 changes: 11 additions & 4 deletions charts/core/src/Chart/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { cx } from '@leafygreen-ui/emotion';
import LeafyGreenProvider, {
useDarkMode,
} from '@leafygreen-ui/leafygreen-provider';
import { Spinner } from '@leafygreen-ui/loading-indicator';
import { BaseFontSize } from '@leafygreen-ui/tokens';
import { Body } from '@leafygreen-ui/typography';

import { ChartProvider } from '../ChartContext';

Expand All @@ -20,7 +21,8 @@ import {
chartHeaderContainerStyles,
chartStyles,
chartWrapperStyles,
loadingOverlayStyles,
getLoadingOverlayStyles,
getLoadingTextStyles,
} from './Chart.styles';
import { ChartProps, ChartStates } from './Chart.types';
import { useChart } from './hooks';
Expand Down Expand Up @@ -60,8 +62,13 @@ export function Chart({
</div>
<div className={chartWrapperStyles}>
{chartState === ChartStates.Loading && (
<div className={loadingOverlayStyles}>
<Spinner description="Loading chart..." />
<div className={getLoadingOverlayStyles(theme)}>
<Body
className={getLoadingTextStyles(theme)}
baseFontSize={BaseFontSize.Body2}
>
Loading chart...
</Body>
</div>
)}
<div
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0652ac9

Please sign in to comment.