diff --git a/packages/grafana-ui/src/themes/GlobalStyles/fonts.ts b/packages/grafana-ui/src/themes/GlobalStyles/fonts.ts index 5281d2ef6de..353baee7a90 100644 --- a/packages/grafana-ui/src/themes/GlobalStyles/fonts.ts +++ b/packages/grafana-ui/src/themes/GlobalStyles/fonts.ts @@ -75,5 +75,24 @@ export function getFontStyles(theme: GrafanaTheme2) { src: `url('${fontRoot}inter/Inter-MediumItalic.woff2') format('woff2')`, }, }, + { + /* CommitMono - monospace font for code */ + '@font-face': { + fontFamily: 'CommitMono', + fontStyle: 'normal', + fontWeight: 400, + fontDisplay: 'swap', + src: `url('${fontRoot}commitmono/CommitMono-Regular.woff2') format('woff2')`, + }, + }, + { + '@font-face': { + fontFamily: 'CommitMono', + fontStyle: 'italic', + fontWeight: 400, + fontDisplay: 'swap', + src: `url('${fontRoot}commitmono/CommitMono-Italic.woff2') format('woff2')`, + }, + }, ]); } diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformCard.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformCard.tsx index d9029e7de75..7c4297f9827 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformCard.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformCard.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import { memo } from 'react'; +import { memo, useMemo } from 'react'; import { DataTransformerConfig, GrafanaTheme2 } from '@grafana/data'; import { t } from '@grafana/i18n'; @@ -31,26 +31,22 @@ export const QueryTransformCard = memo( return ''; }; - const getDatasourceName = (): string => { + const datasourceIcon = useMemo(() => { if (type === 'query' && 'datasource' in item && item.datasource) { try { const dsSettings = getDataSourceSrv().getInstanceSettings(item.datasource); - return dsSettings?.name || 'Unknown datasource'; + return dsSettings?.meta.info.logos.small; } catch { - return 'Unknown datasource'; + return undefined; } - } else if (type === 'expression' && 'type' in item && typeof item.type === 'string') { - // Show expression type (Math, Reduce, etc.) - return item.type.charAt(0).toUpperCase() + item.type.slice(1); } - return ''; - }; + return undefined; + }, [type, item]); const isHidden = (type === 'query' || type === 'expression') && 'hide' in item && item.hide; const icon = type === 'query' ? 'database' : type === 'expression' ? 'calculator-alt' : 'process'; const typeLabel = type === 'query' ? 'Query' : type === 'expression' ? 'Expression' : 'Transformation'; const name = getName(); - const datasourceName = getDatasourceName(); const handleAction = (e: React.MouseEvent, action: () => void) => { e.stopPropagation(); @@ -131,10 +127,14 @@ export const QueryTransformCard = memo( - {/* Content: Name and datasource */} + {/* Content: Name */}
-
{name}
- {datasourceName &&
{datasourceName}
} + + {type === 'query' && datasourceIcon && ( + + )} +
{name}
+
); @@ -145,6 +145,7 @@ QueryTransformCard.displayName = 'QueryTransformCard'; const getStyles = (theme: GrafanaTheme2) => { const actionsClass = 'actions-container'; + const selectedClass = 'card-selected'; return { card: css({ @@ -160,11 +161,16 @@ const getStyles = (theme: GrafanaTheme2) => { '&:hover': { borderColor: theme.colors.border.strong, }, + [`&.${selectedClass}`]: { + borderColor: theme.colors.primary.border, + boxShadow: `0 0 0 1px ${theme.colors.primary.border}`, + }, + [`&.${selectedClass}:hover`]: { + borderColor: theme.colors.primary.border, + boxShadow: `0 0 0 1px ${theme.colors.primary.border}`, + }, }), - cardSelected: css({ - borderColor: theme.colors.primary.border, - boxShadow: `0 0 0 1px ${theme.colors.primary.border}`, - }), + cardSelected: selectedClass, headerQuery: css({ display: 'flex', alignItems: 'center', @@ -205,6 +211,7 @@ const getStyles = (theme: GrafanaTheme2) => { flexShrink: 0, }), typeLabel: css({ + fontFamily: "'CommitMono', monospace", fontSize: theme.typography.bodySmall.fontSize, fontWeight: theme.typography.fontWeightMedium, color: theme.colors.text.secondary, @@ -224,15 +231,16 @@ const getStyles = (theme: GrafanaTheme2) => { content: css({ padding: theme.spacing(1.5), }), + datasourceIcon: css({ + width: '16px', + height: '16px', + flexShrink: 0, + }), name: css({ - fontSize: theme.typography.h5.fontSize, + fontFamily: "'CommitMono', monospace", + fontSize: theme.typography.body.fontSize, fontWeight: theme.typography.fontWeightMedium, color: theme.colors.text.primary, - marginBottom: theme.spacing(0.5), - }), - datasource: css({ - fontSize: theme.typography.bodySmall.fontSize, - color: theme.colors.text.secondary, }), }; }; diff --git a/public/fonts/commitmono/CommitMono-Italic.woff2 b/public/fonts/commitmono/CommitMono-Italic.woff2 new file mode 100644 index 00000000000..30fdd60257e Binary files /dev/null and b/public/fonts/commitmono/CommitMono-Italic.woff2 differ diff --git a/public/fonts/commitmono/CommitMono-Regular.woff2 b/public/fonts/commitmono/CommitMono-Regular.woff2 new file mode 100644 index 00000000000..19e4c78504d Binary files /dev/null and b/public/fonts/commitmono/CommitMono-Regular.woff2 differ