Skip to content

Commit

Permalink
cleanup, add pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Jun 13, 2024
1 parent 57464fd commit 63bb340
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions app/packages/core/src/components/Sidebar/Entries/PathValueEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ const TitleDiv = styled.div`
`;

const ScalarDiv = styled.div`
& {
text-selection
& > div:last-child {
cursor: pointer;
}
& > div > span {
cursor: text;
}
& > div {
Expand Down Expand Up @@ -118,7 +121,7 @@ const ScalarValueEntry = ({
trigger={trigger}
>
<ScalarDiv
title={expanded ? "click to minimize" : "click to expand"}
title={`Click to ${expanded ? "minimize" : "expand"}`}
className={expanded ? "expanded" : ""}
onClick={() => setExpanded((cur) => !cur)}
>
Expand Down Expand Up @@ -149,11 +152,8 @@ const ListContainer = styled(ScalarDiv)`
margin-top: 0.25rem;
padding: 0.25rem 0.5rem;
&.expanded > div {
& > div {
margin-bottom: 0.5rem;
}
&.expanded > div {
white-space: unset;
}
`;
Expand Down Expand Up @@ -185,9 +185,6 @@ const ListValueEntry = ({
const pseudoField = makePseudoField(path);
const { ftype, subfield, embeddedDocType } =
useRecoilValue(fos.field(path)) ?? makePseudoField(path);
const [textExpanded, setTextExpanded] = useRecoilState(
expandedPathValueEntry(path)
);

return (
<RegularEntry
Expand All @@ -207,20 +204,9 @@ const ListValueEntry = ({
field={field ?? pseudoField}
color={color}
template={({ label, hoverTarget }) => (
<>
<span
onClick={(e) => e.stopPropagation()}
ref={hoverTarget}
style={{ flex: "unset" }}
>
{label}
</span>
<span
title={textExpanded ? "click to minimize" : "click to expand"}
style={{ flex: 1, height: "100%" }}
onClick={() => setTextExpanded((cur) => !cur)}
/>
</>
<span onClick={(e) => e.stopPropagation()} ref={hoverTarget}>
{label}
</span>
)}
/>

Expand Down Expand Up @@ -281,10 +267,8 @@ const ListLoadable = ({ path }: { path: string }) => {
? Array.from(data).map((value) => prettify(value as string))
: [];
}, [data]);
const textExpanded = useRecoilValue(expandedPathValueEntry(path));

return (
<ListContainer className={textExpanded ? "expanded" : ""}>
<ListContainer>
{values.map((v, i) => (
<div key={i} title={typeof v === "string" ? v : undefined}>
{v}
Expand Down

0 comments on commit 63bb340

Please sign in to comment.