-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StatsHouse UI: add show dash name and description, update tooltip
- Loading branch information
Showing
10 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { selectorParams, useStore } from '../../store'; | ||
import { useWindowSize } from '../../hooks'; | ||
import cn from 'classnames'; | ||
import { Tooltip } from '../UI'; | ||
import { DashboardNameTitle } from './DashboardNameTitle'; | ||
|
||
export type DashboardNameProps = {}; | ||
|
||
export function DashboardName() { | ||
const params = useStore(selectorParams); | ||
const scrollY = useWindowSize((s) => s.scrollY > 16); | ||
|
||
if (!params.dashboard?.name) { | ||
return null; | ||
} | ||
return ( | ||
<div className={cn('sticky-top mt-2 bg-body', scrollY && 'shadow-sm small')}> | ||
<Tooltip | ||
className="container-xl d-flex flex-row gap-2" | ||
title={<DashboardNameTitle name={params.dashboard.name} description={params.dashboard.description} />} | ||
hover | ||
horizontal="left" | ||
> | ||
<div> | ||
{params.dashboard.name} | ||
{!!params.dashboard.description && ':'} | ||
</div> | ||
{!!params.dashboard.description && ( | ||
<div className="text-secondary flex-grow-1 w-0 overflow-hidden text-truncate"> | ||
{params.dashboard.description} | ||
</div> | ||
)} | ||
</Tooltip> | ||
</div> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
statshouse-ui/src/components/Dashboard/DashboardNameTitle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
export type DashboardNameTitleProps = { | ||
name: string; | ||
description?: string; | ||
}; | ||
|
||
export function DashboardNameTitle({ name, description }: DashboardNameTitleProps) { | ||
return ( | ||
<div className="small text-secondary overflow-auto"> | ||
<div className="text-body fw-bold"> | ||
{name} | ||
{!!description && ':'} | ||
</div> | ||
{!!description && <div style={{ maxWidth: '80vw', whiteSpace: 'pre-wrap' }}>{description}</div>} | ||
{!!description && ( | ||
<div className="opacity-0 overflow-hidden h-0" style={{ maxWidth: '80vw', whiteSpace: 'pre' }}> | ||
{description} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters