diff --git a/client/src/components/categorical/value.js b/client/src/components/categorical/value.js index c5a2b8d8..8eec1462 100644 --- a/client/src/components/categorical/value.js +++ b/client/src/components/categorical/value.js @@ -15,6 +15,7 @@ import { import Occupancy from "./occupancy"; import * as globals from "../../globals"; import styles from "./categorical.css"; +import { Tooltip } from "@blueprintjs/core"; @connect(state => ({ categoricalSelection: state.categoricalSelection, @@ -203,6 +204,30 @@ class CategoryValue extends React.Component { categories = schema.annotations.obsByName[colorAccessor]?.categories; } + let truncatedString = null; + + if ( + colorAccessor && + !isColorBy && + displayString.length > globals.categoryLabelDisplayStringShortLength + ) { + truncatedString = `${displayString.slice( + 0, + globals.categoryLabelDisplayStringShortLength / 2 + )}…${displayString.slice( + -globals.categoryLabelDisplayStringShortLength / 2 + )}`; + } else if ( + displayString.length > globals.categoryLabelDisplayStringLongLength + ) { + truncatedString = `${displayString.slice( + 0, + globals.categoryLabelDisplayStringLongLength / 2 + )}…${displayString.slice( + -globals.categoryLabelDisplayStringLongLength / 2 + )}`; + } + return (
-
-
-
- +
+
+ + {annotations.isEditingLabelName && annotations.labelEditable.category === metadataField && annotations.labelEditable.label === categoryIndex ? null - : displayString} + : truncatedString || displayString} -
+ {isUserAnno && - annotations.isEditingLabelName && annotations.labelEditable.category === metadataField && + annotations.isEditingLabelName && annotations.labelEditable.label === categoryIndex ? (
{ diff --git a/client/src/globals.js b/client/src/globals.js index 46ce2b3e..9f62bd26 100644 --- a/client/src/globals.js +++ b/client/src/globals.js @@ -68,9 +68,12 @@ export const leftSidebarSectionHeading = { letterSpacing: ".05em" }; export const leftSidebarSectionPadding = 10; +export const categoryLabelDisplayStringLongLength = 35; +export const categoryLabelDisplayStringShortLength = 15; /* various timing-related behaviors */ export const tooltipHoverOpenDelay = 1000; /* ms delay before a tooltip displays */ +export const tooltipHoverOpenDelayQuick = 500; let _API = { // prefix: "http://api.clustering.czi.technology/api/",