EmptyState: Add completed variant (#86497)

* add 'completed' variant

* add central text alignment
This commit is contained in:
Ashley Harrison 2024-04-18 11:22:28 +01:00 committed by GitHub
parent bc07eedaa9
commit 07044309f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 115 additions and 3 deletions

View File

@ -66,6 +66,16 @@ import { EmptyState } from '@grafana/ui';
<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
For all variants you can:

View File

@ -1,4 +1,5 @@
import React, { ReactNode } from 'react';
import SVG from 'react-inlinesvg';
import { Box } from '../Layout/Box/Box';
import { Stack } from '../Layout/Stack/Stack';
@ -6,6 +7,7 @@ import { Text } from '../Text/Text';
import { GrotCTA } from './GrotCTA/GrotCTA';
import { GrotNotFound } from './GrotNotFound/GrotNotFound';
import GrotCompleted from './grot-completed.svg';
interface Props {
/**
@ -24,7 +26,7 @@ interface Props {
/**
* 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 = ({
@ -41,8 +43,14 @@ export const EmptyState = ({
<Box paddingY={4} gap={4} display="flex" direction="column" alignItems="center">
{!hideImage && imageToShow}
<Stack direction="column" alignItems="center">
<Text variant="h4">{message}</Text>
{children && <Text color="secondary">{children}</Text>}
<Text variant="h4" textAlignment="center">
{message}
</Text>
{children && (
<Text color="secondary" textAlignment="center">
{children}
</Text>
)}
</Stack>
{button}
</Box>
@ -57,6 +65,9 @@ function getDefaultImageForVariant(variant: Props['variant']) {
case 'not-found': {
return <GrotNotFound width={300} />;
}
case 'completed': {
return <SVG src={GrotCompleted} width={300} />;
}
default: {
throw new Error(`Unknown variant: ${variant}`);
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 32 KiB