Skip to content

Commit 2add476

Browse files
feat(Versions): redesign
1 parent e229c75 commit 2add476

File tree

19 files changed

+542
-466
lines changed

19 files changed

+542
-466
lines changed

src/components/VersionsBar/VersionsBar.scss

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,82 @@
11
@use '../../styles/mixins.scss';
22

33
.ydb-versions-bar {
4+
&__bar-wrapper {
5+
gap: var(--g-spacing-2);
6+
7+
width: 100%;
8+
9+
&_size_m {
10+
gap: var(--g-spacing-3);
11+
}
12+
}
13+
414
&__bar {
15+
gap: var(--g-spacing-half);
16+
517
width: 100%;
618
height: 10px;
19+
20+
&_size_m {
21+
gap: var(--g-spacing-1);
22+
23+
height: 20px;
24+
}
725
}
826

927
&__titles-wrapper {
10-
width: max-content;
28+
flex-direction: column;
29+
gap: var(--g-spacing-half);
30+
31+
&_size_m {
32+
flex-flow: row wrap;
33+
gap: var(--g-spacing-4);
34+
}
1135
}
1236

1337
&__title {
38+
gap: var(--g-spacing-1);
39+
40+
width: max-content;
41+
42+
&_size_m {
43+
gap: var(--g-spacing-2);
44+
45+
height: 20px;
46+
}
47+
}
48+
49+
&__title-text {
1450
overflow: hidden;
1551

1652
text-overflow: ellipsis;
1753

1854
color: var(--g-color-text-primary);
1955

2056
@include mixins.body-1-typography();
57+
58+
&_size_m {
59+
overflow: visible;
60+
61+
text-overflow: initial;
62+
}
2163
}
2264

2365
&__version {
2466
min-width: 10px;
2567

2668
border-radius: var(--g-border-radius-xs);
69+
70+
&_size_m {
71+
min-width: 20px;
72+
}
2773
}
2874

29-
&__title,
75+
&__title-text,
3076
&__version,
3177
&__version-icon {
78+
cursor: pointer;
79+
3280
&_dimmed {
3381
opacity: 0.5;
3482
}

src/components/VersionsBar/VersionsBar.tsx

Lines changed: 93 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ const MAX_DISPLAYED_VERSIONS = TRUNCATION_THRESHOLD - 1;
1919
const HOVER_DELAY = 200;
2020
const TOOLTIP_OPEN_DELAY = 200;
2121

22+
type VersionsBarSize = 's' | 'm';
23+
2224
interface VersionsBarProps {
2325
preparedVersions: PreparedVersion[];
26+
withTitles?: boolean;
27+
size?: VersionsBarSize;
2428
}
2529

26-
export function VersionsBar({preparedVersions}: VersionsBarProps) {
27-
const shouldTruncateVersions = preparedVersions.length > TRUNCATION_THRESHOLD;
30+
export function VersionsBar({preparedVersions, withTitles = true, size = 's'}: VersionsBarProps) {
31+
const shouldTruncateVersions = preparedVersions.length > TRUNCATION_THRESHOLD && size === 's';
2832

2933
const [hoveredVersion, setHoveredVersion] = React.useState<string | undefined>();
3034
const [allVersionsDisplayed, setAllVersionsDisplayed] = React.useState<boolean>(false);
@@ -103,12 +107,12 @@ export function VersionsBar({preparedVersions}: VersionsBarProps) {
103107
}, [handleMouseEnter]);
104108

105109
const isDimmed = (version: string) => {
106-
return hoveredVersion && hoveredVersion !== version;
110+
return Boolean(hoveredVersion && hoveredVersion !== version);
107111
};
108112

109113
return (
110-
<Flex gap={2} direction={'column'} className={b(null)} wrap>
111-
<Flex className={b('bar')} grow={1} gap={0.5}>
114+
<Flex direction={'column'} className={b('bar-wrapper', {size})} wrap>
115+
<Flex className={b('bar', {size})} grow={1}>
112116
{displayedVersions.map((item) => (
113117
<Tooltip
114118
key={item.version}
@@ -119,54 +123,103 @@ export function VersionsBar({preparedVersions}: VersionsBarProps) {
119123
{item.version}
120124
</React.Fragment>
121125
}
122-
placement={'top-start'}
126+
placement={size === 'm' ? 'auto' : 'top-start'}
123127
openDelay={TOOLTIP_OPEN_DELAY}
124128
>
125129
<span
126130
onMouseEnter={() => {
127131
handleMouseEnter(item.version);
128132
}}
129133
onMouseLeave={handleMouseLeave}
130-
className={b('version', {dimmed: isDimmed(item.version)})}
134+
className={b('version', {dimmed: isDimmed(item.version), size})}
131135
style={{backgroundColor: item.color, width: `${item.value}%`}}
132136
/>
133137
</Tooltip>
134138
))}
135139
</Flex>
136140

137-
<Flex gap={0.5} direction={'column'}>
138-
{truncatedDisplayedVersions.map((item) => (
139-
<Tooltip
140-
key={item.version}
141-
content={i18n('tooltip_nodes', {count: item.count})}
142-
placement={'bottom-end'}
143-
openDelay={TOOLTIP_OPEN_DELAY}
144-
>
145-
<Flex gap={1} alignItems={'center'} className={b('titles-wrapper')}>
146-
<svg
147-
xmlns="http://www.w3.org/2000/svg"
148-
width="6"
149-
height="6"
150-
viewBox="0 0 6 6"
151-
fill="none"
152-
className={b('version-icon', {dimmed: isDimmed(item.version)})}
153-
>
154-
<circle cx="3" cy="3" r="3" fill={item.color} />
155-
</svg>
156-
<div
157-
className={b('title', {dimmed: isDimmed(item.version)})}
158-
onMouseEnter={() => {
159-
handleMouseEnter(item.version);
160-
}}
161-
onMouseLeave={handleMouseLeave}
162-
>
163-
{item.version}
164-
</div>
165-
</Flex>
166-
</Tooltip>
167-
))}
168-
<Flex>{renderButton()}</Flex>
169-
</Flex>
141+
{withTitles && (
142+
<Flex className={b('titles-wrapper', {size})}>
143+
{truncatedDisplayedVersions.map((item) => (
144+
<VersionTitle
145+
key={item.version}
146+
version={item.version}
147+
color={item.color || ''}
148+
count={item.count}
149+
isDimmed={isDimmed(item.version)}
150+
onMouseEnter={() => {
151+
handleMouseEnter(item.version);
152+
}}
153+
onMouseLeave={handleMouseLeave}
154+
size={size}
155+
/>
156+
))}
157+
<Flex>{renderButton()}</Flex>
158+
</Flex>
159+
)}
170160
</Flex>
171161
);
172162
}
163+
164+
interface VersionTitleProps {
165+
version: string;
166+
color: string;
167+
count?: number;
168+
isDimmed: boolean;
169+
onMouseEnter: () => void;
170+
onMouseLeave: () => void;
171+
size: VersionsBarSize;
172+
}
173+
174+
function VersionTitle({
175+
version,
176+
color,
177+
count,
178+
isDimmed,
179+
onMouseEnter,
180+
onMouseLeave,
181+
size,
182+
}: VersionTitleProps) {
183+
return (
184+
<Tooltip
185+
content={i18n('tooltip_nodes', {count: count})}
186+
placement={'bottom-end'}
187+
openDelay={TOOLTIP_OPEN_DELAY}
188+
>
189+
<Flex alignItems={'center'} className={b('title', {size})}>
190+
<VersionCircle size={size} dimmed={isDimmed} color={color} />
191+
<div
192+
className={b('title-text', {dimmed: isDimmed, size})}
193+
onMouseEnter={onMouseEnter}
194+
onMouseLeave={onMouseLeave}
195+
>
196+
{version}
197+
</div>
198+
</Flex>
199+
</Tooltip>
200+
);
201+
}
202+
203+
interface VersionCircleProps {
204+
size: VersionsBarSize;
205+
dimmed: boolean;
206+
color: string;
207+
}
208+
209+
function VersionCircle({size, dimmed, color}: VersionCircleProps) {
210+
const numericSize = size === 'm' ? 8 : 6;
211+
const radius = numericSize / 2;
212+
213+
return (
214+
<svg
215+
xmlns="http://www.w3.org/2000/svg"
216+
width={numericSize}
217+
height={numericSize}
218+
viewBox={`0 0 ${numericSize} ${numericSize}`}
219+
fill="none"
220+
className={b('version-icon', {dimmed})}
221+
>
222+
<circle cx={radius} cy={radius} r={radius} fill={color} />
223+
</svg>
224+
);
225+
}

src/containers/Cluster/VersionsBar/VersionsBar.scss

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/containers/Cluster/VersionsBar/VersionsBar.tsx

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,15 @@
11
@use '../../../styles/mixins.scss';
22

33
.ydb-versions-grouped-node-tree {
4-
$item-width: 100%;
5-
$margin-size: 24px;
6-
7-
&_first-level {
8-
margin-top: 10px;
9-
margin-bottom: 10px;
10-
4+
&__wrapper {
115
border: 1px solid var(--g-color-line-generic);
12-
border-radius: 10px;
6+
border-radius: var(--g-border-radius-m);
137
}
148

159
&__dt-wrapper {
1610
position: relative;
1711
z-index: 0;
1812

1913
overflow: auto hidden;
20-
21-
margin-right: $margin-size;
22-
margin-left: $margin-size;
23-
}
24-
25-
.ydb-tree-view {
26-
@include mixins.body-2-typography();
27-
28-
// Apply margin ignoring first element of the tree
29-
.ydb-tree-view {
30-
margin-left: $margin-size;
31-
}
32-
}
33-
34-
& .tree-view_item {
35-
height: 40px;
36-
margin: 0;
37-
38-
// By default tree is rendered with padding calculated based on level
39-
// We replace padding with margin for correct hover
40-
padding: 0 10px !important;
41-
42-
border: 0;
43-
border-radius: 10px;
44-
}
45-
46-
& .tree-view_children .tree-view_item {
47-
width: $item-width;
48-
}
49-
50-
& .g-progress__stack {
51-
cursor: pointer;
5214
}
5315
}

0 commit comments

Comments
 (0)