A local-first personal finance app
[AI] Add tooltips to titlebar theme, privacy, and server status icons (#8440)
tabedzki1dbe1b78a14a
diff --git a/packages/desktop-client/src/components/LoggedInUser.tsx b/packages/desktop-client/src/components/LoggedInUser.tsxindex 81e531be05..5bee1aec98 100644--- a/packages/desktop-client/src/components/LoggedInUser.tsx+++ b/packages/desktop-client/src/components/LoggedInUser.tsx@@ -9,6 +9,7 @@ import { Popover } from '@actual-app/components/popover';import { styles } from '@actual-app/components/styles';import { Text } from '@actual-app/components/text';import { theme } from '@actual-app/components/theme';+import { Tooltip } from '@actual-app/components/tooltip';import { View } from '@actual-app/components/view';import { listen } from '@actual-app/core/platform/client/connection';import type { RemoteFile, SyncedLocalFile } from '@actual-app/core/types/file';@@ -127,16 +128,40 @@ export function LoggedInUser({ hideIfNoServer, style }: LoggedInUserProps) {}};- function serverMessage() {+ function getServerStatus() {if (!serverUrl) {- return t('No server');+ return {+ message: t('No server'),+ tooltip: (+ <Trans>+ A server syncs your budget across devices and keeps a backup of your+ data.+ <br />+ Click to set one up.+ </Trans>+ ),+ };}if (userData?.offline) {- return t('Server offline');+ return {+ message: t('Server offline'),+ tooltip: (+ <Trans>+ Can't reach your server right now.+ <br />+ Changes are saved locally and will sync once it's reachable again.+ </Trans>+ ),+ };}- return t('Server online');+ return {+ message: t('Server online'),+ tooltip: (+ <Trans>Connected to your server — your budget is syncing.</Trans>+ ),+ };}if (hideIfNoServer && !serverUrl) return null;@@ -215,11 +240,23 @@ export function LoggedInUser({ hideIfNoServer, style }: LoggedInUserProps) {return [...adminMenu, ...baseMenu];};+ const serverStatus = getServerStatus();+return (<View style={{ flexDirection: 'row', alignItems: 'center', ...style }}>- <Button ref={triggerRef} variant="bare" onPress={() => setMenuOpen(true)}>- {serverMessage()}- </Button>+ <Tooltip+ placement="bottom end"+ content={serverStatus.tooltip}+ triggerProps={{ isDisabled: menuOpen }}+ >+ <Button+ ref={triggerRef}+ variant="bare"+ onPress={() => setMenuOpen(true)}+ >+ {serverStatus.message}+ </Button>+ </Tooltip>{!loading &&multiuserEnabled &&userData &&diff --git a/packages/desktop-client/src/components/ThemeSelector.tsx b/packages/desktop-client/src/components/ThemeSelector.tsxindex 595e189d7e..7864099545 100644--- a/packages/desktop-client/src/components/ThemeSelector.tsx+++ b/packages/desktop-client/src/components/ThemeSelector.tsx@@ -1,6 +1,6 @@import React, { useRef, useState } from 'react';import type { CSSProperties } from 'react';-import { useTranslation } from 'react-i18next';+import { Trans, useTranslation } from 'react-i18next';import { Button } from '@actual-app/components/button';import { useResponsive } from '@actual-app/components/hooks/useResponsive';@@ -11,6 +11,7 @@ import {} from '@actual-app/components/icons/v2';import { Menu } from '@actual-app/components/menu';import { Popover } from '@actual-app/components/popover';+import { Tooltip } from '@actual-app/components/tooltip';import type { Theme } from '@actual-app/core/types/prefs';import { themeOptions, useTheme } from '#style';@@ -49,15 +50,21 @@ export function ThemeSelector({ style }: ThemeSelectorProps) {return (<>- <Button- ref={triggerRef}- variant="bare"- aria-label={t('Switch theme')}- onPress={() => setMenuOpen(true)}- style={style}+ <Tooltip+ placement="bottom end"+ content={<Trans>Switch theme</Trans>}+ triggerProps={{ isDisabled: menuOpen }}>- <Icon style={{ width: 13, height: 13, color: 'inherit' }} />- </Button>+ <Button+ ref={triggerRef}+ variant="bare"+ aria-label={t('Switch theme')}+ onPress={() => setMenuOpen(true)}+ style={style}+ >+ <Icon style={{ width: 13, height: 13, color: 'inherit' }} />+ </Button>+ </Tooltip><Popoveroffset={8}diff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsxindex 2257a1e7ea..723d9ab096 100644--- a/packages/desktop-client/src/components/Titlebar.tsx+++ b/packages/desktop-client/src/components/Titlebar.tsx@@ -17,6 +17,7 @@ import type { CSSProperties } from '@actual-app/components/styles';import { styles } from '@actual-app/components/styles';import { Text } from '@actual-app/components/text';import { theme } from '@actual-app/components/theme';+import { Tooltip } from '@actual-app/components/tooltip';import { View } from '@actual-app/components/view';import { listen } from '@actual-app/core/platform/client/connection';import { isDevelopmentEnvironment } from '@actual-app/core/shared/environment';@@ -89,20 +90,33 @@ function PrivacyButton({ style }: PrivacyButtonProps) {);return (- <Button- variant="bare"- aria-label={- isPrivacyEnabled ? t('Disable privacy mode') : t('Enable privacy mode')+ <Tooltip+ placement="bottom end"+ content={+ isPrivacyEnabled ? (+ <Trans>Disable privacy mode</Trans>+ ) : (+ <Trans>Enable privacy mode</Trans>+ )}- onPress={() => setPrivacyEnabledPref(String(!isPrivacyEnabled))}- style={style}>- {isPrivacyEnabled ? (- <SvgViewHide style={privacyIconStyle} />- ) : (- <SvgViewShow style={privacyIconStyle} />- )}- </Button>+ <Button+ variant="bare"+ aria-label={+ isPrivacyEnabled+ ? t('Disable privacy mode')+ : t('Enable privacy mode')+ }+ onPress={() => setPrivacyEnabledPref(String(!isPrivacyEnabled))}+ style={style}+ >+ {isPrivacyEnabled ? (+ <SvgViewHide style={privacyIconStyle} />+ ) : (+ <SvgViewShow style={privacyIconStyle} />+ )}+ </Button>+ </Tooltip>);}@@ -210,44 +224,62 @@ function ServerSyncButton({ style, isMobile = false }: ServerSyncButtonProps) {[onSync],);+ const tooltipContent =+ syncState === 'error' ? (+ <Trans>Sync error — click to retry</Trans>+ ) : syncState === 'offline' ? (+ <Trans>Offline — will sync when reconnected</Trans>+ ) : syncState === 'local' ? (+ <Trans>Local file, not connected to a server</Trans>+ ) : syncState === 'disabled' ? (+ <Trans>Syncing disabled for this file</Trans>+ ) : (+ <Trans>+ Sync with your server to back up this file and access it on other+ devices+ </Trans>+ );+return (- <Button- variant="bare"- aria-label={t('Server Sync')}- className={css({- ...(isMobile- ? {- ...style,- WebkitAppRegion: 'none',- ...mobileIconStyle,- }- : {- ...style,- WebkitAppRegion: 'none',- color: desktopColor,- }),- '&[data-hovered]': hoveredStyle,- '&[data-pressed]': activeStyle,- })}- onPress={onSync}- isDisabled={syncState === 'offline'}- aria-disabled={syncState === 'offline'}- >- {isMobile ? (- syncState === 'error' ? (- <SvgAlertTriangle width={14} height={14} />+ <Tooltip placement="bottom end" content={tooltipContent}>+ <Button+ variant="bare"+ aria-label={t('Server Sync')}+ className={css({+ ...(isMobile+ ? {+ ...style,+ WebkitAppRegion: 'none',+ ...mobileIconStyle,+ }+ : {+ ...style,+ WebkitAppRegion: 'none',+ color: desktopColor,+ }),+ '&[data-hovered]': hoveredStyle,+ '&[data-pressed]': activeStyle,+ })}+ onPress={onSync}+ isDisabled={syncState === 'offline'}+ aria-disabled={syncState === 'offline'}+ >+ {isMobile ? (+ syncState === 'error' ? (+ <SvgAlertTriangle width={14} height={14} />+ ) : (+ <AnimatedRefresh width={18} height={18} animating={syncing} />+ )+ ) : syncState === 'error' ? (+ <SvgAlertTriangle width={13} />) : (- <AnimatedRefresh width={18} height={18} animating={syncing} />- )- ) : syncState === 'error' ? (- <SvgAlertTriangle width={13} />- ) : (- <AnimatedRefresh animating={syncing} />- )}- <Text style={isMobile ? { ...mobileTextStyle } : null}>- {syncState === 'disabled' ? ` ${t('Disabled')}` : null}- </Text>- </Button>+ <AnimatedRefresh animating={syncing} />+ )}+ <Text style={isMobile ? { ...mobileTextStyle } : null}>+ {syncState === 'disabled' ? ` ${t('Disabled')}` : null}+ </Text>+ </Button>+ </Tooltip>);}diff --git a/upcoming-release-notes/adding-tooltip-to-title-icons.md b/upcoming-release-notes/adding-tooltip-to-title-icons.mdnew file mode 100644index 0000000000..8083f7567b--- /dev/null+++ b/upcoming-release-notes/adding-tooltip-to-title-icons.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [tabedzki]+---++Add tooltips to the theme, privacy, and server status icons in the top bar