import { css } from '@emotion/css'; import React, { Dispatch, SetStateAction } from 'react'; import SVG from 'react-inlinesvg'; import { GrafanaTheme2 } from '@grafana/data'; import { Field, Input, Label, useStyles2 } from '@grafana/ui'; import { getPublicOrAbsoluteUrl } from '../resource'; import { MediaType } from '../types'; interface Props { newValue: string; setNewValue: Dispatch>; mediaType: MediaType; } export const URLPickerTab = (props: Props) => { const { newValue, setNewValue, mediaType } = props; const styles = useStyles2(getStyles); const imgSrc = getPublicOrAbsoluteUrl(newValue!); let shortName = newValue?.substring(newValue.lastIndexOf('/') + 1, newValue.lastIndexOf('.')); if (shortName.length > 20) { shortName = shortName.substring(0, 20) + '...'; } return ( <> setNewValue(e.currentTarget.value)} value={newValue} />
{mediaType === MediaType.Icon && } {mediaType === MediaType.Image && newValue && }
); }; const getStyles = (theme: GrafanaTheme2) => ({ iconContainer: css` display: flex; flex-direction: column; width: 80%; align-items: center; align-self: center; `, iconPreview: css` width: 238px; height: 198px; border: 1px solid ${theme.colors.border.medium}; display: flex; align-items: center; justify-content: center; `, img: css` width: 147px; height: 147px; fill: ${theme.colors.text.primary}; `, });