Skip to content

feat: improve appearing controls styles #1436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2024
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
52 changes: 0 additions & 52 deletions src/components/ClipboardButton/ClipboardButton.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/ClipboardButton/index.ts

This file was deleted.

13 changes: 3 additions & 10 deletions src/components/DeveloperUILinkButton/DeveloperUILinkButton.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
.developer-ui-link-button {
display: none;

&_visible {
display: inline-block;
}
@import '../../styles/mixins.scss';

.data-table__row:hover &,
.ydb-paginated-table__row:hover & {
display: inline-block;
}
.developer-ui-link-button {
@include table-hover-appearing-button();
}
29 changes: 26 additions & 3 deletions src/components/DeveloperUILinkButton/DeveloperUILinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
import {ArrowUpRightFromSquare} from '@gravity-ui/icons';
import type {ButtonSize} from '@gravity-ui/uikit';
import {Button, Icon} from '@gravity-ui/uikit';

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

import i18n from './i18n';

import './DeveloperUILinkButton.scss';

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

const buttonSizeToIconSize: Record<ButtonSize, number> = {
xs: 14,
s: 16,
m: 16,
l: 18,
xl: 18,
};

interface DeveloperUiLinkProps {
className?: string;
visible?: boolean;
href: string;
size?: ButtonSize;
}

export function DeveloperUILinkButton({href, visible = false, className}: DeveloperUiLinkProps) {
export function DeveloperUILinkButton({
href,
visible = false,
className,
size = 's',
}: DeveloperUiLinkProps) {
return (
<Button size="s" href={href} className={b({visible}, className)} target="_blank">
<Icon data={ArrowUpRightFromSquare} />
<Button
size={size}
href={href}
className={b({visible}, className)}
target="_blank"
title={i18n('action_go-to', {href})}
>
<Icon data={ArrowUpRightFromSquare} size={buttonSizeToIconSize[size]} />
Copy link
Collaborator

@astandrik astandrik Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can use Button Icons as here

<Button size="xs">
    <Button.Icon>
        <ArrowsRotateLeft />
    </Button.Icon>
</Button>;

and icon size should be set automatically according to button size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with uikit team, button doesn't affect it's icon size. We should explicitly set icon size we want.

</Button>
);
}
3 changes: 3 additions & 0 deletions src/components/DeveloperUILinkButton/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"action_go-to": "Go to {{href}}"
}
7 changes: 7 additions & 0 deletions src/components/DeveloperUILinkButton/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {registerKeysets} from '../../../utils/i18n';

import en from './en.json';

const COMPONENT = 'ydb-developer-ui-button';

export default registerKeysets(COMPONENT, {en});
33 changes: 22 additions & 11 deletions src/components/EntityStatus/EntityStatus.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import '../../styles/mixins.scss';

.entity-status {
position: relative;

display: inline-flex;
align-items: center;

Expand All @@ -14,24 +16,33 @@
}

&__clipboard-button {
color: var(--g-color-text-secondary);

@include table-hover-appearing-button();
}

&__controls-wrapper {
position: absolute;
top: 0;
right: 0;

display: flex;
flex-shrink: 0;
align-items: center;
gap: var(--g-spacing-1);

margin-left: var(--g-spacing-2);
width: 0;
height: 100%;

opacity: 0;
color: var(--g-color-text-secondary);
background-color: var(--g-color-base-float);

&_visible,
&:focus-visible {
opacity: 1;
.data-table__row:hover &,
.ydb-paginated-table__row:hover &,
.ydb-tree-view__item & {
width: min-content;
padding: var(--g-spacing-1);
}
}

&__additional-controls {
margin-left: var(--g-spacing-1);
}

&__label {
margin-right: 2px;

Expand Down
30 changes: 16 additions & 14 deletions src/components/EntityStatus/EntityStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {Link as UIKitLink} from '@gravity-ui/uikit';
import {ClipboardButton, Link as UIKitLink} from '@gravity-ui/uikit';

import {EFlag} from '../../types/api/enums';
import {cn} from '../../utils/cn';
import {ClipboardButton} from '../ClipboardButton';
import {InternalLink} from '../InternalLink/InternalLink';
import {StatusIcon} from '../StatusIcon/StatusIcon';
import type {StatusIconMode, StatusIconSize} from '../StatusIcon/StatusIcon';
Expand Down Expand Up @@ -95,18 +94,21 @@ export function EntityStatus({
</span>
)}
<span className={b('link', {'with-left-trim': withLeftTrim})}>{renderLink()}</span>
{hasClipboardButton && (
<ClipboardButton
text={name}
size="s"
className={b('clipboard-button', {
visible: clipboardButtonAlwaysVisible,
})}
/>
)}
{additionalControls && (
<span className={b('additional-controls ')}>{additionalControls}</span>
)}
<div className={b('controls-wrapper')}>
{hasClipboardButton && (
<ClipboardButton
text={name}
size="xs"
view="normal"
className={b('clipboard-button', {
visible: clipboardButtonAlwaysVisible,
})}
/>
)}
{additionalControls && (
<span className={b('additional-controls')}>{additionalControls}</span>
)}
</div>
Comment on lines +108 to +110
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeveloperUIButton is controlled by display: none and display: inline-block. It cannot be selected with Tab. Two ways possible:

  1. All buttons in the UI should be keyboard accessible, so this DeveloperUIButton button should be updated too

  2. We don't need to make buttons in table keyboard accessible (for me in tables it doesn't make much sense anyway), so we can stick to previous solution, but update only ClipboardButton

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets try the hardest way number 1. I hope I've found a solution.

</div>
);
}
4 changes: 3 additions & 1 deletion src/components/NodeHostWrapper/NodeHostWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const NodeHostWrapper = ({node, getNodeRef, database}: NodeHostWrapperPro
})
: undefined;

