Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/components/TreeView/TreeView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $step-offset: 24px;

.ydb-tree-view {
--ydb-tree-view-level: 0;
$icon-height: 24px;

$root: &;
font-size: 13px;
Expand Down Expand Up @@ -48,6 +49,7 @@ $step-offset: 24px;
flex-grow: 1;
display: flex;
align-items: center;
justify-content: space-between;
overflow: hidden;
}

Expand All @@ -56,17 +58,22 @@ $step-offset: 24px;
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
width: $icon-height;
height: $icon-height;
color: var(--g-color-text-hint);

svg {
display: block;
}
}

&__label {
display: inline-flex;
align-items: center;
min-width: 0;
}

&__text {
flex-grow: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
Expand Down
15 changes: 10 additions & 5 deletions src/components/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import type {DropdownMenuItemMixed} from '@gravity-ui/uikit';
import {DropdownMenu} from '@gravity-ui/uikit';
import {ActionTooltip, DropdownMenu} from '@gravity-ui/uikit';

import {block} from '../../utils/cn';

Expand All @@ -18,7 +18,7 @@
onArrowClick?: () => void;
onActionsOpenToggle?: (isOpen: boolean) => void;
hasArrow?: boolean;
actions?: DropdownMenuItemMixed<any>[];

Check warning on line 21 in src/components/TreeView/TreeView.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Unexpected any. Specify a different type
additionalNodeElements?: JSX.Element;
level?: number;
}
Expand Down Expand Up @@ -74,6 +74,9 @@
containerClassName += ' tree-view_children-collapsed';
}

const tooltipContent = title ?? (typeof name === 'string' ? name : '');
const isTooltipDisabled = tooltipContent.trim().length === 0;

return (
<div className={b()} style={{[TREE_LEVEL_CSS_VAR]: level} as React.CSSProperties}>
<div className="tree-view">
Expand All @@ -88,10 +91,12 @@
onClick={handleArrowClick}
/>
<div className={b('content')}>
{icon && <div className={b('icon')}>{icon}</div>}
<div className={b('text')} title={title}>
{name}
</div>
<ActionTooltip title={tooltipContent} disabled={isTooltipDisabled}>
<div className={b('label')}>
{icon && <div className={b('icon')}>{icon}</div>}
<div className={b('text')}>{name}</div>
</div>
</ActionTooltip>
{actions && actions.length > 0 && (
<div className={b('actions')}>
{additionalNodeElements}
Expand Down
Loading