Files
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

78 lines
2.1 KiB
TypeScript

import { css } from '@emotion/css';
import React, { FC, MouseEvent } from 'react';
import { GrafanaTheme } from '@grafana/data';
import { Icon, stylesFactory, useTheme } from '@grafana/ui';
import store from 'app/core/store';
import { TutorialCardType } from '../types';
import { cardContent, cardStyle, iconStyle } from './sharedStyles';
interface Props {
card: TutorialCardType;
}
export const TutorialCard: FC<Props> = ({ card }) => {
const theme = useTheme();
const styles = getStyles(theme, card.done);
return (
<a className={styles.card} onClick={(event: MouseEvent<HTMLAnchorElement>) => handleTutorialClick(event, card)}>
<div className={cardContent}>
<div className={styles.type}>{card.type}</div>
<div className={styles.heading}>{card.done ? 'complete' : card.heading}</div>
<h4 className={styles.cardTitle}>{card.title}</h4>
<div className={styles.info}>{card.info}</div>
<Icon className={iconStyle(theme, card.done)} name={card.icon} size="xxl" />
</div>
</a>
);
};
const handleTutorialClick = (event: MouseEvent<HTMLAnchorElement>, card: TutorialCardType) => {
event.preventDefault();
const isSet = store.get(card.key);
if (!isSet) {
store.set(card.key, true);
}
window.open(`${card.href}?utm_source=grafana_gettingstarted`, '_blank');
};
const getStyles = stylesFactory((theme: GrafanaTheme, complete: boolean) => {
return {
card: css`
${cardStyle(theme, complete)}
width: 460px;
min-width: 460px;
@media only screen and (max-width: ${theme.breakpoints.xl}) {
min-width: 368px;
}
@media only screen and (max-width: ${theme.breakpoints.lg}) {
min-width: 272px;
}
`,
type: css`
color: ${theme.colors.textBlue};
text-transform: uppercase;
`,
heading: css`
text-transform: uppercase;
color: ${theme.colors.textBlue};
margin-bottom: ${theme.spacing.sm};
`,
cardTitle: css`
margin-bottom: ${theme.spacing.md};
`,
info: css`
margin-bottom: ${theme.spacing.md};
`,
status: css`
display: flex;
justify-content: flex-end;
`,
};
});