From f38d2612ae6da395af8ae6e22bdb6949bbfd567b Mon Sep 17 00:00:00 2001 From: Anton Ulyanov Date: Tue, 26 Mar 2024 18:54:17 +0300 Subject: [PATCH] StatsHouse UI: add show dash name and description, update tooltip --- .../src/components/Dashboard/Dashboard.tsx | 2 + .../Dashboard/DashboardGroupTooltipTitle.tsx | 9 ++++- .../components/Dashboard/DashboardHeader.tsx | 2 +- .../components/Dashboard/DashboardName.tsx | 37 +++++++++++++++++++ .../Dashboard/DashboardNameTitle.tsx | 23 ++++++++++++ .../Plot/PlotHeaderTooltipContent.tsx | 7 +++- .../src/components/Plot/PlotLayout.tsx | 2 +- .../src/components/UI/TooltipTitleContent.tsx | 9 ++++- statshouse-ui/src/store/tvMode/tvModeStore.ts | 2 +- statshouse-ui/src/view/ViewPage.tsx | 2 +- 10 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 statshouse-ui/src/components/Dashboard/DashboardName.tsx create mode 100644 statshouse-ui/src/components/Dashboard/DashboardNameTitle.tsx diff --git a/statshouse-ui/src/components/Dashboard/Dashboard.tsx b/statshouse-ui/src/components/Dashboard/Dashboard.tsx index 1470652de..c46e1f7a2 100644 --- a/statshouse-ui/src/components/Dashboard/Dashboard.tsx +++ b/statshouse-ui/src/components/Dashboard/Dashboard.tsx @@ -26,6 +26,7 @@ import { PlotLink } from '../Plot/PlotLink'; import { ErrorMessages } from '../ErrorMessages'; import { DashboardVariablesControl } from './DashboardVariablesControl'; import { Button, Tooltip } from '../UI'; +import { DashboardName } from './DashboardName'; export type DashboardProps = { yAxisSize?: number; @@ -53,6 +54,7 @@ export const Dashboard: React.FC = ({ embed = false, yAxisSize = return (
+ {!!params.dashboard?.name && !embed && !tvMode && } {params.plots.length > 0 && !embed && !tvMode && } {dashboardLayoutEdit && ( diff --git a/statshouse-ui/src/components/Dashboard/DashboardGroupTooltipTitle.tsx b/statshouse-ui/src/components/Dashboard/DashboardGroupTooltipTitle.tsx index cc59377d2..4fa043c48 100644 --- a/statshouse-ui/src/components/Dashboard/DashboardGroupTooltipTitle.tsx +++ b/statshouse-ui/src/components/Dashboard/DashboardGroupTooltipTitle.tsx @@ -9,11 +9,16 @@ export function DashboardGroupTooltipTitle({ name, description }: DashboardGroup } return (
-
+
{name} {!!description && ':'}
- {!!description &&
{description}
} + {!!description &&
{description}
} + {!!description && ( +
+ {description} +
+ )}
); } diff --git a/statshouse-ui/src/components/Dashboard/DashboardHeader.tsx b/statshouse-ui/src/components/Dashboard/DashboardHeader.tsx index a7e2fc6dd..f2c832223 100644 --- a/statshouse-ui/src/components/Dashboard/DashboardHeader.tsx +++ b/statshouse-ui/src/components/Dashboard/DashboardHeader.tsx @@ -65,7 +65,7 @@ export const DashboardHeader: React.FC = () => { }, [params]); return ( -
+
s.scrollY > 16); + + if (!params.dashboard?.name) { + return null; + } + return ( +
+ } + hover + horizontal="left" + > +
+ {params.dashboard.name} + {!!params.dashboard.description && ':'} +
+ {!!params.dashboard.description && ( +
+ {params.dashboard.description} +
+ )} +
+
+ ); +} diff --git a/statshouse-ui/src/components/Dashboard/DashboardNameTitle.tsx b/statshouse-ui/src/components/Dashboard/DashboardNameTitle.tsx new file mode 100644 index 000000000..4585a0730 --- /dev/null +++ b/statshouse-ui/src/components/Dashboard/DashboardNameTitle.tsx @@ -0,0 +1,23 @@ +import React from 'react'; + +export type DashboardNameTitleProps = { + name: string; + description?: string; +}; + +export function DashboardNameTitle({ name, description }: DashboardNameTitleProps) { + return ( +
+
+ {name} + {!!description && ':'} +
+ {!!description &&
{description}
} + {!!description && ( +
+ {description} +
+ )} +
+ ); +} diff --git a/statshouse-ui/src/components/Plot/PlotHeaderTooltipContent.tsx b/statshouse-ui/src/components/Plot/PlotHeaderTooltipContent.tsx index 530ac9d6c..711220ee0 100644 --- a/statshouse-ui/src/components/Plot/PlotHeaderTooltipContent.tsx +++ b/statshouse-ui/src/components/Plot/PlotHeaderTooltipContent.tsx @@ -6,7 +6,12 @@ export function PlotHeaderTooltipContent({ name, description }: PlotHeaderToolti return (
{name}
- {!!description &&
{description}
} + {!!description &&
{description}
} + {!!description && ( +
+ {description} +
+ )}
); } diff --git a/statshouse-ui/src/components/Plot/PlotLayout.tsx b/statshouse-ui/src/components/Plot/PlotLayout.tsx index 72f68ada1..dec9f4973 100644 --- a/statshouse-ui/src/components/Plot/PlotLayout.tsx +++ b/statshouse-ui/src/components/Plot/PlotLayout.tsx @@ -52,7 +52,7 @@ export const PlotLayout: React.FC = ({ return
{children}
; } return ( -
+
{children}
diff --git a/statshouse-ui/src/components/UI/TooltipTitleContent.tsx b/statshouse-ui/src/components/UI/TooltipTitleContent.tsx index f4419573e..45b9e5eb0 100644 --- a/statshouse-ui/src/components/UI/TooltipTitleContent.tsx +++ b/statshouse-ui/src/components/UI/TooltipTitleContent.tsx @@ -8,7 +8,14 @@ export const TooltipTitleContent = React.memo(function TooltipTitleContent({ chi return null; } if (typeof children === 'string') { - return
{children}
; + return ( +
+
{children}
+
+ {children} +
+
+ ); } return <>{children}; }); diff --git a/statshouse-ui/src/store/tvMode/tvModeStore.ts b/statshouse-ui/src/store/tvMode/tvModeStore.ts index 6bf4cbf8b..2c323c4e4 100644 --- a/statshouse-ui/src/store/tvMode/tvModeStore.ts +++ b/statshouse-ui/src/store/tvMode/tvModeStore.ts @@ -8,7 +8,7 @@ export type TVModeStore = { enable: boolean; interval: number; }; -export const defaultInterval = 30000; +export const defaultInterval = 0; const localStorageParamName = 'tv_interval'; const firstSelectorElement = '.dashLayout'; let timer: NodeJS.Timeout; diff --git a/statshouse-ui/src/view/ViewPage.tsx b/statshouse-ui/src/view/ViewPage.tsx index ddbdc72dc..adaa01e26 100644 --- a/statshouse-ui/src/view/ViewPage.tsx +++ b/statshouse-ui/src/view/ViewPage.tsx @@ -67,7 +67,7 @@ export const ViewPage: React.FC = ({ embed, yAxisSize = 54 }) => } return (
-
+
{tvMode && (