2022-04-22 21:33:13 +08:00
|
|
|
import { css } from '@emotion/css';
|
|
|
|
|
2022-10-26 20:28:12 +08:00
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
2025-05-30 01:13:25 +08:00
|
|
|
import { Trans, useTranslate } from '@grafana/i18n';
|
2024-01-19 17:50:56 +08:00
|
|
|
import { reportInteraction } from '@grafana/runtime';
|
2022-10-26 20:28:12 +08:00
|
|
|
import { Icon, useStyles2 } from '@grafana/ui';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
|
|
|
import { Card } from '../types';
|
|
|
|
|
2024-01-19 17:50:56 +08:00
|
|
|
import { cardContent, cardStyle } from './sharedStyles';
|
2020-05-13 14:00:40 +08:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
card: Card;
|
|
|
|
}
|
|
|
|
|
2022-10-26 20:28:12 +08:00
|
|
|
export const DocsCard = ({ card }: Props) => {
|
2025-05-30 01:13:25 +08:00
|
|
|
const { t } = useTranslate();
|
2023-10-09 17:49:08 +08:00
|
|
|
const styles = useStyles2(getStyles, card.done);
|
2020-05-13 14:00:40 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.card}>
|
|
|
|
<div className={cardContent}>
|
2024-01-19 17:50:56 +08:00
|
|
|
<a
|
|
|
|
href={`${card.href}?utm_source=grafana_gettingstarted`}
|
|
|
|
className={styles.url}
|
|
|
|
onClick={() => reportInteraction('grafana_getting_started_docs', { title: card.title, link: card.href })}
|
|
|
|
>
|
2025-05-30 01:13:25 +08:00
|
|
|
<div className={styles.heading}>
|
|
|
|
{card.done ? t('gettingstarted.docs-card.complete', 'complete') : card.heading}
|
|
|
|
</div>
|
2020-05-13 14:00:40 +08:00
|
|
|
<h4 className={styles.title}>{card.title}</h4>
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-11-18 22:36:35 +08:00
|
|
|
<a
|
|
|
|
href={`${card.learnHref}?utm_source=grafana_gettingstarted`}
|
2021-08-12 17:13:03 +08:00
|
|
|
className={styles.learnUrl}
|
2020-11-18 22:36:35 +08:00
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
2024-01-19 17:50:56 +08:00
|
|
|
onClick={() => reportInteraction('grafana_getting_started_docs', { title: card.title, link: card.learnHref })}
|
2020-11-18 22:36:35 +08:00
|
|
|
>
|
2025-05-30 01:13:25 +08:00
|
|
|
<Trans i18nKey="gettingstarted.docs-card.learn-how">Learn how in the docs</Trans>{' '}
|
|
|
|
<Icon name="external-link-alt" />
|
2020-05-13 14:00:40 +08:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-10-26 20:28:12 +08:00
|
|
|
const getStyles = (theme: GrafanaTheme2, complete: boolean) => {
|
2020-05-13 14:00:40 +08:00
|
|
|
return {
|
2024-10-25 21:50:28 +08:00
|
|
|
card: css({
|
|
|
|
...cardStyle(theme, complete),
|
2020-05-13 14:00:40 +08:00
|
|
|
|
2024-10-25 21:50:28 +08:00
|
|
|
minWidth: '230px',
|
2020-05-13 14:00:40 +08:00
|
|
|
|
2024-10-25 21:50:28 +08:00
|
|
|
[theme.breakpoints.down('md')]: {
|
|
|
|
minWidth: '192px',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
heading: css({
|
|
|
|
textTransform: 'uppercase',
|
|
|
|
color: complete ? theme.v1.palette.blue95 : '#FFB357',
|
|
|
|
marginBottom: theme.spacing(2),
|
|
|
|
}),
|
|
|
|
title: css({
|
|
|
|
marginBottom: theme.spacing(2),
|
|
|
|
}),
|
|
|
|
url: css({
|
|
|
|
display: 'inline-block',
|
|
|
|
}),
|
|
|
|
learnUrl: css({
|
|
|
|
borderTop: `1px solid ${theme.colors.border.weak}`,
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 0,
|
|
|
|
padding: theme.spacing(1, 2),
|
|
|
|
width: '100%',
|
|
|
|
}),
|
2020-05-13 14:00:40 +08:00
|
|
|
};
|
2022-10-26 20:28:12 +08:00
|
|
|
};
|