diff --git a/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.mdx b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.mdx new file mode 100644 index 00000000000..fbd10d9a685 --- /dev/null +++ b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.mdx @@ -0,0 +1,15 @@ +import { Props } from '@storybook/addon-docs/blocks'; +import { LoadingPlaceholder } from './LoadingPlaceholder'; + +# LoadingPlaceholder + +Loading indicator with a text. Used to alert a user to wait for an activity to complete. + +### Usage + +```jsx + +``` + +### Props + diff --git a/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.story.tsx b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.story.tsx new file mode 100644 index 00000000000..ad8215e0aaa --- /dev/null +++ b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.story.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { LoadingPlaceholder } from './LoadingPlaceholder'; +import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; +import mdx from './LoadingPlaceholder.mdx'; + +export default { + title: 'General/LoadingPlaceholder', + component: LoadingPlaceholder, + decorators: [withCenteredStory], + parameters: { + docs: { + page: mdx, + }, + }, +}; + +export const basic = () => { + return ; +}; diff --git a/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx index 4f2db5cd539..52e9146d79d 100644 --- a/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx +++ b/packages/grafana-ui/src/components/LoadingPlaceholder/LoadingPlaceholder.tsx @@ -1,12 +1,32 @@ -import React, { SFC } from 'react'; +import React, { HTMLAttributes, SFC } from 'react'; +import { css, cx } from 'emotion'; +import { GrafanaTheme } from '@grafana/data'; import { Spinner } from '../Spinner/Spinner'; +import { useStyles } from '../../themes'; -interface LoadingPlaceholderProps { +/** + * @public + */ +export interface LoadingPlaceholderProps extends HTMLAttributes { text: string; } -export const LoadingPlaceholder: SFC = ({ text }) => ( -
- {text} -
-); +/** + * @public + */ +export const LoadingPlaceholder: SFC = ({ text, className, ...rest }) => { + const styles = useStyles(getStyles); + return ( +
+ {text} +
+ ); +}; + +const getStyles = (theme: GrafanaTheme) => { + return { + container: css` + margin-bottom: ${theme.spacing.xl}; + `, + }; +}; diff --git a/packages/grafana-ui/src/components/index.ts b/packages/grafana-ui/src/components/index.ts index 0a0def694c8..1edeed625f7 100644 --- a/packages/grafana-ui/src/components/index.ts +++ b/packages/grafana-ui/src/components/index.ts @@ -13,7 +13,7 @@ export { ClipboardButton } from './ClipboardButton/ClipboardButton'; export { Cascader, CascaderOption } from './Cascader/Cascader'; export { ButtonCascader } from './ButtonCascader/ButtonCascader'; -export { LoadingPlaceholder } from './LoadingPlaceholder/LoadingPlaceholder'; +export { LoadingPlaceholder, LoadingPlaceholderProps } from './LoadingPlaceholder/LoadingPlaceholder'; export { ColorPicker, SeriesColorPicker } from './ColorPicker/ColorPicker'; export { SeriesColorPickerPopover, SeriesColorPickerPopoverWithTheme } from './ColorPicker/SeriesColorPickerPopover'; export { PanelOptionsGroup } from './PanelOptionsGroup/PanelOptionsGroup';