mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 18:48:12 +08:00
sub in Truncate component
This commit is contained in:
@@ -3,6 +3,7 @@ import React from "react";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import * as globals from "../../globals";
|
import * as globals from "../../globals";
|
||||||
import Logo from "../framework/logo";
|
import Logo from "../framework/logo";
|
||||||
|
import Truncate from "../util/truncate";
|
||||||
|
|
||||||
@connect((state) => ({
|
@connect((state) => ({
|
||||||
datasetTitle: state.config?.displayNames?.dataset ?? "",
|
datasetTitle: state.config?.displayNames?.dataset ?? "",
|
||||||
@@ -13,16 +14,8 @@ import Logo from "../framework/logo";
|
|||||||
class LeftSideBar extends React.Component {
|
class LeftSideBar extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { datasetTitle, aboutURL } = this.props;
|
const { datasetTitle, aboutURL } = this.props;
|
||||||
|
const width = 190;
|
||||||
const displayTitle =
|
const fontSize = 14;
|
||||||
datasetTitle.length > globals.datasetTitleMaxCharacterCount
|
|
||||||
? `${datasetTitle.substring(
|
|
||||||
0,
|
|
||||||
Math.floor(globals.datasetTitleMaxCharacterCount / 2)
|
|
||||||
)}…${datasetTitle.slice(
|
|
||||||
-Math.floor(globals.datasetTitleMaxCharacterCount / 2)
|
|
||||||
)}`
|
|
||||||
: datasetTitle;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -62,24 +55,27 @@ class LeftSideBar extends React.Component {
|
|||||||
<div
|
<div
|
||||||
data-testid="header"
|
data-testid="header"
|
||||||
style={{
|
style={{
|
||||||
fontSize: 14,
|
fontSize,
|
||||||
position: "relative",
|
position: "relative",
|
||||||
top: -6,
|
top: -6,
|
||||||
display: "inline-block",
|
display: "inline-block",
|
||||||
width: "190px",
|
width,
|
||||||
marginLeft: "7px",
|
marginLeft: "7px",
|
||||||
height: "1.2em",
|
height: "1.2em",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
wordBreak: "break-all",
|
wordBreak: "break-all",
|
||||||
}}
|
}}
|
||||||
title={datasetTitle}
|
|
||||||
>
|
>
|
||||||
{aboutURL ? (
|
{aboutURL ? (
|
||||||
<a href={aboutURL} target="_blank" rel="noopener noreferrer">
|
<Truncate size={width} fontSize={fontSize}>
|
||||||
{displayTitle}
|
<a href={aboutURL} target="_blank" rel="noopener noreferrer">
|
||||||
</a>
|
{datasetTitle}
|
||||||
|
</a>
|
||||||
|
</Truncate>
|
||||||
) : (
|
) : (
|
||||||
displayTitle
|
<Truncate size={width} fontSize={fontSize}>
|
||||||
|
<span>{datasetTitle}</span>
|
||||||
|
</Truncate>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user