grafana/public/app/features/alerting/unified/components/EmptyAreaWithCTA.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

75 lines
1.7 KiB
TypeScript

import { css } from '@emotion/css';
import React, { ButtonHTMLAttributes, FC } from 'react';
import { GrafanaTheme } from '@grafana/data';
import { Button, ButtonVariant, IconName, LinkButton, useStyles } from '@grafana/ui';
import { EmptyArea } from './EmptyArea';
export interface EmptyAreaWithCTAProps {
buttonLabel: string;
href?: string;
onButtonClick?: ButtonHTMLAttributes<HTMLButtonElement>['onClick'];
text: string;
buttonIcon?: IconName;
buttonSize?: 'xs' | 'sm' | 'md' | 'lg';
buttonVariant?: ButtonVariant;
showButton?: boolean;
}
export const EmptyAreaWithCTA: FC<EmptyAreaWithCTAProps> = ({
buttonIcon,
buttonLabel,
buttonSize = 'lg',
buttonVariant = 'primary',
onButtonClick,
text,
href,
showButton = true,
}) => {
const styles = useStyles(getStyles);
const commonProps = {
className: styles.button,
icon: buttonIcon,
size: buttonSize,
variant: buttonVariant,
};
return (
<EmptyArea>
<>
<p className={styles.text}>{text}</p>
{showButton &&
(href ? (
<LinkButton href={href} type="button" {...commonProps}>
{buttonLabel}
</LinkButton>
) : (
<Button onClick={onButtonClick} type="button" {...commonProps}>
{buttonLabel}
</Button>
))}
</>
</EmptyArea>
);
};
const getStyles = (theme: GrafanaTheme) => {
return {
container: css`
background-color: ${theme.colors.bg2};
color: ${theme.colors.textSemiWeak};
padding: ${theme.spacing.xl};
text-align: center;
`,
text: css`
margin-bottom: ${theme.spacing.md};
`,
button: css`
margin: ${theme.spacing.md} 0 ${theme.spacing.sm};
`,
};
};