Skip to content

Commit 54ca8b3

Browse files
LunoryRuminat
authored andcommitted
chore: revert "feat(AsideHeader)!: add ui-kit button in aside-header (#315)" (#385)
* Revert "feat(AsideHeader)!: add ui-kit button in aside-header (#315)" This reverts commit 7269e9d. * chore: update screenshots * fix: remove odd extraButtonProps after reverting uikit btn in action
1 parent ae1fbe8 commit 54ca8b3

File tree

10 files changed

+69
-176
lines changed

10 files changed

+69
-176
lines changed

src/components/AsideHeader/README-ru.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ export const Aside: FC = () => {
169169
| tooltipText | Содержимое тултипа. | `React.ReactNode` | |
170170
| type | Тип элемента меню, определяющий его внешний вид: `"regular"`, `"action"` или `"divider"`. | `string` | `"regular"` |
171171
| qa | Значение, которое будет передано в атрибут `data-qa`. | `string` | |
172-
| extraButtonProps | Значения, переданные в UIKit `Button` для `type=action` item | `string` | |
173172

174173
### `TopAlert`
175174

src/components/AsideHeader/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export const Aside: FC = () => {
170170
| tooltipText | Tooltip content | `React.ReactNode` | |
171171
| type | The menu item type changes appearance: `"regular"`, `"action"`, `"divider"` | `string` | `"regular"` |
172172
| qa | The value to be passed to `data-qa` attribute | `string` | |
173-
| extraButtonProps | Properties passing to UIKit `Button` for `type=action` | `string` | |
174173

175174
### `TopAlert`
176175

Loading
Loading
Loading
Loading

src/components/AsideHeader/__stories__/moc.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export const menuItemsShowcase: AsideHeaderProps['menuItems'] = [
8787
type: 'action',
8888
icon: Plus,
8989
afterMoreButton: true,
90-
extraButtonProps: {
91-
'aria-label': 'action2',
92-
'aria-labelledby': 'action2',
93-
},
9490
onItemClick({id, title, current}) {
9591
alert(JSON.stringify({id, title, current}));
9692
},
@@ -130,10 +126,6 @@ const MENU_ITEMS_CLAMPED: AsideHeaderProps['menuItems'] = [
130126
title: MENU_ITEMS_CLAMPED_TITLE,
131127
icon: Gear,
132128
type: 'action',
133-
extraButtonProps: {
134-
'aria-label': 'action',
135-
'aria-labelledby': 'action',
136-
},
137129
},
138130
{
139131
id: 'text-link',
@@ -147,10 +139,6 @@ const MENU_ITEMS_CLAMPED: AsideHeaderProps['menuItems'] = [
147139
icon: Gear,
148140
link: 'about:blank',
149141
type: 'action',
150-
extraButtonProps: {
151-
'aria-label': 'text-link-action',
152-
'aria-labelledby': 'text-link-action',
153-
},
154142
},
155143
];
156144

src/components/CompositeBar/Item/Item.scss

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,6 @@ $block: '.#{variables.$ns}composite-bar-item';
3030
cursor: pointer;
3131
padding: 0;
3232

33-
&__action {
34-
display: flex;
35-
min-width: 0;
36-
width: 100%;
37-
height: 100%;
38-
align-items: center;
39-
cursor: pointer;
40-
}
41-
42-
&__action_collapse {
43-
display: flex;
44-
width: 216px;
45-
}
46-
47-
&__action-btn-container {
48-
display: flex;
49-
}
50-
5133
&__icon {
5234
color: var(--gn-aside-header-item-icon-color, var(--_--item-icon-color));
5335

@@ -92,15 +74,6 @@ $block: '.#{variables.$ns}composite-bar-item';
9274
height: 100%;
9375
}
9476

95-
&__action-icon {
96-
color: var(--gn-aside-header-item-icon-color, var(--g-color-text-complementary));
97-
align-items: center;
98-
display: flex;
99-
flex-shrink: 0;
100-
justify-content: center;
101-
width: var(--gn-composite-bar-item-action-size, 36px);
102-
}
103-
10477
&__title {
10578
display: flex;
10679
align-items: center;
@@ -190,15 +163,36 @@ $block: '.#{variables.$ns}composite-bar-item';
190163
justify-content: center;
191164
}
192165

193-
&__action-container {
194-
width: 100%;
166+
&_type_action {
167+
justify-content: center;
168+
height: var(--gn-composite-bar-item-action-size);
195169
margin: 0 10px 8px;
196-
}
170+
background: var(--g-color-base-float);
171+
box-shadow:
172+
0px 0px 0px 1px rgba(0, 0, 0, 0.03),
173+
0px 5px 6px rgba(0, 0, 0, 0.12);
174+
border-radius: var(--gn-composite-bar-item-action-size);
175+
transition:
176+
transform 0.1s ease-out,
177+
background-color 0.15s linear;
178+
179+
&:focus-visible {
180+
box-shadow: 0 0 0 2px var(--g-color-line-misc);
181+
}
197182

198-
&__action-container-compact {
199-
width: var(--gn-composite-bar-item-action-size, 36px);
200-
height: var(--gn-composite-bar-item-action-size, 36px);
201-
margin: 0 10px 8px;
183+
&:hover {
184+
background-color: var(--g-color-base-float-hover);
185+
}
186+
187+
&:active {
188+
box-shadow: 0 1px 2px var(--g-color-sfx-shadow);
189+
transition: none;
190+
transform: scale(0.96);
191+
}
192+
193+
& #{$class}__icon-place {
194+
width: var(--gn-composite-bar-item-action-size);
195+
}
202196
}
203197

204198
&__icon-tooltip_item-type_action {

src/components/CompositeBar/Item/Item.tsx

Lines changed: 40 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import React from 'react';
22

3-
import {
4-
ActionTooltip,
5-
Button,
6-
Icon,
7-
List,
8-
Popup,
9-
PopupPlacement,
10-
PopupProps,
11-
} from '@gravity-ui/uikit';
3+
import {ActionTooltip, Icon, List, Popup, PopupPlacement, PopupProps} from '@gravity-ui/uikit';
124

135
import {useAsideHeaderContext} from '../../AsideHeader/AsideHeaderContext';
146
import {ASIDE_HEADER_ICON_SIZE} from '../../constants';
@@ -173,116 +165,50 @@ export const Item: React.FC<ItemInnerProps> = (props) => {
173165
? ['a' as const, {href: item.link}]
174166
: ['button' as const, {}];
175167

176-
const handleMouseEnter = () => {
177-
if (!compact) {
178-
onMouseEnter?.();
179-
}
180-
};
181-
182-
const handleMouseLeave = () => {
183-
if (!compact) {
184-
onMouseLeave?.();
185-
}
186-
};
187-
188-
const handleClick = (
189-
event: React.MouseEvent<
190-
HTMLAnchorElement | HTMLButtonElement | HTMLDivElement,
191-
MouseEvent
192-
>,
193-
) => {
194-
const target = event.currentTarget;
195-
if (collapsedItem) {
196-
/**
197-
* If we call onItemClick for collapsedItem then:
198-
* - User get unexpected item in onItemClick callback
199-
* - onClosePanel calls twice for each popuped item, as result it will prevent opening of panelItems
200-
*/
201-
toggleOpen(!open);
202-
} else if (target instanceof HTMLDivElement) {
203-
onItemClick?.(item, false, event as React.MouseEvent<HTMLDivElement, MouseEvent>);
204-
}
205-
};
206-
207-
const renderActionButton = () => (
208-
<div className={compact ? b('action-container-compact') : b('action-container')}>
209-
<Button
210-
onClick={handleClick}
211-
className={b('action', {compact, collapse: !compact}, className)}
168+
const createdNode = (
169+
<React.Fragment>
170+
<Tag
171+
{...tagProps}
172+
className={b({type, current, compact}, className)}
212173
ref={ref}
213174
data-qa={item.qa}
214-
onMouseEnter={handleMouseEnter}
215-
onMouseLeave={handleMouseLeave}
216-
size="l"
217-
view="raised"
218-
type="button"
219-
pin="circle-circle"
220-
{...item.extraButtonProps}
175+
onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
176+
if (collapsedItem) {
177+
/**
178+
* If we call onItemClick for collapsedItem then:
179+
* - User get unexpected item in onItemClick callback
180+
* - onClosePanel calls twice for each popuped item, as result it will prevent opening of panelItems
181+
*/
182+
toggleOpen(!open);
183+
onCollapseItemClick?.();
184+
} else {
185+
onItemClick?.(item, false, event);
186+
}
187+
}}
188+
onClickCapture={onItemClickCapture}
189+
onMouseEnter={() => {
190+
if (!compact) {
191+
onMouseEnter?.();
192+
}
193+
}}
194+
onMouseLeave={() => {
195+
if (!compact) {
196+
onMouseLeave?.();
197+
}
198+
}}
221199
>
222-
<div className={b('action-btn-container')}>
223-
<div className={b('action-icon')}>{makeIconNode(iconEl)}</div>
224-
225-
{!compact && (
226-
<div
227-
className={b('title')}
228-
title={typeof item.title === 'string' ? item.title : undefined}
229-
>
230-
{titleEl}
231-
</div>
232-
)}
200+
<div className={b('icon-place')} ref={highlightedRef}>
201+
{makeIconNode(iconEl)}
233202
</div>
234-
</Button>
235-
</div>
236-
);
237203

238-
const renderTagContainer = () => (
239-
<Tag
240-
{...tagProps}
241-
className={b({type, current, compact}, className)}
242-
ref={ref}
243-
data-qa={item.qa}
244-
onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
245-
if (collapsedItem) {
246-
/**
247-
* If we call onItemClick for collapsedItem then:
248-
* - User get unexpected item in onItemClick callback
249-
* - onClosePanel calls twice for each popuped item, as result it will prevent opening of panelItems
250-
*/
251-
toggleOpen(!open);
252-
onCollapseItemClick?.();
253-
} else {
254-
onItemClick?.(item, false, event);
255-
}
256-
}}
257-
onClickCapture={onItemClickCapture}
258-
onMouseEnter={() => {
259-
if (!compact) {
260-
onMouseEnter?.();
261-
}
262-
}}
263-
onMouseLeave={() => {
264-
if (!compact) {
265-
onMouseLeave?.();
266-
}
267-
}}
268-
>
269-
<div className={b('icon-place')} ref={highlightedRef}>
270-
{makeIconNode(iconEl)}
271-
</div>
272-
273-
<div
274-
className={b('title')}
275-
title={typeof item.title === 'string' ? item.title : undefined}
276-
>
277-
{titleEl}
278-
</div>
279-
</Tag>
280-
);
281-
282-
const createdNode = (
283-
<React.Fragment>
284-
{type === 'action' ? renderActionButton() : renderTagContainer()}
285-
{renderPopupContent && anchorRef?.current && (
204+
<div
205+
className={b('title')}
206+
title={typeof item.title === 'string' ? item.title : undefined}
207+
>
208+
{titleEl}
209+
</div>
210+
</Tag>
211+
{renderPopupContent && Boolean(anchorRef?.current) && (
286212
<Popup
287213
strategy="fixed"
288214
open={popupVisible}
@@ -299,21 +225,12 @@ export const Item: React.FC<ItemInnerProps> = (props) => {
299225
</React.Fragment>
300226
);
301227

302-
if (item.link) {
303-
return (
304-
<a href={item.link} className={b('link')}>
305-
{createdNode}
306-
</a>
307-
);
308-
}
309-
310228
return createdNode;
311229
};
312230

313231
const iconNode = icon ? (
314232
<Icon qa={iconQa} data={icon} size={iconSize} className={b('icon')} />
315233
) : null;
316-
317234
const titleNode = renderItemTitle(item);
318235
const params = {icon: iconNode, title: titleNode};
319236
let highlightedNode = null;

src/components/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {HTMLAttributeAnchorTarget} from 'react';
22

3-
import {AlertProps, ButtonProps, IconProps, QAProps} from '@gravity-ui/uikit';
3+
import {AlertProps, IconProps, QAProps} from '@gravity-ui/uikit';
44

55
import {ItemProps} from 'src/components/CompositeBar/Item/Item';
66

@@ -56,10 +56,6 @@ export interface MenuItem extends QAProps {
5656
* The category to which the menu item belongs. Need for grouping in the display/editing mode of all pages
5757
*/
5858
category?: string;
59-
/**
60-
* Pass extra props to UIKit Button for action type item
61-
*/
62-
extraButtonProps?: ButtonProps;
6359
}
6460

6561
export type SubheaderMenuItem = Omit<ItemProps, 'onItemClick' | 'onItemClickCapture'>;

0 commit comments

Comments
 (0)