Skip to content

Commit 830c0a5

Browse files
authored
feat: improve appearing controls styles (#1436)
1 parent 6cc07d5 commit 830c0a5

File tree

18 files changed

+126
-114
lines changed

18 files changed

+126
-114
lines changed

src/components/ClipboardButton/ClipboardButton.tsx

-52
This file was deleted.

src/components/ClipboardButton/index.ts

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
.developer-ui-link-button {
2-
display: none;
3-
4-
&_visible {
5-
display: inline-block;
6-
}
1+
@import '../../styles/mixins.scss';
72

8-
.data-table__row:hover &,
9-
.ydb-paginated-table__row:hover & {
10-
display: inline-block;
11-
}
3+
.developer-ui-link-button {
4+
@include table-hover-appearing-button();
125
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
import {ArrowUpRightFromSquare} from '@gravity-ui/icons';
2+
import type {ButtonSize} from '@gravity-ui/uikit';
23
import {Button, Icon} from '@gravity-ui/uikit';
34

45
import {cn} from '../../utils/cn';
56

7+
import i18n from './i18n';
8+
69
import './DeveloperUILinkButton.scss';
710

811
const b = cn('developer-ui-link-button');
912

13+
const buttonSizeToIconSize: Record<ButtonSize, number> = {
14+
xs: 14,
15+
s: 16,
16+
m: 16,
17+
l: 18,
18+
xl: 18,
19+
};
20+
1021
interface DeveloperUiLinkProps {
1122
className?: string;
1223
visible?: boolean;
1324
href: string;
25+
size?: ButtonSize;
1426
}
1527

16-
export function DeveloperUILinkButton({href, visible = false, className}: DeveloperUiLinkProps) {
28+
export function DeveloperUILinkButton({
29+
href,
30+
visible = false,
31+
className,
32+
size = 's',
33+
}: DeveloperUiLinkProps) {
1734
return (
18-
<Button size="s" href={href} className={b({visible}, className)} target="_blank">
19-
<Icon data={ArrowUpRightFromSquare} />
35+
<Button
36+
size={size}
37+
href={href}
38+
className={b({visible}, className)}
39+
target="_blank"
40+
title={i18n('action_go-to', {href})}
41+
>
42+
<Icon data={ArrowUpRightFromSquare} size={buttonSizeToIconSize[size]} />
2043
</Button>
2144
);
2245
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"action_go-to": "Go to {{href}}"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../../utils/i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-developer-ui-button';
6+
7+
export default registerKeysets(COMPONENT, {en});

src/components/EntityStatus/EntityStatus.scss

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@import '../../styles/mixins.scss';
22

33
.entity-status {
4+
position: relative;
5+
46
display: inline-flex;
57
align-items: center;
68

@@ -14,24 +16,33 @@
1416
}
1517

1618
&__clipboard-button {
19+
color: var(--g-color-text-secondary);
20+
21+
@include table-hover-appearing-button();
22+
}
23+
24+
&__controls-wrapper {
25+
position: absolute;
26+
top: 0;
27+
right: 0;
28+
1729
display: flex;
18-
flex-shrink: 0;
30+
align-items: center;
31+
gap: var(--g-spacing-1);
1932

20-
margin-left: var(--g-spacing-2);
33+
width: 0;
34+
height: 100%;
2135

22-
opacity: 0;
23-
color: var(--g-color-text-secondary);
36+
background-color: var(--g-color-base-float);
2437

25-
&_visible,
26-
&:focus-visible {
27-
opacity: 1;
38+
.data-table__row:hover &,
39+
.ydb-paginated-table__row:hover &,
40+
.ydb-tree-view__item & {
41+
width: min-content;
42+
padding: var(--g-spacing-1);
2843
}
2944
}
3045

31-
&__additional-controls {
32-
margin-left: var(--g-spacing-1);
33-
}
34-
3546
&__label {
3647
margin-right: 2px;
3748

src/components/EntityStatus/EntityStatus.tsx

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {Link as UIKitLink} from '@gravity-ui/uikit';
1+
import {ClipboardButton, Link as UIKitLink} from '@gravity-ui/uikit';
22

33
import {EFlag} from '../../types/api/enums';
44
import {cn} from '../../utils/cn';
5-
import {ClipboardButton} from '../ClipboardButton';
65
import {InternalLink} from '../InternalLink/InternalLink';
76
import {StatusIcon} from '../StatusIcon/StatusIcon';
87
import type {StatusIconMode, StatusIconSize} from '../StatusIcon/StatusIcon';
@@ -95,18 +94,21 @@ export function EntityStatus({
9594
</span>
9695
)}
9796
<span className={b('link', {'with-left-trim': withLeftTrim})}>{renderLink()}</span>
98-
{hasClipboardButton && (
99-
<ClipboardButton
100-
text={name}
101-
size="s"
102-
className={b('clipboard-button', {
103-
visible: clipboardButtonAlwaysVisible,
104-
})}
105-
/>
106-
)}
107-
{additionalControls && (
108-
<span className={b('additional-controls ')}>{additionalControls}</span>
109-
)}
97+
<div className={b('controls-wrapper')}>
98+
{hasClipboardButton && (
99+
<ClipboardButton
100+
text={name}
101+
size="xs"
102+
view="normal"
103+
className={b('clipboard-button', {
104+
visible: clipboardButtonAlwaysVisible,
105+
})}
106+
/>
107+
)}
108+
{additionalControls && (
109+
<span className={b('additional-controls')}>{additionalControls}</span>
110+
)}
111+
</div>
110112
</div>
111113
);
112114
}

src/components/NodeHostWrapper/NodeHostWrapper.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export const NodeHostWrapper = ({node, getNodeRef, database}: NodeHostWrapperPro
4242
})
4343
: undefined;
4444

45-
const additionalControls = nodeHref ? <DeveloperUILinkButton href={nodeHref} /> : null;
45+
const additionalControls = nodeHref ? (
46+
<DeveloperUILinkButton href={nodeHref} size="xs" />
47+
) : null;
4648

4749
return (
4850
<CellWithPopover

src/components/PaginatedTable/PaginatedTable.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
--paginated-table-cell-horizontal-padding: 10px;
88

99
--paginated-table-border-color: var(--g-color-base-generic-hover);
10-
--paginated-table-hover-color: var(--g-color-base-float-hover);
10+
--paginated-table-hover-color: var(--g-color-base-float);
1111

1212
width: 100%;
1313
@include body-2-typography();

src/containers/App/App.scss

+1-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ body,
3636
}
3737

3838
.g-root {
39-
--ydb-data-table-color-hover: var(--g-color-base-float-hover);
39+
--ydb-data-table-color-hover: var(--g-color-base-float);
4040

4141
// Colors for tablets, status icons and progress bars
4242
--ydb-color-status-grey: var(--g-color-base-neutral-heavy);
@@ -89,16 +89,6 @@ body,
8989
color: var(--g-color-text-danger);
9090
}
9191

92-
.data-table__row,
93-
.ydb-paginated-table__row,
94-
.ydb-tree-view__item {
95-
&:hover {
96-
& .clipboard-button {
97-
opacity: 1;
98-
}
99-
}
100-
}
101-
10292
.g-root .data-table_highlight-rows .data-table__row:hover {
10393
background: var(--ydb-data-table-color-hover);
10494
}

src/containers/Tenant/Diagnostics/TopShards/getTopShardsColumns.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ const tabletIdColumn: Column<KeyValueRow> = {
9292
hasClipboardButton
9393
showStatus={false}
9494
additionalControls={
95-
<DeveloperUILinkButton href={createTabletDeveloperUIHref(row.TabletId)} />
95+
<DeveloperUILinkButton
96+
href={createTabletDeveloperUIHref(row.TabletId)}
97+
size="xs"
98+
/>
9699
}
97100
/>
98101
);

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import React from 'react';
22

33
import {DefinitionList, HelpPopover} from '@gravity-ui/components';
44
import type {DefinitionListSingleItem} from '@gravity-ui/components/build/esm/components/DefinitionList/types';
5-
import {Flex, Tabs} from '@gravity-ui/uikit';
5+
import {ClipboardButton, Flex, Tabs} from '@gravity-ui/uikit';
66
import qs from 'qs';
77
import {Link, useLocation} from 'react-router-dom';
88
import {StringParam, useQueryParam} from 'use-query-params';
99

1010
import {AsyncReplicationState} from '../../../components/AsyncReplicationState';
11-
import {ClipboardButton} from '../../../components/ClipboardButton';
1211
import {toFormattedSize} from '../../../components/FormattedBytes/utils';
1312
import {LinkWithIcon} from '../../../components/LinkWithIcon/LinkWithIcon';
1413
import SplitPane from '../../../components/SplitPane';

src/containers/Tenant/Query/ExecuteResult/ExecuteResult.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react';
22

33
import type {ControlGroupOption} from '@gravity-ui/uikit';
4-
import {RadioButton, Tabs, Text} from '@gravity-ui/uikit';
4+
import {ClipboardButton, RadioButton, Tabs, Text} from '@gravity-ui/uikit';
55
import JSONTree from 'react-json-inspector';
66

7-
import {ClipboardButton} from '../../../../components/ClipboardButton';
87
import Divider from '../../../../components/Divider/Divider';
98
import ElapsedTime from '../../../../components/ElapsedTime/ElapsedTime';
109
import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';

src/containers/Tenant/Query/ExplainResult/ExplainResult.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react';
22

3-
import {RadioButton} from '@gravity-ui/uikit';
3+
import {ClipboardButton, RadioButton} from '@gravity-ui/uikit';
44

5-
import {ClipboardButton} from '../../../../components/ClipboardButton';
65
import Divider from '../../../../components/Divider/Divider';
76
import ElapsedTime from '../../../../components/ElapsedTime/ElapsedTime';
87
import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';

src/containers/Versions/NodesTreeTitle/NodesTreeTitle.scss

+4
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,9 @@
6565

6666
opacity: 0;
6767
color: var(--g-color-text-secondary);
68+
.ydb-tree-view__item:hover &,
69+
&:focus-visible {
70+
opacity: 1;
71+
}
6872
}
6973
}

src/containers/Versions/NodesTreeTitle/NodesTreeTitle.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import {Progress} from '@gravity-ui/uikit';
1+
import {ClipboardButton, Progress} from '@gravity-ui/uikit';
22

3-
import {ClipboardButton} from '../../../components/ClipboardButton';
43
import type {VersionValue} from '../../../types/versions';
54
import {cn} from '../../../utils/cn';
65
import type {PreparedNodeSystemState} from '../../../utils/nodes';
@@ -46,7 +45,12 @@ export const NodesTreeTitle = ({
4645
{title ? (
4746
<span className={b('overview-title')}>
4847
{title}
49-
<ClipboardButton text={title} size="s" className={b('clipboard-button')} />
48+
<ClipboardButton
49+
text={title}
50+
size="s"
51+
className={b('clipboard-button')}
52+
view="normal"
53+
/>
5054
</span>
5155
) : null}
5256
</div>

src/styles/mixins.scss

+26
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,29 @@
368368
--entity-state-border-color: var(--g-color-line-generic-hover);
369369
}
370370
}
371+
372+
@mixin table-hover-appearing-button {
373+
opacity: 0;
374+
375+
&_visible,
376+
&:focus-visible {
377+
opacity: 1;
378+
}
379+
&:focus-visible {
380+
position: absolute;
381+
top: 2px;
382+
right: 2px;
383+
384+
background-color: var(--g-color-base-float);
385+
}
386+
.data-table__row:hover &,
387+
.ydb-paginated-table__row:hover & {
388+
opacity: 1;
389+
}
390+
.data-table__row:hover &:focus-visible,
391+
.ydb-paginated-table__row:hover &:focus-visible {
392+
position: static;
393+
394+
background-color: unset;
395+
}
396+
}

0 commit comments

Comments
 (0)