const additionalControls = nodeHref ? <DeveloperUILinkButton href={nodeHref} /> : null;
const additionalControls = nodeHref ? (
<DeveloperUILinkButton href={nodeHref} size="xs" />
) : null;

return (
<CellWithPopover
Expand Down
2 changes: 1 addition & 1 deletion src/components/PaginatedTable/PaginatedTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--paginated-table-cell-horizontal-padding: 10px;

--paginated-table-border-color: var(--g-color-base-generic-hover);
--paginated-table-hover-color: var(--g-color-base-float-hover);
--paginated-table-hover-color: var(--g-color-base-float);

width: 100%;
@include body-2-typography();
Expand Down
12 changes: 1 addition & 11 deletions src/containers/App/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ body,
}

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

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

.data-table__row,
.ydb-paginated-table__row,
.ydb-tree-view__item {
&:hover {
& .clipboard-button {
opacity: 1;
}
}
}

.g-root .data-table_highlight-rows .data-table__row:hover {
background: var(--ydb-data-table-color-hover);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ const tabletIdColumn: Column<KeyValueRow> = {
hasClipboardButton
showStatus={false}
additionalControls={
<DeveloperUILinkButton href={createTabletDeveloperUIHref(row.TabletId)} />
<DeveloperUILinkButton
href={createTabletDeveloperUIHref(row.TabletId)}
size="xs"
/>
}
/>
);
Expand Down
3 changes: 1 addition & 2 deletions src/containers/Tenant/ObjectSummary/ObjectSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import React from 'react';

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

import {AsyncReplicationState} from '../../../components/AsyncReplicationState';
import {ClipboardButton} from '../../../components/ClipboardButton';
import {toFormattedSize} from '../../../components/FormattedBytes/utils';
import {LinkWithIcon} from '../../../components/LinkWithIcon/LinkWithIcon';
import SplitPane from '../../../components/SplitPane';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';

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

import {ClipboardButton} from '../../../../components/ClipboardButton';
import Divider from '../../../../components/Divider/Divider';
import ElapsedTime from '../../../../components/ElapsedTime/ElapsedTime';
import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';

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

import {ClipboardButton} from '../../../../components/ClipboardButton';
import Divider from '../../../../components/Divider/Divider';
import ElapsedTime from '../../../../components/ElapsedTime/ElapsedTime';
import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';
Expand Down
4 changes: 4 additions & 0 deletions src/containers/Versions/NodesTreeTitle/NodesTreeTitle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,9 @@

opacity: 0;
color: var(--g-color-text-secondary);
.ydb-tree-view__item:hover &,
&:focus-visible {
opacity: 1;
}
}
}
10 changes: 7 additions & 3 deletions src/containers/Versions/NodesTreeTitle/NodesTreeTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Progress} from '@gravity-ui/uikit';
import {ClipboardButton, Progress} from '@gravity-ui/uikit';

import {ClipboardButton} from '../../../components/ClipboardButton';
import type {VersionValue} from '../../../types/versions';
import {cn} from '../../../utils/cn';
import type {PreparedNodeSystemState} from '../../../utils/nodes';
Expand Down Expand Up @@ -46,7 +45,12 @@ export const NodesTreeTitle = ({
{title ? (
<span className={b('overview-title')}>
{title}
<ClipboardButton text={title} size="s" className={b('clipboard-button')} />
<ClipboardButton
text={title}
size="s"
className={b('clipboard-button')}
view="normal"
/>
</span>
) : null}
</div>
Expand Down
26 changes: 26 additions & 0 deletions src/styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,29 @@
--entity-state-border-color: var(--g-color-line-generic-hover);
}
}

@mixin table-hover-appearing-button {
opacity: 0;

&_visible,
&:focus-visible {
opacity: 1;
}
&:focus-visible {
position: absolute;
top: 2px;
right: 2px;

background-color: var(--g-color-base-float);
}
.data-table__row:hover &,
.ydb-paginated-table__row:hover & {
opacity: 1;
}
.data-table__row:hover &:focus-visible,
.ydb-paginated-table__row:hover &:focus-visible {
position: static;

background-color: unset;
}
}
Loading