diff --git a/packages/grafana-ui/src/components/Card/Card.tsx b/packages/grafana-ui/src/components/Card/Card.tsx index e28e8c35069..cdcee58d462 100644 --- a/packages/grafana-ui/src/components/Card/Card.tsx +++ b/packages/grafana-ui/src/components/Card/Card.tsx @@ -224,6 +224,9 @@ export const getCardStyles = stylesFactory((theme: GrafanaTheme) => { media: css` margin-right: ${theme.spacing.md}; width: 40px; + display: flex; + align-items: center; + & > * { width: 100%; } diff --git a/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx b/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx index 9216c2e3c76..3643a792f0a 100644 --- a/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx +++ b/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx @@ -4,7 +4,7 @@ import { css, cx, keyframes } from 'emotion'; import _ from 'lodash'; import tinycolor from 'tinycolor2'; import { LocationUpdate } from '@grafana/runtime'; -import { Icon, IconButton, styleMixins, stylesFactory, useStyles, useTheme } from '@grafana/ui'; +import { Icon, IconButton, styleMixins, useStyles } from '@grafana/ui'; import { selectors } from '@grafana/e2e-selectors'; import { DateTimeInput, GrafanaTheme } from '@grafana/data'; @@ -142,7 +142,7 @@ export const AddPanelWidgetUnconnected: React.FC = ({ panel, dashboard, u return (
- + {addPanelView ? 'Add panel from panel library' : 'Add panel'} {addPanelView ? ( @@ -194,26 +194,30 @@ interface AddPanelWidgetHandleProps { onCancel: (e: React.MouseEvent) => void; onBack?: () => void; children?: string; + styles: AddPanelStyles; } -const AddPanelWidgetHandle: React.FC = ({ children, onBack, onCancel }) => { - const theme = useTheme(); - const styles = getAddPanelWigetHandleStyles(theme); +const AddPanelWidgetHandle: React.FC = ({ children, onBack, onCancel, styles }) => { return ( -
-
- {onBack && ( - - )} -
- +
+ {onBack && ( +
+ +
+ )} + {!onBack && ( +
+ +
+ )} {children && {children}} - +
+
); }; -const getStyles = stylesFactory((theme: GrafanaTheme) => { +const getStyles = (theme: GrafanaTheme) => { const pulsate = keyframes` 0% {box-shadow: 0 0 0 2px ${theme.colors.bodyBg}, 0 0 0px 4px ${theme.colors.formFocusOutline};} 50% {box-shadow: 0 0 0 2px ${theme.colors.bodyBg}, 0 0 0px 4px ${tinycolor(theme.colors.formFocusOutline) @@ -221,6 +225,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { .toHexString()};} 100% {box-shadow: 0 0 0 2px ${theme.colors.bodyBg}, 0 0 0px 4px ${theme.colors.formFocusOutline};} `; + return { wrapper: css` overflow: hidden; @@ -261,43 +266,28 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { display: flex; flex-direction: column; row-gap: ${theme.spacing.sm}; + padding: 0 ${theme.spacing.sm} ${theme.spacing.sm} ${theme.spacing.sm}; height: 100%; - margin-left: ${theme.spacing.xl}; - margin-right: ${theme.spacing.xl}; - margin-top: ${theme.spacing.base * 4}px; - margin-bottom: ${theme.spacing.base * 5}px; - `, - buttonMargin: css` - margin-right: ${theme.spacing.sm}; `, libraryPanelsWrapper: css` - padding: ${theme.spacing.base * 4}px ${theme.spacing.xl}; + padding: ${theme.spacing.sm}; `, - }; -}); - -const getAddPanelWigetHandleStyles = stylesFactory((theme: GrafanaTheme) => { - return { - handle: css` - position: absolute; + headerRow: css` display: flex; align-items: center; - height: ${theme.spacing.gutter}; + height: 38px; + flex-shrink: 0; width: 100%; font-size: ${theme.typography.size.md}; font-weight: ${theme.typography.weight.semibold}; + padding-left: ${theme.spacing.sm}; transition: background-color 0.1s ease-in-out; cursor: move; + &:hover { background: ${theme.colors.bg2}; } `, - pushRight: css` - margin-left: auto; - `, - leftPad: css` - padding-left: ${theme.spacing.xl}; - `, backButton: css` display: flex; align-items: center; @@ -309,4 +299,6 @@ const getAddPanelWigetHandleStyles = stylesFactory((theme: GrafanaTheme) => { margin: 0; `, }; -}); +}; + +type AddPanelStyles = ReturnType; diff --git a/public/app/features/dashboard/components/AddPanelWidget/__snapshots__/AddPanelWidget.test.tsx.snap b/public/app/features/dashboard/components/AddPanelWidget/__snapshots__/AddPanelWidget.test.tsx.snap index f9a203cf21a..96bf6c325c2 100644 --- a/public/app/features/dashboard/components/AddPanelWidget/__snapshots__/AddPanelWidget.test.tsx.snap +++ b/public/app/features/dashboard/components/AddPanelWidget/__snapshots__/AddPanelWidget.test.tsx.snap @@ -6,11 +6,22 @@ exports[`Render should render component 1`] = ` > Add panel
= ({ isOpen = false, panel, i return ( - + setPanelTitle(e.currentTarget.value)} /> - + setFolderId(id)} initialFolderId={initialFolderId} /> diff --git a/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx b/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx index a3cfd0333ce..f38728c770f 100644 --- a/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx +++ b/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Icon, IconButton, stylesFactory, ConfirmModal, Tooltip, useStyles, Card } from '@grafana/ui'; +import { Icon, IconButton, ConfirmModal, Tooltip, useStyles, Card } from '@grafana/ui'; import { css } from 'emotion'; import { GrafanaTheme } from '@grafana/data'; import { LibraryPanelDTO } from '../../state/api'; @@ -32,7 +32,7 @@ export const LibraryPanelCard: React.FC onClick(libraryPanel) : undefined}> - + Reusable panel @@ -42,17 +42,6 @@ export const LibraryPanelCard: React.FC - - {/* - Commenting this out as obtaining the number of variables used by a panel - isn't implemetned yet. - -
- - {varCount} -
-
*/} - Last edited {formatDate?.(libraryPanel.meta.updated ?? '') ?? libraryPanel.meta.updated} by{' '} {libraryPanel.meta.updatedBy.name} @@ -94,7 +83,7 @@ export const LibraryPanelCard: React.FC { +const getStyles = (theme: GrafanaTheme) => { return { tooltip: css` display: inline; @@ -103,10 +92,10 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { margin-right: 0.5ch; `, panelIcon: css` - margin-right: ${theme.spacing.md}; + color: ${theme.colors.textWeak}; `, tagList: css` align-self: center; `, }; -}); +}; diff --git a/public/app/features/library-panels/components/LibraryPanelsView/LibraryPanelsView.tsx b/public/app/features/library-panels/components/LibraryPanelsView/LibraryPanelsView.tsx index 5a344fa03c8..70c044ff31c 100644 --- a/public/app/features/library-panels/components/LibraryPanelsView/LibraryPanelsView.tsx +++ b/public/app/features/library-panels/components/LibraryPanelsView/LibraryPanelsView.tsx @@ -62,12 +62,12 @@ export const LibraryPanelsView: React.FC = ({ return (
- Popular panels from the panel library
} value={searchString} + autoFocus onChange={(e) => setSearchString(e.currentTarget.value)} > {/*