From 728e7c3b266d5a9c881c1ce7b335fa6dd32a1a0c Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 14 May 2022 11:09:41 -0500 Subject: [PATCH] settings: change tooltips to help buttons This is more friendly for touch screen users. --- src/settings/Settings.tsx | 134 +++++++++++++++++------------- src/settings/i18n.ts | 20 +++-- src/settings/settings.scss | 13 ++- src/settings/translations/en.json | 32 ++++--- 4 files changed, 121 insertions(+), 78 deletions(-) diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 1fd4d206..7447965c 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -7,25 +7,26 @@ import { ButtonGroup, ControlGroup, FormGroup, + IRef, Icon, InputGroup, Intent, Label, Switch, } from '@blueprintjs/core'; -import { Tooltip2 } from '@blueprintjs/popover2'; +import { Classes as Classes2, Popover2 } from '@blueprintjs/popover2'; import { useI18n } from '@shopify/react-i18n'; -import React, { useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { useDispatch } from 'react-redux'; import { useTernaryDarkMode } from 'usehooks-ts'; import AboutDialog from '../about/AboutDialog'; import { appCheckForUpdate, appReload, appShowInstallPrompt } from '../app/actions'; import { + appName, pybricksBugReportsUrl, pybricksGitterUrl, pybricksProjectsUrl, pybricksSupportUrl, - tooltipDelay, } from '../app/constants'; import { pseudolocalize } from '../i18n'; import { useSelector } from '../reducers'; @@ -39,6 +40,43 @@ import { import { I18nId } from './i18n'; import './settings.scss'; +type HelpButtonProps = { + label: string; + content: string | JSX.Element; +}; + +const HelpButton: React.VoidFunctionComponent = ({ + label, + content, +}) => { + const handleOpening = useCallback((node: HTMLElement) => { + // role must match aria-haspopup + node.setAttribute('role', 'dialog'); + }, []); + + return ( + ( +