From 07d2c0427de12b393b985135db05bd97723eb581 Mon Sep 17 00:00:00 2001 From: sylenien Date: Tue, 17 May 2022 17:36:11 +0200 Subject: [PATCH] feat(ui): add hovers to metric widgets for dashboard and template comps --- .../DashboardMetricSelection.tsx | 4 +- .../DashboardRouter/DashboardRouter.tsx | 2 +- .../WidgetWrapper/TemplateOverlay.tsx | 10 +++-- .../WidgetWrapper/WidgetWrapper.tsx | 25 ++++++------ .../WidgetWrapper/widgetWrapper.css | 39 +++++++++++++++++++ 5 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 frontend/app/components/Dashboard/components/WidgetWrapper/widgetWrapper.css diff --git a/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx b/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx index 1482250ef..6f4e0e876 100644 --- a/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx +++ b/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx @@ -80,7 +80,7 @@ function DashboardMetricSelection(props) {
-
+
{activeCategory && widgetCategories.map((category, index) =>
{activeCategory && activeCategory.widgets.map((widget: any) => ( diff --git a/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx b/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx index 31e509d52..1add670ec 100644 --- a/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx +++ b/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx @@ -15,7 +15,7 @@ import DashboardView from '../DashboardView'; import MetricsView from '../MetricsView'; import WidgetView from '../WidgetView'; -function DashboardViewSelected({ siteId, dashboardId}) { +function DashboardViewSelected({ siteId, dashboardId }) { return ( ) diff --git a/frontend/app/components/Dashboard/components/WidgetWrapper/TemplateOverlay.tsx b/frontend/app/components/Dashboard/components/WidgetWrapper/TemplateOverlay.tsx index 7a25de14f..f1b6b6c70 100644 --- a/frontend/app/components/Dashboard/components/WidgetWrapper/TemplateOverlay.tsx +++ b/frontend/app/components/Dashboard/components/WidgetWrapper/TemplateOverlay.tsx @@ -1,9 +1,13 @@ -//@ts-nocheck import React from 'react'; +import cn from 'classnames'; +import stl from './widgetWrapper.css'; -function TemplateOverlay() { +interface IProps { + isTemplate?: boolean; +} +function TemplateOverlay(props: IProps) { return ( -
+
); } diff --git a/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx b/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx index b5a60eedb..26c4019d3 100644 --- a/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx +++ b/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx @@ -13,6 +13,7 @@ import TemplateOverlay from './TemplateOverlay'; import WidgetIcon from './WidgetIcon'; import AlertButton from './AlertButton'; import { Tooltip } from 'react-tippy'; +import stl from './widgetWrapper.css'; interface Props { className?: string; @@ -59,13 +60,6 @@ function WidgetWrapper(props: Props) { const onDelete = async () => { dashboardStore.deleteDashboardWidget(dashboard?.dashboardId, widget.widgetId); - // if (await confirm({ - // header: 'Confirm', - // confirmButton: 'Yes, delete', - // confirmation: `Are you sure you want to permanently delete the widget from this dashboard?` - // })) { - // dashboardStore.deleteDashboardWidget(dashboardId!, widget.widgetId); - // } } const onChartClick = () => { @@ -77,13 +71,19 @@ function WidgetWrapper(props: Props) { const ref: any = useRef(null) const dragDropRef: any = dragRef(dropRef(ref)) + const addOverlay = isTemplate || !isPredefined + + console.log(widget, isTemplate, addOverlay) + return useObserver(() => (
{}} id={`widget-${widget.widgetId}`} > +
{isPredefined ? 'Cannot drill down system provided metrics' : 'Click to drill down'}
{/* @ts-ignore */} Click to select} > - {isTemplate && } + {addOverlay && }
diff --git a/frontend/app/components/Dashboard/components/WidgetWrapper/widgetWrapper.css b/frontend/app/components/Dashboard/components/WidgetWrapper/widgetWrapper.css new file mode 100644 index 000000000..7531f60b2 --- /dev/null +++ b/frontend/app/components/Dashboard/components/WidgetWrapper/widgetWrapper.css @@ -0,0 +1,39 @@ +.hoverableWidget { + transition: all 0.2s; +} + +.hoverGray { + &:hover { + box-shadow: 0 0 0 1px #999; + + & .drillDownMessage { + display: unset; + } + } +} + +.hoverBlue { + &:hover { + box-shadow: 0 0 0 1px $main; + } +} + +.drillDownMessage { + display: none; + position: absolute; + top: 35px; + left: 0; + width: 100%; + text-align: center; + font-size: 16px; +} + +.overlay { + top: 0; + bottom: 0; + left: 0; + right: 0; +} +.overlayDashboard { + top: 20%!important; +}