@grafana/ui
Version:
Grafana Components Library
1 lines • 2.92 kB
Source Map (JSON)
{"version":3,"file":"InfoBox.mjs","sources":["../../../../src/components/InfoBox/InfoBox.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport * as React from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\n\nimport { useStyles2 } from '../../themes/ThemeContext';\nimport { Alert, AlertVariant } from '../Alert/Alert';\nimport { Icon } from '../Icon/Icon';\n\nexport interface InfoBoxProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n children: React.ReactNode;\n /** Title of the box */\n title?: string | JSX.Element;\n /** Url of the read more link */\n url?: string;\n /** Text of the read more link */\n urlTitle?: string;\n /** Indicates whether or not box should be rendered with Grafana branding background */\n branded?: boolean;\n /** Color variant of the box */\n severity?: AlertVariant;\n /** Call back to be performed when box is dismissed */\n onDismiss?: () => void;\n}\n\n/** @deprecated use Alert with severity info */\nexport const InfoBox = React.memo(\n React.forwardRef<HTMLDivElement, InfoBoxProps>(\n ({ title, className, children, branded, url, urlTitle, onDismiss, severity = 'info', ...otherProps }, ref) => {\n const styles = useStyles2(getStyles);\n\n return (\n // component is deprecated so no point fixing this\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n <Alert severity={severity} className={className} {...otherProps} ref={ref} title={title as string}>\n <div>{children}</div>\n {url && (\n <a href={url} className={cx('external-link', styles.docsLink)} target=\"_blank\" rel=\"noreferrer\">\n <Icon name=\"book\" /> {urlTitle || 'Read more'}\n </a>\n )}\n </Alert>\n );\n }\n )\n);\n\nInfoBox.displayName = 'InfoBox';\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n docsLink: css({\n display: 'inline-block',\n marginTop: theme.spacing(2),\n }),\n});\n"],"names":[],"mappings":";;;;;;;AA0BO,MAAM,UAAU,KAAM,CAAA,IAAA;AAAA,EAC3B,KAAM,CAAA,UAAA;AAAA,IACJ,CAAC,EAAE,KAAO,EAAA,SAAA,EAAW,UAAU,OAAS,EAAA,GAAA,EAAK,QAAU,EAAA,SAAA,EAAW,QAAW,GAAA,MAAA,EAAQ,GAAG,UAAA,IAAc,GAAQ,KAAA;AAC5G,MAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA;AAEnC,MAAA;AAAA;AAAA;AAAA,6BAGG,KAAM,EAAA,EAAA,QAAA,EAAoB,WAAuB,GAAG,UAAA,EAAY,KAAU,KACzE,EAAA,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,SAAK,QAAS,EAAA,CAAA;AAAA,UACd,GACC,oBAAA,IAAA,CAAC,GAAE,EAAA,EAAA,IAAA,EAAM,KAAK,SAAW,EAAA,EAAA,CAAG,eAAiB,EAAA,MAAA,CAAO,QAAQ,CAAA,EAAG,MAAO,EAAA,QAAA,EAAS,KAAI,YACjF,EAAA,QAAA,EAAA;AAAA,4BAAC,GAAA,CAAA,IAAA,EAAA,EAAK,MAAK,MAAO,EAAA,CAAA;AAAA,YAAE,GAAA;AAAA,YAAE,QAAY,IAAA;AAAA,WACpC,EAAA;AAAA,SAEJ,EAAA;AAAA;AAAA;AAEJ;AAEJ;AAEA,OAAA,CAAQ,WAAc,GAAA,SAAA;AAEtB,MAAM,SAAA,GAAY,CAAC,KAA0B,MAAA;AAAA,EAC3C,UAAU,GAAI,CAAA;AAAA,IACZ,OAAS,EAAA,cAAA;AAAA,IACT,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA,GAC3B;AACH,CAAA,CAAA;;;;"}