diff --git a/packages/grafana-ui/src/components/LoadingBar/LoadingBar.mdx b/packages/grafana-ui/src/components/LoadingBar/LoadingBar.mdx
new file mode 100644
index 00000000000..80cb225ba28
--- /dev/null
+++ b/packages/grafana-ui/src/components/LoadingBar/LoadingBar.mdx
@@ -0,0 +1,8 @@
+import { Meta, Preview, Props } from '@storybook/addon-docs/blocks';
+import { LoadingBar } from './LoadingBar';
+
+
+
+# LoadingBar
+
+The LoadingBar is used as a simple loading slider animation in the top of its container.
diff --git a/packages/grafana-ui/src/components/LoadingBar/LoadingBar.story.tsx b/packages/grafana-ui/src/components/LoadingBar/LoadingBar.story.tsx
index ae86ba742ae..ed6ed416259 100644
--- a/packages/grafana-ui/src/components/LoadingBar/LoadingBar.story.tsx
+++ b/packages/grafana-ui/src/components/LoadingBar/LoadingBar.story.tsx
@@ -1,9 +1,11 @@
-import { action } from '@storybook/addon-actions';
+import { css } from '@emotion/css';
import { ComponentMeta, ComponentStory } from '@storybook/react';
-import React, { CSSProperties, useState, ReactNode } from 'react';
+import React from 'react';
-import { LoadingBar, LoadingBarProps } from '@grafana/ui';
+import { GrafanaTheme2 } from '@grafana/data';
+import { LoadingBar, LoadingBarProps, useStyles2 } from '@grafana/ui';
+import { DashboardStoryCanvas } from '../../utils/storybook/DashboardStoryCanvas';
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
const meta: ComponentMeta = {
@@ -16,23 +18,29 @@ const meta: ComponentMeta = {
},
};
-function getContentStyle(): CSSProperties {
+const getStyles = (theme: GrafanaTheme2) => {
+ const { borderColor } = theme.components.panel;
+
return {
- backgroundColor: '#181B1F',
- width: '400px',
- height: '200px',
- border: '1px solid rgba(204, 204, 220, 0.25)',
- borderRadius: '1px',
+ container: css({
+ label: 'placeholder-container',
+ width: '400px',
+ height: '200px',
+ border: `1px solid ${borderColor}`,
+ borderRadius: '3px',
+ }),
};
-}
+};
export const Basic: ComponentStory = (args: LoadingBarProps) => {
- const contentStyle = getContentStyle();
+ const styles = useStyles2(getStyles);
return (
-
-
-
+
+
+
+
+
);
};
diff --git a/packages/grafana-ui/src/components/LoadingBar/LoadingBar.tsx b/packages/grafana-ui/src/components/LoadingBar/LoadingBar.tsx
index b9791a4cfde..dc7f7a1a0b9 100644
--- a/packages/grafana-ui/src/components/LoadingBar/LoadingBar.tsx
+++ b/packages/grafana-ui/src/components/LoadingBar/LoadingBar.tsx
@@ -1,10 +1,6 @@
import { css, keyframes } from '@emotion/css';
import React from 'react';
-import { GrafanaTheme2 } from '@grafana/data';
-
-import { useTheme2 } from '../../themes';
-
/**
* @internal
*/
@@ -13,19 +9,18 @@ export interface LoadingBarProps {
width?: number;
height?: number;
ariaLabel?: string;
- barColor?: string;
}
/**
* @internal
*/
export const LoadingBar: React.FC = ({ containerWidth, width, height, ariaLabel = 'Loading bar' }) => {
- const loadingStyles = getLoadingStyes(containerWidth, width, height);
+ const loadingStyles = getLoadingStyles(containerWidth, width, height);
+
return ;
};
-const getLoadingStyes = (containerWidth: number, width?: number, height?: number) => {
- const theme = useTheme2();
+const getLoadingStyles = (containerWidth: number, width?: number, height?: number) => {
const loadingWidth = width ?? 128;
const loadingAnimation = keyframes({
'0%': {
@@ -38,8 +33,8 @@ const getLoadingStyes = (containerWidth: number, width?: number, height?: number
return {
loading: css({
width: `${loadingWidth}px`,
- height: `${height ?? 2}ipx`,
- background: `linear-gradient(90deg, rgba(110, 159, 255, 0) 0%, ${theme.palette.blueLight} 80.75%, rgba(110, 159, 255, 0) 100%)`,
+ height: `${height ?? 2}px`,
+ background: 'linear-gradient(90deg, rgba(110, 159, 255, 0) 0%, #6E9FFF 80.75%, rgba(110, 159, 255, 0) 100%)',
position: 'absolute',
animation: `${loadingAnimation} 2s infinite linear`,
willChange: 'transform',