Skip to content

Commit 9e7fca3

Browse files
committed
feat: clamp leaf text to 1 line by default; closes #88
1 parent bc57300 commit 9e7fca3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/components/DatasetDetailPage/FileTree/FileTreeRow.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { Tooltip, IconButton } from "@mui/material";
1414
import { Colors } from "design/theme";
1515
import React, { useState } from "react";
1616

17-
// FileTreeRow.tsx (top of file, below imports)
17+
// show more / show less button for long string
1818
const LeafString: React.FC<{ value: string }> = ({ value }) => {
1919
const LIMIT = 120;
20-
const [expanded, setExpanded] = React.useState(false);
20+
const [expanded, setExpanded] = useState(false);
2121

2222
const isLong = value.length > LIMIT;
2323
const display = expanded
@@ -45,7 +45,7 @@ const LeafString: React.FC<{ value: string }> = ({ value }) => {
4545
// collapsed: clamp to 2 lines; expanded: fully wrap
4646
display: expanded ? "block" : "-webkit-box",
4747
WebkitBoxOrient: "vertical",
48-
WebkitLineClamp: expanded ? ("unset" as any) : 2,
48+
WebkitLineClamp: expanded ? ("unset" as any) : 1,
4949
whiteSpace: expanded ? "pre-wrap" : "normal",
5050
overflow: expanded ? "visible" : "hidden",
5151
textOverflow: expanded ? "unset" : "ellipsis",
@@ -63,7 +63,11 @@ const LeafString: React.FC<{ value: string }> = ({ value }) => {
6363
e.stopPropagation(); // don’t toggle the row
6464
setExpanded((v) => !v);
6565
}}
66-
sx={{ px: 0.5, minWidth: "auto" }}
66+
sx={{
67+
px: 0.5,
68+
minWidth: "auto",
69+
color: Colors.purple,
70+
}}
6771
>
6872
{expanded ? "Show less" : "Show more"}
6973
</Button>
@@ -110,7 +114,6 @@ const FileTreeRow: React.FC<Props> = ({
110114
}) => {
111115
const [open, setOpen] = useState(false);
112116
const [copied, setCopied] = useState(false);
113-
const [showFull, setShowFull] = useState(false);
114117
// const internal = getInternalByPath?.(node.path);
115118
// const internal = getInternalByPath ? getInternalByPath(node.path) : undefined;
116119
const internal = getInternalByPath(node.path);
@@ -154,7 +157,6 @@ const FileTreeRow: React.FC<Props> = ({
154157

155158
<Typography
156159
sx={{
157-
// fontWeight: 600,
158160
flex: 1,
159161
color: Colors.darkPurple,
160162
}}
@@ -277,8 +279,6 @@ const FileTreeRow: React.FC<Props> = ({
277279
title={
278280
node.name === "_ArrayZipData_"
279281
? "[compressed data]"
280-
: typeof node.value === "string"
281-
? node.value
282282
: JSON.stringify(node.value)
283283
}
284284
sx={{

0 commit comments

Comments
 (0)