mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
EmptyState: Add completed
variant (#86497)
* add 'completed' variant * add central text alignment
This commit is contained in:
parent
bc07eedaa9
commit
07044309f1
@ -66,6 +66,16 @@ import { EmptyState } from '@grafana/ui';
|
|||||||
<EmptyState variant="not-found" message="No playlists found" />;
|
<EmptyState variant="not-found" message="No playlists found" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `variant="completed"`
|
||||||
|
|
||||||
|
For when a user has completed all tasks on a page, such as reading all their notifications.
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import { EmptyState } from '@grafana/ui';
|
||||||
|
|
||||||
|
<EmptyState variant="completed" message="You're all caught up" />;
|
||||||
|
```
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
For all variants you can:
|
For all variants you can:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
|
import SVG from 'react-inlinesvg';
|
||||||
|
|
||||||
import { Box } from '../Layout/Box/Box';
|
import { Box } from '../Layout/Box/Box';
|
||||||
import { Stack } from '../Layout/Stack/Stack';
|
import { Stack } from '../Layout/Stack/Stack';
|
||||||
@ -6,6 +7,7 @@ import { Text } from '../Text/Text';
|
|||||||
|
|
||||||
import { GrotCTA } from './GrotCTA/GrotCTA';
|
import { GrotCTA } from './GrotCTA/GrotCTA';
|
||||||
import { GrotNotFound } from './GrotNotFound/GrotNotFound';
|
import { GrotNotFound } from './GrotNotFound/GrotNotFound';
|
||||||
|
import GrotCompleted from './grot-completed.svg';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
@ -24,7 +26,7 @@ interface Props {
|
|||||||
/**
|
/**
|
||||||
* Which variant to use. Affects the default image shown.
|
* Which variant to use. Affects the default image shown.
|
||||||
*/
|
*/
|
||||||
variant: 'call-to-action' | 'not-found';
|
variant: 'call-to-action' | 'not-found' | 'completed';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EmptyState = ({
|
export const EmptyState = ({
|
||||||
@ -41,8 +43,14 @@ export const EmptyState = ({
|
|||||||
<Box paddingY={4} gap={4} display="flex" direction="column" alignItems="center">
|
<Box paddingY={4} gap={4} display="flex" direction="column" alignItems="center">
|
||||||
{!hideImage && imageToShow}
|
{!hideImage && imageToShow}
|
||||||
<Stack direction="column" alignItems="center">
|
<Stack direction="column" alignItems="center">
|
||||||
<Text variant="h4">{message}</Text>
|
<Text variant="h4" textAlignment="center">
|
||||||
{children && <Text color="secondary">{children}</Text>}
|
{message}
|
||||||
|
</Text>
|
||||||
|
{children && (
|
||||||
|
<Text color="secondary" textAlignment="center">
|
||||||
|
{children}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
{button}
|
{button}
|
||||||
</Box>
|
</Box>
|
||||||
@ -57,6 +65,9 @@ function getDefaultImageForVariant(variant: Props['variant']) {
|
|||||||
case 'not-found': {
|
case 'not-found': {
|
||||||
return <GrotNotFound width={300} />;
|
return <GrotNotFound width={300} />;
|
||||||
}
|
}
|
||||||
|
case 'completed': {
|
||||||
|
return <SVG src={GrotCompleted} width={300} />;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error(`Unknown variant: ${variant}`);
|
throw new Error(`Unknown variant: ${variant}`);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 32 KiB |
Loading…
Reference in New Issue
Block a user