From 90e1f245108668c7d658ee8afb547867cb1ea3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 28 Apr 2025 17:20:12 +0200 Subject: [PATCH] Dashboard: Style change to hover and selected nodes in outline (#104462) * Dashboard: Style change to hover and selected nodes in outline * Update * Update --- .../edit-pane/DashboardOutline.tsx | 91 ++++++++++++------- .../scene/layout-rows/RowItemEditor.tsx | 4 +- 2 files changed, 61 insertions(+), 34 deletions(-) diff --git a/public/app/features/dashboard-scene/edit-pane/DashboardOutline.tsx b/public/app/features/dashboard-scene/edit-pane/DashboardOutline.tsx index e231c286720..58076081f00 100644 --- a/public/app/features/dashboard-scene/edit-pane/DashboardOutline.tsx +++ b/public/app/features/dashboard-scene/edit-pane/DashboardOutline.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { SceneObject } from '@grafana/scenes'; -import { Box, Icon, Stack, Text, useElementSelection, useStyles2 } from '@grafana/ui'; +import { Box, Icon, Text, useElementSelection, useStyles2, useTheme2 } from '@grafana/ui'; import { t, Trans } from 'app/core/internationalization'; import { DashboardGridItem } from '../scene/layout-default/DashboardGridItem'; @@ -24,7 +24,7 @@ export function DashboardOutline({ editPane }: Props) { const dashboard = getDashboardSceneFor(editPane); return ( - + ); @@ -40,6 +40,7 @@ function DashboardOutlineNode({ depth: number; }) { const [isCollapsed, setIsCollapsed] = useState(depth > 0); + const theme = useTheme2(); const { key } = sceneObject.useState(); const styles = useStyles2(getStyles); const { isSelected, onSelect } = useElementSelection(key); @@ -53,7 +54,7 @@ function DashboardOutlineNode({ const elementCollapsed = editableElement.getCollapsedState?.(); const outlineRename = useOutlineRename(editableElement); - const onNameClicked = (evt: React.PointerEvent) => { + const onNodeClicked = (evt: React.PointerEvent) => { // Only select via clicking outline never deselect if (!isSelected) { onSelect?.(evt); @@ -62,7 +63,8 @@ function DashboardOutlineNode({ editableElement.scrollIntoView?.(); }; - const onToggleCollapse = () => { + const onToggleCollapse = (evt: React.MouseEvent) => { + evt.stopPropagation(); setIsCollapsed(!isCollapsed); // Sync expanded state with canvas element @@ -80,16 +82,19 @@ function DashboardOutlineNode({ return ( <> - +
{elementInfo.isContainer && ( - )} - +
{elementInfo.isContainer && !isCollapsed && ( -
+
+
{children.length > 0 ? ( children.map((child) => ( span': { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', }, }), - nodeButtonSelected: css({ - color: theme.colors.text.primary, - outline: `1px dashed ${theme.colors.primary.border} !important`, - outlineOffset: '0px', - '&:hover': { - outline: `1px dashed ${theme.colors.primary.border}`, - }, - }), hiddenIcon: css({ color: theme.colors.text.secondary, marginLeft: theme.spacing(1), }), - nodeButtonClone: css({ + nodeNameClone: css({ color: theme.colors.text.secondary, cursor: 'not-allowed', }), outlineInput: css({ - border: `1px solid ${theme.colors.primary.border}`, + border: `1px solid ${theme.components.input.borderColor}`, height: theme.spacing(3), + borderRadius: theme.shape.radius.default, '&:focus': { outline: 'none', boxShadow: 'none', }, }), + nodeChildren: css({ + display: 'flex', + flexDirection: 'column', + position: 'relative', + }), + nodeChildrenLine: css({ + position: 'absolute', + width: '1px', + height: '100%', + left: '7px', + zIndex: 1, + backgroundColor: theme.colors.border.weak, + }), }; } diff --git a/public/app/features/dashboard-scene/scene/layout-rows/RowItemEditor.tsx b/public/app/features/dashboard-scene/scene/layout-rows/RowItemEditor.tsx index 9f7c0426682..f67256a31c8 100644 --- a/public/app/features/dashboard-scene/scene/layout-rows/RowItemEditor.tsx +++ b/public/app/features/dashboard-scene/scene/layout-rows/RowItemEditor.tsx @@ -24,7 +24,8 @@ export function useEditOptions(model: RowItem, isNewElement: boolean): OptionsPa new OptionsPaneCategoryDescriptor({ title: '', id: 'row-options' }) .addItem( new OptionsPaneItemDescriptor({ - title: t('dashboard.rows-layout.row-options.row.title', 'Title'), + title: '', + skipField: true, render: () => , }) ) @@ -85,6 +86,7 @@ function RowTitleInput({ row, isNewElement }: { row: RowItem; isNewElement: bool return (