Step.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { css } from '@emotion/css';
  2. import React, { FC } from 'react';
  3. import { GrafanaTheme } from '@grafana/data';
  4. import { stylesFactory, useTheme } from '@grafana/ui';
  5. import { Card, SetupStep, TutorialCardType } from '../types';
  6. import { DocsCard } from './DocsCard';
  7. import { TutorialCard } from './TutorialCard';
  8. interface Props {
  9. step: SetupStep;
  10. }
  11. export const Step: FC<Props> = ({ step }) => {
  12. const theme = useTheme();
  13. const styles = getStyles(theme);
  14. return (
  15. <div className={styles.setup}>
  16. <div className={styles.info}>
  17. <h2 className={styles.title}>{step.title}</h2>
  18. <p>{step.info}</p>
  19. </div>
  20. <div className={styles.cards}>
  21. {step.cards.map((card: Card | TutorialCardType, index: number) => {
  22. const key = `${card.title}-${index}`;
  23. if (card.type === 'tutorial') {
  24. return <TutorialCard key={key} card={card as TutorialCardType} />;
  25. }
  26. return <DocsCard key={key} card={card} />;
  27. })}
  28. </div>
  29. </div>
  30. );
  31. };
  32. const getStyles = stylesFactory((theme: GrafanaTheme) => {
  33. return {
  34. setup: css`
  35. display: flex;
  36. width: 95%;
  37. `,
  38. info: css`
  39. width: 172px;
  40. margin-right: 5%;
  41. @media only screen and (max-width: ${theme.breakpoints.xxl}) {
  42. margin-right: ${theme.spacing.xl};
  43. }
  44. @media only screen and (max-width: ${theme.breakpoints.sm}) {
  45. display: none;
  46. }
  47. `,
  48. title: css`
  49. color: ${theme.palette.blue95};
  50. `,
  51. cards: css`
  52. overflow-x: scroll;
  53. overflow-y: hidden;
  54. width: 100%;
  55. display: flex;
  56. justify-content: center;
  57. @media only screen and (max-width: ${theme.breakpoints.xxl}) {
  58. justify-content: flex-start;
  59. }
  60. `,
  61. };
  62. });