Grafana-UI: LoadingPlaceholder docs (#28874)

* Refactor props

* Add docs
This commit is contained in:
Alex Khomenko 2020-11-09 09:25:07 +02:00 committed by GitHub
parent 3697b628a7
commit 1d7fda4db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 8 deletions

View File

@ -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
<LoadingPlaceholder text='Loading...'/>
```
### Props
<Props of={LoadingPlaceholder} />

View File

@ -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 <LoadingPlaceholder text="Loading..." />;
};

View File

@ -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<HTMLDivElement> {
text: string;
}
export const LoadingPlaceholder: SFC<LoadingPlaceholderProps> = ({ text }) => (
<div className="gf-form-group">
{text} <Spinner inline={true} />
</div>
);
/**
* @public
*/
export const LoadingPlaceholder: SFC<LoadingPlaceholderProps> = ({ text, className, ...rest }) => {
const styles = useStyles(getStyles);
return (
<div className={cx(styles.container, className)} {...rest}>
{text} <Spinner inline={true} />
</div>
);
};
const getStyles = (theme: GrafanaTheme) => {
return {
container: css`
margin-bottom: ${theme.spacing.xl};
`,
};
};

View File

@ -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';