From e8f7e2e9bef3ff6762710247e42a5c2f09465100 Mon Sep 17 00:00:00 2001 From: sylenien Date: Wed, 18 May 2022 13:04:56 +0200 Subject: [PATCH] feat(ui): make edit metric title hoverable and clickable, create plain text button for future usage --- .../components/WidgetName/WidgetName.tsx | 11 ++++++----- .../components/WidgetName/widgetName.css | 4 ++++ .../components/WidgetView/WidgetView.tsx | 9 ++++++++- .../components/WidgetView/widgetView.css | 14 ++++++++++++++ frontend/app/components/ui/Button/Button.js | 2 ++ frontend/app/components/ui/Button/button.css | 18 +++++++++++++++++- 6 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 frontend/app/components/Dashboard/components/WidgetName/widgetName.css create mode 100644 frontend/app/components/Dashboard/components/WidgetView/widgetView.css diff --git a/frontend/app/components/Dashboard/components/WidgetName/WidgetName.tsx b/frontend/app/components/Dashboard/components/WidgetName/WidgetName.tsx index 09e3b66b3..57fdcbadd 100644 --- a/frontend/app/components/Dashboard/components/WidgetName/WidgetName.tsx +++ b/frontend/app/components/Dashboard/components/WidgetName/WidgetName.tsx @@ -1,5 +1,7 @@ import React, { useState, useRef, useEffect } from 'react'; +import cn from 'classnames'; import { Icon } from 'UI'; +import stl from './widgetName.css' interface Props { name: string; @@ -31,17 +33,17 @@ function WidgetName(props: Props) { useEffect(() => { setName(props.name) }, [props.name]) - + // const { name } = props; + return (
{ editing ? ( setEditing(true)} @@ -49,10 +51,9 @@ function WidgetName(props: Props) { ) : (
{ name }
)} - { canEdit &&
setEditing(true)}>
}
); } -export default WidgetName; \ No newline at end of file +export default WidgetName; diff --git a/frontend/app/components/Dashboard/components/WidgetName/widgetName.css b/frontend/app/components/Dashboard/components/WidgetName/widgetName.css new file mode 100644 index 000000000..f52459368 --- /dev/null +++ b/frontend/app/components/Dashboard/components/WidgetName/widgetName.css @@ -0,0 +1,4 @@ +.input { + padding: 5px 9px; + height: 32px!important; +} diff --git a/frontend/app/components/Dashboard/components/WidgetView/WidgetView.tsx b/frontend/app/components/Dashboard/components/WidgetView/WidgetView.tsx index 7cb96634b..9f346a315 100644 --- a/frontend/app/components/Dashboard/components/WidgetView/WidgetView.tsx +++ b/frontend/app/components/Dashboard/components/WidgetView/WidgetView.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import { useStore } from 'App/mstore'; +import cn from 'classnames' import { Icon, BackLink, Loader } from 'UI'; import WidgetForm from '../WidgetForm'; import WidgetPreview from '../WidgetPreview'; @@ -7,6 +8,7 @@ import WidgetSessions from '../WidgetSessions'; import { useObserver } from 'mobx-react-lite'; import { withSiteId } from 'App/routes'; import WidgetName from '../WidgetName'; +import stl from './widgetView.css'; interface Props { history: any; @@ -36,12 +38,17 @@ function WidgetView(props: Props) { } } + const openEdit = () => { + if (expanded) return; + setExpanded(true) + } + return useObserver(() => (
-
+

(