From 9be6ba3640443a5d4066d776a87903c7f7113604 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 21 Dec 2021 18:07:42 -0600 Subject: [PATCH] update to Tooltip2 Tooltip has been deprecated so trying out the new Tooltip2. --- src/settings/SettingsDrawer.tsx | 43 ++++++++++++----------- src/toolbar/ActionButton.tsx | 61 ++++++++++++++++++--------------- src/toolbar/OpenFileButton.tsx | 56 ++++++++++++++++-------------- 3 files changed, 85 insertions(+), 75 deletions(-) diff --git a/src/settings/SettingsDrawer.tsx b/src/settings/SettingsDrawer.tsx index 50f92a86..85221b76 100644 --- a/src/settings/SettingsDrawer.tsx +++ b/src/settings/SettingsDrawer.tsx @@ -13,11 +13,10 @@ import { InputGroup, Intent, Label, - Position, Switch, - Tooltip, useHotkeys, } from '@blueprintjs/core'; +import { Tooltip2 } from '@blueprintjs/popover2'; import { useI18n } from '@shopify/react-i18n'; import React, { useMemo, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; @@ -117,12 +116,12 @@ const SettingsDrawer: React.FunctionComponent = (props) => { }, )} > - @@ -140,13 +139,13 @@ const SettingsDrawer: React.FunctionComponent = (props) => { ) } /> - - + @@ -164,15 +163,15 @@ const SettingsDrawer: React.FunctionComponent = (props) => { ) } /> - + - @@ -190,14 +189,14 @@ const SettingsDrawer: React.FunctionComponent = (props) => { ) } /> - + - @@ -209,7 +208,7 @@ const SettingsDrawer: React.FunctionComponent = (props) => { SettingsStringId.FirmwareHubNameLabel, )} - + = (props) => { placeholder="Pybricks Hub" rightElement={ isHubNameValid ? undefined : ( - = (props) => { intent={Intent.DANGER} itemType="div" /> - + ) } /> diff --git a/src/toolbar/ActionButton.tsx b/src/toolbar/ActionButton.tsx index 269fcda4..41e75573 100644 --- a/src/toolbar/ActionButton.tsx +++ b/src/toolbar/ActionButton.tsx @@ -1,14 +1,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020-2021 The Pybricks Authors -import { - Button, - Intent, - Position, - Spinner, - Tooltip, - useHotkeys, -} from '@blueprintjs/core'; +import { Button, IRef, Intent, Spinner, useHotkeys } from '@blueprintjs/core'; +import { Tooltip2 } from '@blueprintjs/popover2'; import { useI18n } from '@shopify/react-i18n'; import React, { useMemo, useRef } from 'react'; import { tooltipDelay } from '../app/constants'; @@ -76,27 +70,40 @@ const ActionButton: React.FC = (props) => { useHotkeys(hotkeys); return ( - - - + renderTarget={({ + ref: tooltipRef, + isOpen: _tooltipIsOpen, + ...tooltipProps + }) => ( + + )} + /> ); }; diff --git a/src/toolbar/OpenFileButton.tsx b/src/toolbar/OpenFileButton.tsx index fa7dffbf..fd3ec3af 100644 --- a/src/toolbar/OpenFileButton.tsx +++ b/src/toolbar/OpenFileButton.tsx @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020-2021 The Pybricks Authors -import { Button, Intent, Position, Spinner, Tooltip } from '@blueprintjs/core'; +import { Button, IRef, Intent, Spinner } from '@blueprintjs/core'; +import { Tooltip2 } from '@blueprintjs/popover2'; import { useI18n } from '@shopify/react-i18n'; import React from 'react'; import Dropzone from 'react-dropzone'; @@ -47,7 +48,6 @@ const OpenFileButton: React.FC = (props) => { accept={props.fileExtension} multiple={false} noClick={props.onClick !== undefined} - noKeyboard={props.onClick !== undefined} onDropAccepted={(acceptedFiles) => { // should only be one file since multiple={false} acceptedFiles.forEach((f) => { @@ -78,7 +78,7 @@ const OpenFileButton: React.FC = (props) => { }} > {({ getRootProps, getInputProps }): JSX.Element => ( - = (props) => { } : undefined, )} - position={Position.BOTTOM} + placement="bottom" hoverOpenDelay={tooltipDelay} - > -
+ renderTarget={({ + ref: tooltipRef, + isOpen: _tooltipIsOpen, + ...tooltipProps + }) => ( -
-
+ )} + /> )} );