Skip to content

Commit

Permalink
Move tooltip to its own component
Browse files Browse the repository at this point in the history
  • Loading branch information
rogermparent committed Apr 1, 2022
1 parent 7cb4ca7 commit dd4c713
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
20 changes: 1 addition & 19 deletions webview/src/experiments/components/cell/Cell.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
import { Experiment } from 'dvc/src/experiments/webview/contract'
import React from 'react'
import { Cell } from 'react-table'
import { CellTooltip } from './CellTooltip'
import { CopyButton } from '../copyButton/CopyButton'
import Tooltip, {
CELL_TOOLTIP_DELAY
} from '../../../shared/components/tooltip/Tooltip'
import { formatFloat } from '../../util/numberFormatting'
import styles from '../table/styles.module.scss'

const groupLabels: Record<string, string> = {
metrics: 'Metric',
params: 'Parameter'
}

const CellTooltip: React.FC<{
cell: Cell<Experiment, string | number>
}> = ({ cell }) => {
const {
column: { group },
value
} = cell
return (
<>
{groupLabels[group as string]}: {value}
</>
)
}

const UndefinedCell = (
<div className={styles.innerCell}>
<span className={styles.cellContents}>. . .</span>
Expand Down
22 changes: 22 additions & 0 deletions webview/src/experiments/components/cell/CellTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { Cell } from 'react-table'
import { Experiment } from 'dvc/src/experiments/webview/contract'

const groupLabels: Record<string, string> = {
metrics: 'Metric',
params: 'Parameter'
}

export const CellTooltip: React.FC<{
cell: Cell<Experiment, string | number>
}> = ({ cell }) => {
const {
column: { group },
value
} = cell
return (
<>
{groupLabels[group as string]}: {value}
</>
)
}

0 comments on commit dd4c713

Please sign in to comment.