oncall-engine/grafana-plugin/src/components/CardButton/CardButton.tsx
Rares Mardare f7beced64e
More emotionjs migration changes (#4362)
# What this PR does

- Get rid of some of the hardcoded css variables defined in `vars.css`,
specifically tags-related, but not only
- Migrated a few more components to emotion
2024-05-27 13:28:56 +00:00

40 lines
1.1 KiB
TypeScript

import React, { FC } from 'react';
import { cx } from '@emotion/css';
import { VerticalGroup, useStyles2 } from '@grafana/ui';
import { Block } from 'components/GBlock/Block';
import { Text } from 'components/Text/Text';
import { getCardButtonStyles } from './CardButton.styles';
interface CardButtonProps {
icon: React.ReactElement;
description: string;
title: string;
selected: boolean;
onClick: (selected: boolean) => void;
}
export const CardButton: FC<CardButtonProps> = (props) => {
const { icon, description, title, selected, onClick } = props;
const styles = useStyles2(getCardButtonStyles);
return (
<Block
onClick={() => onClick(!selected)}
withBackground
className={cx(styles.root, { [styles.rootSelected]: selected })}
data-testid="test__cardButton"
>
<div className={styles.icon}>{icon}</div>
<div className={styles.meta}>
<VerticalGroup spacing="xs">
<Text type="secondary">{description}</Text>
<Text.Title level={1}>{title}</Text.Title>
</VerticalGroup>
</div>
</Block>
);
};