Skip to content

Commit

Permalink
looks good now
Browse files Browse the repository at this point in the history
  • Loading branch information
bobular committed Jun 21, 2024
1 parent 06f4959 commit 30da70a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
26 changes: 25 additions & 1 deletion packages/libs/coreui/src/components/Mesa/Ui/DataCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import Templates from '../Templates';
import { makeClassifier } from '../Utils/Utils';

import { Tooltip } from '../../../components/info/Tooltip';

const dataCellClass = makeClassifier('DataCell');

class DataCell extends React.PureComponent {
Expand Down Expand Up @@ -64,7 +66,29 @@ class DataCell extends React.PureComponent {
width = width ? { width, maxWidth: width, minWidth: width } : {};
style = Object.assign({}, style, width, whiteSpace);
className = dataCellClass() + (className ? ' ' + className : '');
const children = this.renderContent();

const content = this.renderContent();
const columnName = column.name ?? column.key;

// Ideally the tooltip would also be conditional on there
// being actual content, but this is not trivial without
// copy-pasting the getValue logic from this.renderContent().
// Verdict: not worth it
const children = options.inlineUseTooltips ? (
<Tooltip
title={
<>
{columnName && <span>{columnName}:</span>}
{content}
</>
}
>
{content}
</Tooltip>
) : (
content
);

const props = {
style,
children,
Expand Down
1 change: 0 additions & 1 deletion packages/libs/coreui/src/components/Mesa/Ui/DataRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class DataRow extends React.PureComponent {
const { row, rowIndex, options } = this.props;
const { inline, onRowClick, inlineUseTooltips } = options;
if (!inline && !onRowClick) return;
console.log({ options });
if (inline && !inlineUseTooltips)
this.setState({ expanded: !this.state.expanded });
if (typeof onRowClick === 'function') onRowClick(row, rowIndex);
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/coreui/src/components/Mesa/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface MesaStateProps<
inline?: boolean;
inlineMaxWidth?: string;
inlineMaxHeight?: string;
inlineUseTooltips?: boolean; // on clicking on a row, don't expand the row height-wise to show the full contents, use a tooltip instead
inlineUseTooltips?: boolean; // don't use onClick to show the full contents, use an onMouseOver tooltip instead
className?: string;
errOnOverflow?: boolean;
editableColumns?: boolean;
Expand Down

0 comments on commit 30da70a

Please sign in to comment.