Skip to content

Commit 7c5aaca

Browse files
committed
refactor(mobile): after rebase
1 parent 89e4de0 commit 7c5aaca

File tree

5 files changed

+34
-36
lines changed

5 files changed

+34
-36
lines changed

demo/stories/mobile-editor/MobileEditor.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {memo} from 'react';
22

3-
import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';
43
import cloneDeep from 'lodash/cloneDeep';
54

65
import {
@@ -42,7 +41,6 @@ export const MobileEditor = memo(() => {
4241
stickyToolbar
4342
settingsVisible
4443
editor={editor}
45-
toaster={toaster}
4644
className={className}
4745
mobile
4846
/>

src/bundle/SelectPopup.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import {Popup, PopupProps, Sheet} from '@gravity-ui/uikit';
44

55
import {cn} from '../classname';
66

7-
export type SelectPopupProps = Pick<PopupProps, 'placement' | 'open' | 'anchorRef'> & {
7+
export type SelectPopupProps = Pick<PopupProps, 'placement' | 'open' | 'anchorElement'> & {
88
children: ReactNode;
99
mobile?: boolean;
10-
buttonRef?: PopupProps['anchorRef'];
1110
onClose?: () => void;
1211
};
1312

@@ -19,7 +18,7 @@ export const SelectPopup: FC<SelectPopupProps> = ({
1918
mobile,
2019
children,
2120
onClose,
22-
anchorRef,
21+
anchorElement,
2322
placement,
2423
open = false,
2524
}) => {
@@ -32,7 +31,12 @@ export const SelectPopup: FC<SelectPopupProps> = ({
3231
}
3332

3433
return (
35-
<Popup anchorRef={anchorRef} open={open} onClose={onClose} placement={placement}>
34+
<Popup
35+
anchorElement={anchorElement}
36+
open={open}
37+
onOpenChange={onClose}
38+
placement={placement}
39+
>
3640
{children}
3741
</Popup>
3842
);

src/bundle/settings/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
HelpMark,
1111
Icon,
1212
Menu,
13-
Popup,
1413
type PopupPlacement,
1514
} from '@gravity-ui/uikit';
1615

@@ -90,7 +89,7 @@ export const EditorSettings = memo<EditorSettingsProps>(function EditorSettings(
9089
mobile={mobile}
9190
open={popupShown}
9291
onClose={hidePopup}
93-
anchorRef={chevronElement}
92+
anchorElement={chevronElement}
9493
placement={placement}
9594
>
9695
<SettingsContent

src/toolbar/PreviewTooltip.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ const b = cn('preview-tooltip');
1111
type PreviewTooltipProps = {
1212
preview?: React.ReactNode;
1313
children: React.ReactElement;
14+
mobile?: boolean;
1415
};
1516

16-
export const PreviewTooltip: React.FC<PreviewTooltipProps> = ({preview, children}) => {
17+
export const PreviewTooltip: React.FC<PreviewTooltipProps> = ({preview, children, mobile}) => {
1718
return (
1819
<Tooltip
1920
placement="right"
2021
className={b()}
21-
disabled={!preview}
22+
disabled={!preview || mobile}
2223
openDelay={ToolbarTooltipDelay.Open}
2324
closeDelay={ToolbarTooltipDelay.Close}
2425
content={<div className={b('content')}>{preview}</div>}

src/toolbar/ToolbarListButton.tsx

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import {Fragment, useEffect, useState} from 'react';
22

33
import {ChevronDown} from '@gravity-ui/icons';
4-
import {
5-
ActionTooltip,
6-
Button,
7-
HelpMark,
8-
Hotkey,
9-
Icon,
10-
Menu,
11-
Popover,
12-
Popup,
13-
} from '@gravity-ui/uikit';
4+
import {ActionTooltip, Button, HelpMark, Hotkey, Icon, Menu, Popover} from '@gravity-ui/uikit';
145

156
import {SelectPopup} from '../bundle/SelectPopup';
167
import {cn} from '../classname';
@@ -110,7 +101,12 @@ export function ToolbarListButton<E>({
110101
</Button>
111102
</ActionTooltip>
112103
</Popover>
113-
<SelectPopup mobile={mobile} open={popupOpen} onClose={hide} buttonRef={anchorElement}>
104+
<SelectPopup
105+
mobile={mobile}
106+
open={popupOpen}
107+
onClose={hide}
108+
anchorElement={anchorElement}
109+
>
114110
<Menu size="l" className={b('menu')}>
115111
{data
116112
.map((data) => {
@@ -132,9 +128,7 @@ export function ToolbarListButton<E>({
132128

133129
const disabled = !isEnable(editor);
134130

135-
const hideHintWhenDisabled =
136-
mobile || hintWhenDisabled === false || !disabled;
137-
131+
const hideHintWhenDisabled = hintWhenDisabled === false || !disabled;
138132
const hintWhenDisabledText =
139133
typeof hintWhenDisabled === 'string'
140134
? hintWhenDisabled
@@ -169,7 +163,7 @@ export function ToolbarListButton<E>({
169163
key={id}
170164
>
171165
{(props, ref) => (
172-
<PreviewTooltip preview={preview}>
166+
<PreviewTooltip preview={preview} mobile>
173167
<Menu.Item
174168
key={id}
175169
ref={ref}
@@ -186,17 +180,19 @@ export function ToolbarListButton<E>({
186180
>
187181
<div className={b('item')}>
188182
{titleText}
189-
<div className={b('extra')}>
190-
{hotkey && <Hotkey value={hotkey} />}
191-
{hintText && (
192-
<HelpMark
193-
className={b('hint')}
194-
popoverProps={{modal: false}}
195-
>
196-
{hintText}
197-
</HelpMark>
198-
)}
199-
</div>
183+
{!mobile && (
184+
<div className={b('extra')}>
185+
{hotkey && <Hotkey value={hotkey} />}
186+
{hintText && (
187+
<HelpMark
188+
className={b('hint')}
189+
popoverProps={{modal: false}}
190+
>
191+
{hintText}
192+
</HelpMark>
193+
)}
194+
</div>
195+
)}
200196
</div>
201197
</Menu.Item>
202198
</PreviewTooltip>

0 commit comments

Comments
 (0)