Skip to content

A local-first personal finance app

:recycle: (components) refactor useResponsive and move to comp. lib (#4568)

Matiss Janis Aboltinsebb83aca5156
diff --git a/packages/component-library/package.json b/packages/component-library/package.json
index efd49b5d00..27ca3e2079 100644
--- a/packages/component-library/package.json
+++ b/packages/component-library/package.json
@@ -7,7 +7,8 @@
},
"dependencies": {
"@emotion/css": "^11.13.4",
- "react-aria-components": "^1.7.0"
+ "react-aria-components": "^1.7.0",
+ "usehooks-ts": "^3.0.1"
},
"devDependencies": {
"@svgr/cli": "^8.1.0",
@@ -15,6 +16,7 @@
"react": "18.2.0"
},
"exports": {
+ "./hooks/*": "./src/hooks/*.ts",
"./icons/logo": "./src/icons/logo/index.ts",
"./icons/v0": "./src/icons/v0/index.ts",
"./icons/v1": "./src/icons/v1/index.ts",
diff --git a/packages/component-library/src/hooks/useResponsive.ts b/packages/component-library/src/hooks/useResponsive.ts
new file mode 100644
index 0000000000..9ca85a6673
--- /dev/null
+++ b/packages/component-library/src/hooks/useResponsive.ts
@@ -0,0 +1,23 @@
+import { useWindowSize } from 'usehooks-ts';
+
+import { breakpoints } from '../tokens';
+
+export function useResponsive() {
+ const { height, width } = useWindowSize({
+ debounceDelay: 250,
+ });
+
+ // Possible view modes: narrow, small, medium, wide
+ // To check if we're at least small width, check !isNarrowWidth
+ return {
+ // atLeastMediumWidth is provided to avoid checking (isMediumWidth || isWideWidth)
+ atLeastMediumWidth: width >= breakpoints.medium,
+ isNarrowWidth: width < breakpoints.small,
+ isSmallWidth: width >= breakpoints.small && width < breakpoints.medium,
+ isMediumWidth: width >= breakpoints.medium && width < breakpoints.wide,
+ // No atLeastWideWidth because that's identical to isWideWidth
+ isWideWidth: width >= breakpoints.wide,
+ height,
+ width,
+ };
+}
diff --git a/packages/desktop-client/src/components/App.tsx b/packages/desktop-client/src/components/App.tsx
index 4e5079773c..1640fd7a11 100644
--- a/packages/desktop-client/src/components/App.tsx
+++ b/packages/desktop-client/src/components/App.tsx
@@ -37,7 +37,6 @@ import { FatalError } from './FatalError';
import { FinancesApp } from './FinancesApp';
import { ManagementApp } from './manager/ManagementApp';
import { Modals } from './Modals';
-import { ResponsiveProvider } from './responsive/ResponsiveProvider';
import { SidebarProvider } from './sidebar/SidebarProvider';
import { UpdateNotification } from './UpdateNotification';
@@ -207,44 +206,40 @@ export function App() {
<BrowserRouter>
<ExposeNavigate />
<HotkeysProvider initiallyActiveScopes={['*']}>
- <ResponsiveProvider>
- <SpreadsheetProvider>
- <SidebarProvider>
- <BudgetMonthCountProvider>
- <DndProvider backend={HTML5Backend}>
+ <SpreadsheetProvider>
+ <SidebarProvider>
+ <BudgetMonthCountProvider>
+ <DndProvider backend={HTML5Backend}>
+ <View
+ data-theme={theme}
+ style={{
+ height: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ }}
+ >
<View
- data-theme={theme}
+ key={hiddenScrollbars ? 'hidden-scrollbars' : 'scrollbars'}
style={{
- height: '100%',
- display: 'flex',
- flexDirection: 'column',
+ flexGrow: 1,
+ overflow: 'hidden',
+ ...styles.lightScrollbar,
}}
>
- <View
- key={
- hiddenScrollbars ? 'hidden-scrollbars' : 'scrollbars'
- }
- style={{
- flexGrow: 1,
- overflow: 'hidden',
- ...styles.lightScrollbar,
- }}
- >
- <ErrorBoundary FallbackComponent={ErrorFallback}>
- {process.env.REACT_APP_REVIEW_ID &&
- !Platform.isPlaywright && <DevelopmentTopBar />}
- <AppInner />
- </ErrorBoundary>
- <ThemeStyle />
- <Modals />
- <UpdateNotification />
- </View>
+ <ErrorBoundary FallbackComponent={ErrorFallback}>
+ {process.env.REACT_APP_REVIEW_ID &&
+ !Platform.isPlaywright && <DevelopmentTopBar />}
+ <AppInner />
+ </ErrorBoundary>
+ <ThemeStyle />
+ <Modals />
+ <UpdateNotification />
</View>
- </DndProvider>
- </BudgetMonthCountProvider>
- </SidebarProvider>
- </SpreadsheetProvider>
- </ResponsiveProvider>
+ </View>
+ </DndProvider>
+ </BudgetMonthCountProvider>
+ </SidebarProvider>
+ </SpreadsheetProvider>
</HotkeysProvider>
</BrowserRouter>
);
diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx
index 071ce50330..214235a9c0 100644
--- a/packages/desktop-client/src/components/FinancesApp.tsx
+++ b/packages/desktop-client/src/components/FinancesApp.tsx
@@ -9,6 +9,8 @@ import {
useHref,
} from 'react-router-dom';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { sync } from 'loot-core/client/app/appSlice';
@@ -22,7 +24,6 @@ import { useLocalPref } from '../hooks/useLocalPref';
import { useMetaThemeColor } from '../hooks/useMetaThemeColor';
import { useNavigate } from '../hooks/useNavigate';
import { useSelector, useDispatch } from '../redux';
-import { theme } from '../style';
import { getIsOutdated, getLatestVersion } from '../util/versions';
import { UserAccessPage } from './admin/UserAccess/UserAccessPage';
@@ -38,7 +39,6 @@ import { ManagePayeesPage } from './payees/ManagePayeesPage';
import { Reports } from './reports';
import { LoadingIndicator } from './reports/LoadingIndicator';
import { NarrowAlternate, WideComponent } from './responsive';
-import { useResponsive } from './responsive/ResponsiveProvider';
import { UserDirectoryPage } from './responsive/wide';
import { ScrollProvider } from './ScrollProvider';
import { useMultiuserEnabled } from './ServerContext';
diff --git a/packages/desktop-client/src/components/Notes.tsx b/packages/desktop-client/src/components/Notes.tsx
index 2fd4af9b8c..a8f9407756 100644
--- a/packages/desktop-client/src/components/Notes.tsx
+++ b/packages/desktop-client/src/components/Notes.tsx
@@ -3,15 +3,15 @@ import React, { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import ReactMarkdown from 'react-markdown';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { type CSSProperties } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { css } from '@emotion/css';
import remarkGfm from 'remark-gfm';
-import { type CSSProperties, theme } from '../style';
import { remarkBreaks, sequentialNewlinesPlugin } from '../util/markdown';
-import { useResponsive } from './responsive/ResponsiveProvider';
-
const remarkPlugins = [sequentialNewlinesPlugin, remarkGfm, remarkBreaks];
const markdownStyles = css({
diff --git a/packages/desktop-client/src/components/Notifications.tsx b/packages/desktop-client/src/components/Notifications.tsx
index faa6cb002a..7d7f9c7041 100644
--- a/packages/desktop-client/src/components/Notifications.tsx
+++ b/packages/desktop-client/src/components/Notifications.tsx
@@ -9,9 +9,13 @@ import React, {
import { useTranslation } from 'react-i18next';
import { Button, ButtonWithLoading } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading';
+import { SvgDelete } from '@actual-app/components/icons/v0';
import { Stack } from '@actual-app/components/stack';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
@@ -20,13 +24,9 @@ import {
type NotificationWithId,
} from 'loot-core/client/notifications/notificationsSlice';
-import { AnimatedLoading } from '../icons/AnimatedLoading';
-import { SvgDelete } from '../icons/v0';
import { useSelector, useDispatch } from '../redux';
-import { theme } from '../style';
import { Link } from './common/Link';
-import { useResponsive } from './responsive/ResponsiveProvider';
function compileMessage(
message: string,
diff --git a/packages/desktop-client/src/components/Page.tsx b/packages/desktop-client/src/components/Page.tsx
index 4683dab9a8..89920cea6a 100644
--- a/packages/desktop-client/src/components/Page.tsx
+++ b/packages/desktop-client/src/components/Page.tsx
@@ -1,13 +1,11 @@
import React, { type ReactNode, type CSSProperties } from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { theme } from '../style';
-
-import { useResponsive } from './responsive/ResponsiveProvider';
-
const HEADER_HEIGHT = 50;
type PageHeaderProps = {
diff --git a/packages/desktop-client/src/components/PrivacyFilter.tsx b/packages/desktop-client/src/components/PrivacyFilter.tsx
index 80998adc3b..4b26172756 100644
--- a/packages/desktop-client/src/components/PrivacyFilter.tsx
+++ b/packages/desktop-client/src/components/PrivacyFilter.tsx
@@ -5,13 +5,12 @@ import React, {
type ReactNode,
} from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
import { usePrivacyMode } from '../hooks/usePrivacyMode';
-import { useResponsive } from './responsive/ResponsiveProvider';
-
type ConditionalPrivacyFilterProps = {
children: ReactNode;
privacyFilter?: boolean | PrivacyFilterProps;
diff --git a/packages/desktop-client/src/components/ThemeSelector.tsx b/packages/desktop-client/src/components/ThemeSelector.tsx
index 659158b1a3..3a57796645 100644
--- a/packages/desktop-client/src/components/ThemeSelector.tsx
+++ b/packages/desktop-client/src/components/ThemeSelector.tsx
@@ -2,16 +2,19 @@ import React, { useRef, useState, type CSSProperties } from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import {
+ SvgMoonStars,
+ SvgSun,
+ SvgSystem,
+} from '@actual-app/components/icons/v2';
import { Menu } from '@actual-app/components/menu';
import { Popover } from '@actual-app/components/popover';
import type { Theme } from 'loot-core/types/prefs';
-import { SvgMoonStars, SvgSun, SvgSystem } from '../icons/v2';
import { themeOptions, useTheme } from '../style';
-import { useResponsive } from './responsive/ResponsiveProvider';
-
type ThemeSelectorProps = {
style?: CSSProperties;
};
diff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsx
index ebddb91132..510fae8095 100644
--- a/packages/desktop-client/src/components/Titlebar.tsx
+++ b/packages/desktop-client/src/components/Titlebar.tsx
@@ -4,9 +4,18 @@ import { useTranslation } from 'react-i18next';
import { Routes, Route, useLocation } from 'react-router-dom';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgArrowLeft } from '@actual-app/components/icons/v1';
+import {
+ SvgAlertTriangle,
+ SvgNavigationMenu,
+ SvgViewHide,
+ SvgViewShow,
+} from '@actual-app/components/icons/v2';
import { SpaceBetween } from '@actual-app/components/space-between';
-import { styles } from '@actual-app/components/styles';
+import { styles, type CSSProperties } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
@@ -23,15 +32,7 @@ import { useGlobalPref } from '../hooks/useGlobalPref';
import { useMetadataPref } from '../hooks/useMetadataPref';
import { useNavigate } from '../hooks/useNavigate';
import { useSyncedPref } from '../hooks/useSyncedPref';
-import { SvgArrowLeft } from '../icons/v1';
-import {
- SvgAlertTriangle,
- SvgNavigationMenu,
- SvgViewHide,
- SvgViewShow,
-} from '../icons/v2';
import { useDispatch } from '../redux';
-import { theme, type CSSProperties } from '../style';
import { AccountSyncCheck } from './accounts/AccountSyncCheck';
import { AnimatedRefresh } from './AnimatedRefresh';
@@ -39,7 +40,6 @@ import { MonthCountSelector } from './budget/MonthCountSelector';
import { Link } from './common/Link';
import { HelpMenu } from './HelpMenu';
import { LoggedInUser } from './LoggedInUser';
-import { useResponsive } from './responsive/ResponsiveProvider';
import { useServerURL } from './ServerContext';
import { useSidebar } from './sidebar/SidebarProvider';
import { useSheetValue } from './spreadsheet/useSheetValue';
diff --git a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx
index a4786f9576..ed54a4121e 100644
--- a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx
@@ -8,16 +8,16 @@ import React, {
} from 'react';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { styles } from '@actual-app/components/styles';
import { TextOneLine } from '@actual-app/components/text-one-line';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css, cx } from '@emotion/css';
import { type AccountEntity } from 'loot-core/types/models';
import { useAccounts } from '../../hooks/useAccounts';
-import { theme } from '../../style';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { Autocomplete } from './Autocomplete';
import { ItemHeader } from './ItemHeader';
diff --git a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
index d0bae776c3..500e852239 100644
--- a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
@@ -12,7 +12,9 @@ import React, {
} from 'react';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { SvgRemove } from '@actual-app/components/icons/v2';
+import { Input } from '@actual-app/components/input';
import { Popover } from '@actual-app/components/popover';
import { styles } from '@actual-app/components/styles';
import { theme } from '@actual-app/components/theme';
@@ -22,9 +24,6 @@ import Downshift, { type StateChangeTypes } from 'downshift';
import { getNormalisedString } from 'loot-core/shared/normalisation';
-import { Input } from '../common/Input';
-import { useResponsive } from '../responsive/ResponsiveProvider';
-
type CommonAutocompleteProps<T extends Item> = {
focused?: boolean;
embedded?: boolean;
diff --git a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx
index 913a7bc19a..da45f0454f 100644
--- a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx
@@ -12,9 +12,12 @@ import React, {
} from 'react';
import { Trans, useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgSplit } from '@actual-app/components/icons/v0';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
import { TextOneLine } from '@actual-app/components/text-one-line';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css, cx } from '@emotion/css';
@@ -28,11 +31,8 @@ import {
import { useCategories } from '../../hooks/useCategories';
import { useSyncedPref } from '../../hooks/useSyncedPref';
-import { SvgSplit } from '../../icons/v0';
-import { theme } from '../../style';
import { useEnvelopeSheetValue } from '../budget/envelope/EnvelopeBudgetComponents';
import { makeAmountFullStyle } from '../budget/util';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { useSheetValue } from '../spreadsheet/useSheetValue';
import { Autocomplete, defaultFilterSuggestion } from './Autocomplete';
diff --git a/packages/desktop-client/src/components/autocomplete/ItemHeader.tsx b/packages/desktop-client/src/components/autocomplete/ItemHeader.tsx
index 18cbb9c9ed..9c4d2bc85f 100644
--- a/packages/desktop-client/src/components/autocomplete/ItemHeader.tsx
+++ b/packages/desktop-client/src/components/autocomplete/ItemHeader.tsx
@@ -1,9 +1,8 @@
import React, { type CSSProperties } from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { styles } from '@actual-app/components/styles';
-
-import { theme } from '../../style';
-import { useResponsive } from '../responsive/ResponsiveProvider';
+import { theme } from '@actual-app/components/theme';
type ItemHeaderProps = {
title: string;
diff --git a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.test.tsx b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.test.tsx
index 10c16b5101..0aed8ad636 100644
--- a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.test.tsx
+++ b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.test.tsx
@@ -8,7 +8,6 @@ import type { AccountEntity, PayeeEntity } from 'loot-core/types/models';
import { AuthProvider } from '../../auth/AuthProvider';
import { useCommonPayees } from '../../hooks/usePayees';
import { TestProvider } from '../../redux/mock';
-import { ResponsiveProvider } from '../responsive/ResponsiveProvider';
import {
PayeeAutocomplete,
@@ -65,17 +64,15 @@ function renderPayeeAutocomplete(
render(
<TestProvider>
<AuthProvider>
- <ResponsiveProvider>
- <div data-testid="autocomplete-test">
- <PayeeAutocomplete
- {...autocompleteProps}
- onSelect={vi.fn()}
- type="single"
- value={null}
- embedded={false}
- />
- </div>
- </ResponsiveProvider>
+ <div data-testid="autocomplete-test">
+ <PayeeAutocomplete
+ {...autocompleteProps}
+ onSelect={vi.fn()}
+ type="single"
+ value={null}
+ embedded={false}
+ />
+ </div>
</AuthProvider>
</TestProvider>,
);
diff --git a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx
index 08004002d0..96e2d70158 100644
--- a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx
@@ -14,8 +14,11 @@ import React, {
import { Trans, useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgAdd, SvgBookmark } from '@actual-app/components/icons/v1';
import { styles } from '@actual-app/components/styles';
import { TextOneLine } from '@actual-app/components/text-one-line';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css, cx } from '@emotion/css';
@@ -28,10 +31,7 @@ import { type AccountEntity, type PayeeEntity } from 'loot-core/types/models';
import { useAccounts } from '../../hooks/useAccounts';
import { useCommonPayees, usePayees } from '../../hooks/usePayees';
-import { SvgAdd, SvgBookmark } from '../../icons/v1';
import { useDispatch } from '../../redux';
-import { theme } from '../../style';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import {
Autocomplete,
diff --git a/packages/desktop-client/src/components/banksync/index.tsx b/packages/desktop-client/src/components/banksync/index.tsx
index 4cd735e210..4f139f8b25 100644
--- a/packages/desktop-client/src/components/banksync/index.tsx
+++ b/packages/desktop-client/src/components/banksync/index.tsx
@@ -1,6 +1,7 @@
import { useMemo, useState, useCallback } from 'react';
import { Trans, useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Text } from '@actual-app/components/text';
import { View } from '@actual-app/components/view';
@@ -15,7 +16,6 @@ import { useGlobalPref } from '../../hooks/useGlobalPref';
import { useDispatch } from '../../redux';
import { MOBILE_NAV_HEIGHT } from '../mobile/MobileNavTabs';
import { Page } from '../Page';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { AccountsHeader } from './AccountsHeader';
import { AccountsList } from './AccountsList';
diff --git a/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx b/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
index 298ad7a2a9..8a374c093d 100644
--- a/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
+++ b/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
@@ -7,7 +7,10 @@ import React, {
} from 'react';
import { useTranslation, Trans } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgArrowThinRight } from '@actual-app/components/icons/v1';
import { styles } from '@actual-app/components/styles';
+import { theme } from '@actual-app/components/theme';
import { Tooltip } from '@actual-app/components/tooltip';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
@@ -15,9 +18,6 @@ import { css } from '@emotion/css';
import { type TransObjectLiteral } from 'loot-core/types/util';
import { useFeatureFlag } from '../../hooks/useFeatureFlag';
-import { SvgArrowThinRight } from '../../icons/v1';
-import { theme } from '../../style';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { type Binding } from '../spreadsheet';
import { CellValue, CellValueText } from '../spreadsheet/CellValue';
import { useFormat } from '../spreadsheet/useFormat';
diff --git a/packages/desktop-client/src/components/common/Modal.tsx b/packages/desktop-client/src/components/common/Modal.tsx
index aad307e122..1b17f34432 100644
--- a/packages/desktop-client/src/components/common/Modal.tsx
+++ b/packages/desktop-client/src/components/common/Modal.tsx
@@ -17,7 +17,11 @@ import { useHotkeysContext } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading';
+import { SvgLogo } from '@actual-app/components/icons/logo';
+import { SvgDelete } from '@actual-app/components/icons/v0';
+import { Input } from '@actual-app/components/input';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
import { TextOneLine } from '@actual-app/components/text-one-line';
@@ -28,11 +32,6 @@ import { css } from '@emotion/css';
import { AutoTextSize } from 'auto-text-size';
import { useModalState } from '../../hooks/useModalState';
-import { SvgLogo } from '../../icons/logo';
-import { SvgDelete } from '../../icons/v0';
-import { useResponsive } from '../responsive/ResponsiveProvider';
-
-import { Input } from './Input';
type ModalProps = ComponentPropsWithRef<typeof ReactAriaModal> & {
name: string;
diff --git a/packages/desktop-client/src/components/manager/BudgetList.tsx b/packages/desktop-client/src/components/manager/BudgetList.tsx
index 9fab55ac19..b67f3e0620 100644
--- a/packages/desktop-client/src/components/manager/BudgetList.tsx
+++ b/packages/desktop-client/src/components/manager/BudgetList.tsx
@@ -8,10 +8,17 @@ import React, {
import { Trans, useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import {
+ SvgCloudUnknown,
+ SvgKey,
+ SvgRefreshArrow,
+} from '@actual-app/components/icons/v2';
import { Menu } from '@actual-app/components/menu';
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';
@@ -49,11 +56,8 @@ import {
SvgUser,
SvgUserGroup,
} from '../../icons/v1';
-import { SvgCloudUnknown, SvgKey, SvgRefreshArrow } from '../../icons/v2';
import { useSelector, useDispatch } from '../../redux';
-import { theme } from '../../style';
import { tokens } from '../../tokens';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { useMultiuserEnabled } from '../ServerContext';
function getFileDescription(file: File, t: (key: string) => string) {
diff --git a/packages/desktop-client/src/components/manager/ManagementApp.tsx b/packages/desktop-client/src/components/manager/ManagementApp.tsx
index 8be567824e..971f604de2 100644
--- a/packages/desktop-client/src/components/manager/ManagementApp.tsx
+++ b/packages/desktop-client/src/components/manager/ManagementApp.tsx
@@ -1,7 +1,9 @@
import React, { useEffect } from 'react';
import { Navigate, Route, Routes } from 'react-router-dom';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { loggedIn } from 'loot-core/client/actions';
@@ -11,7 +13,6 @@ import { ProtectedRoute } from '../../auth/ProtectedRoute';
import { Permissions } from '../../auth/types';
import { useMetaThemeColor } from '../../hooks/useMetaThemeColor';
import { useSelector, useDispatch } from '../../redux';
-import { theme } from '../../style';
import { tokens } from '../../tokens';
import {
BackToFileListButton,
@@ -20,7 +21,6 @@ import {
import { AppBackground } from '../AppBackground';
import { LoggedInUser } from '../LoggedInUser';
import { Notifications } from '../Notifications';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { useMultiuserEnabled, useServerVersion } from '../ServerContext';
import { BudgetList } from './BudgetList';
diff --git a/packages/desktop-client/src/components/manager/subscribe/Login.tsx b/packages/desktop-client/src/components/manager/subscribe/Login.tsx
index f8209db0ef..f4399359a6 100644
--- a/packages/desktop-client/src/components/manager/subscribe/Login.tsx
+++ b/packages/desktop-client/src/components/manager/subscribe/Login.tsx
@@ -4,7 +4,9 @@ import { Trans, useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { Button, ButtonWithLoading } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading';
+import { BigInput } from '@actual-app/components/input';
import { Label } from '@actual-app/components/label';
import { Select } from '@actual-app/components/select';
import { styles } from '@actual-app/components/styles';
@@ -19,9 +21,7 @@ import { type OpenIdConfig } from 'loot-core/types/models/openid';
import { useNavigate } from '../../../hooks/useNavigate';
import { useDispatch } from '../../../redux';
-import { BigInput } from '../../common/Input';
import { Link } from '../../common/Link';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { useAvailableLoginMethods, useLoginMethod } from '../../ServerContext';
import { useBootstrapped, Title } from './common';
diff --git a/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx b/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
index b6b4568d18..d45733c0c1 100644
--- a/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
+++ b/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';
import { NavLink } from 'react-router-dom';
import { useSpring, animated, config } from 'react-spring';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import {
SvgAdd,
SvgCog,
@@ -24,7 +25,6 @@ import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { useDrag } from '@use-gesture/react';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { useScrollListener } from '../ScrollProvider';
const COLUMN_COUNT = 3;
diff --git a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
index f281afca06..34671003c4 100644
--- a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
+++ b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx
@@ -3,9 +3,12 @@ import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
import { Card } from '@actual-app/components/card';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgCalendar, SvgViewShow } from '@actual-app/components/icons/v2';
import { Label } from '@actual-app/components/label';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
import { AutoTextSize } from 'auto-text-size';
@@ -35,15 +38,12 @@ import {
SvgArrowThickRight,
SvgCheveronRight,
} from '../../../icons/v1';
-import { SvgCalendar, SvgViewShow } from '../../../icons/v2';
import { useDispatch } from '../../../redux';
-import { theme } from '../../../style';
import { BalanceWithCarryover } from '../../budget/BalanceWithCarryover';
import { makeAmountGrey, makeBalanceAmountStyle } from '../../budget/util';
import { Link } from '../../common/Link';
import { MobilePageHeader, Page } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { CellValue } from '../../spreadsheet/CellValue';
import { useFormat } from '../../spreadsheet/useFormat';
import { useSheetValue } from '../../spreadsheet/useSheetValue';
diff --git a/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx
index a3aa10db41..c0bfeb3ccf 100644
--- a/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx
@@ -1,11 +1,12 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { type Modal as ModalType } from 'loot-core/client/modals/modalsSlice';
-import { theme } from '../../style';
import { AccountAutocomplete } from '../autocomplete/AccountAutocomplete';
import {
ModalCloseButton,
@@ -14,7 +15,6 @@ import {
ModalHeader,
} from '../common/Modal';
import { SectionLabel } from '../forms';
-import { useResponsive } from '../responsive/ResponsiveProvider';
type AccountAutocompleteModalProps = Extract<
ModalType,
diff --git a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx
index 16d9b371e1..09a9ffda7e 100644
--- a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx
@@ -1,12 +1,13 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { type Modal as ModalType } from 'loot-core/client/modals/modalsSlice';
import * as monthUtils from 'loot-core/shared/months';
-import { theme } from '../../style';
import { CategoryAutocomplete } from '../autocomplete/CategoryAutocomplete';
import {
ModalCloseButton,
@@ -15,7 +16,6 @@ import {
ModalHeader,
} from '../common/Modal';
import { SectionLabel } from '../forms';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { NamespaceContext } from '../spreadsheet/NamespaceContext';
type CategoryAutocompleteModalProps = Extract<
diff --git a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
index 3174e02736..e7e8de8d2f 100644
--- a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
@@ -5,9 +5,11 @@ import { useTranslation, Trans } from 'react-i18next';
import { Button } from '@actual-app/components/button';
import { FormError } from '@actual-app/components/form-error';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Paragraph } from '@actual-app/components/paragraph';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import {
@@ -22,12 +24,10 @@ import { type TransObjectLiteral } from 'loot-core/types/util';
import { useAccounts } from '../../hooks/useAccounts';
import { useCategories } from '../../hooks/useCategories';
import { useDispatch } from '../../redux';
-import { theme } from '../../style';
import { AccountAutocomplete } from '../autocomplete/AccountAutocomplete';
import { CategoryAutocomplete } from '../autocomplete/CategoryAutocomplete';
import { Link } from '../common/Link';
import { Modal, ModalCloseButton, ModalHeader } from '../common/Modal';
-import { useResponsive } from '../responsive/ResponsiveProvider';
function needsCategory(
account: AccountEntity,
diff --git a/packages/desktop-client/src/components/modals/ConfirmTransactionDeleteModal.tsx b/packages/desktop-client/src/components/modals/ConfirmTransactionDeleteModal.tsx
index 9766915f89..6ba8936ccc 100644
--- a/packages/desktop-client/src/components/modals/ConfirmTransactionDeleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/ConfirmTransactionDeleteModal.tsx
@@ -2,6 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { InitialFocus } from '@actual-app/components/initial-focus';
import { Paragraph } from '@actual-app/components/paragraph';
import { styles } from '@actual-app/components/styles';
@@ -10,7 +11,6 @@ import { View } from '@actual-app/components/view';
import { type Modal as ModalType } from 'loot-core/client/modals/modalsSlice';
import { Modal, ModalCloseButton, ModalHeader } from '../common/Modal';
-import { useResponsive } from '../responsive/ResponsiveProvider';
type ConfirmTransactionDeleteModalProps = Extract<
ModalType,
diff --git a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
index 9e7abb77e4..8267ad40df 100644
--- a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
@@ -4,10 +4,13 @@ import { Form } from 'react-aria-components';
import { useTranslation, Trans } from 'react-i18next';
import { ButtonWithLoading } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { InitialFocus } from '@actual-app/components/initial-focus';
+import { Input } from '@actual-app/components/input';
import { Paragraph } from '@actual-app/components/paragraph';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
@@ -19,8 +22,6 @@ import { send } from 'loot-core/platform/client/fetch';
import { getCreateKeyError } from 'loot-core/shared/errors';
import { useDispatch } from '../../redux';
-import { theme } from '../../style';
-import { Input } from '../common/Input';
import { Link } from '../common/Link';
import {
Modal,
@@ -28,7 +29,6 @@ import {
ModalCloseButton,
ModalHeader,
} from '../common/Modal';
-import { useResponsive } from '../responsive/ResponsiveProvider';
type CreateEncryptionKeyModalProps = Extract<
ModalType,
diff --git a/packages/desktop-client/src/components/modals/EditFieldModal.tsx b/packages/desktop-client/src/components/modals/EditFieldModal.tsx
index 0798bd8fdd..a1164dac98 100644
--- a/packages/desktop-client/src/components/modals/EditFieldModal.tsx
+++ b/packages/desktop-client/src/components/modals/EditFieldModal.tsx
@@ -7,6 +7,8 @@ import React, {
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { Input } from '@actual-app/components/input';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { parseISO, format as formatDate, parse as parseDate } from 'date-fns';
@@ -16,10 +18,8 @@ import { currentDay, dayFromDate } from 'loot-core/shared/months';
import { amountToInteger } from 'loot-core/shared/util';
import { useDateFormat } from '../../hooks/useDateFormat';
-import { Input } from '../common/Input';
import { Modal, ModalCloseButton, ModalHeader } from '../common/Modal';
import { SectionLabel } from '../forms';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { DateSelect } from '../select/DateSelect';
const itemStyle: CSSProperties = {
diff --git a/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx b/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx
index a891023e5c..b3487b93da 100644
--- a/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx
+++ b/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx
@@ -4,18 +4,19 @@ import { Form } from 'react-aria-components';
import { useTranslation } from 'react-i18next';
import { Button, ButtonWithLoading } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { InitialFocus } from '@actual-app/components/initial-focus';
+import { Input } from '@actual-app/components/input';
import { Paragraph } from '@actual-app/components/paragraph';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { type Modal as ModalType } from 'loot-core/client/modals/modalsSlice';
import { send } from 'loot-core/platform/client/fetch';
import { getTestKeyError } from 'loot-core/shared/errors';
-import { theme } from '../../style';
-import { Input } from '../common/Input';
import { Link } from '../common/Link';
import {
Modal,
@@ -23,7 +24,6 @@ import {
ModalCloseButton,
ModalHeader,
} from '../common/Modal';
-import { useResponsive } from '../responsive/ResponsiveProvider';
type FixEncryptionKeyModalProps = Extract<
ModalType,
diff --git a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
index 8b5ae47cab..455c53f031 100644
--- a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
@@ -1,12 +1,14 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { theme } from '@actual-app/components/theme';
+
import { type Modal as ModalType } from 'loot-core/client/modals/modalsSlice';
import { useAccounts } from '../../hooks/useAccounts';
import { useNavigate } from '../../hooks/useNavigate';
import { usePayees } from '../../hooks/usePayees';
-import { theme } from '../../style';
import { PayeeAutocomplete } from '../autocomplete/PayeeAutocomplete';
import {
ModalCloseButton,
@@ -14,7 +16,6 @@ import {
ModalTitle,
ModalHeader,
} from '../common/Modal';
-import { useResponsive } from '../responsive/ResponsiveProvider';
type PayeeAutocompleteModalProps = Extract<
ModalType,
diff --git a/packages/desktop-client/src/components/reports/Header.tsx b/packages/desktop-client/src/components/reports/Header.tsx
index f2256c68f0..c7d68c12c6 100644
--- a/packages/desktop-client/src/components/reports/Header.tsx
+++ b/packages/desktop-client/src/components/reports/Header.tsx
@@ -2,6 +2,7 @@ import { type ComponentProps, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Select } from '@actual-app/components/select';
import { SpaceBetween } from '@actual-app/components/space-between';
import { View } from '@actual-app/components/view';
@@ -16,7 +17,6 @@ import { type SyncedPrefs } from 'loot-core/types/prefs';
import { useLocale } from '../../hooks/useLocale';
import { AppliedFilters } from '../filters/AppliedFilters';
import { FilterButton } from '../filters/FiltersMenu';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { getLiveRange } from './getLiveRange';
import {
diff --git a/packages/desktop-client/src/components/reports/Overview.tsx b/packages/desktop-client/src/components/reports/Overview.tsx
index ef8f4e09e1..974ee118f4 100644
--- a/packages/desktop-client/src/components/reports/Overview.tsx
+++ b/packages/desktop-client/src/components/reports/Overview.tsx
@@ -6,6 +6,8 @@ import { Trans, useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgDotsHorizontalTriple } from '@actual-app/components/icons/v1';
import { Menu } from '@actual-app/components/menu';
import { Popover } from '@actual-app/components/popover';
import { View } from '@actual-app/components/view';
@@ -28,12 +30,10 @@ import { useAccounts } from '../../hooks/useAccounts';
import { useNavigate } from '../../hooks/useNavigate';
import { useSyncedPref } from '../../hooks/useSyncedPref';
import { useUndo } from '../../hooks/useUndo';
-import { SvgDotsHorizontalTriple } from '../../icons/v1';
import { useDispatch } from '../../redux';
import { breakpoints } from '../../tokens';
import { MOBILE_NAV_HEIGHT } from '../mobile/MobileNavTabs';
import { MobilePageHeader, Page, PageHeader } from '../Page';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { NON_DRAGGABLE_AREA_CLASS_NAME } from './constants';
import { LoadingIndicator } from './LoadingIndicator';
diff --git a/packages/desktop-client/src/components/reports/ReportCard.tsx b/packages/desktop-client/src/components/reports/ReportCard.tsx
index 3afc441360..e063462af8 100644
--- a/packages/desktop-client/src/components/reports/ReportCard.tsx
+++ b/packages/desktop-client/src/components/reports/ReportCard.tsx
@@ -7,6 +7,8 @@ import React, {
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgDotsHorizontalTriple } from '@actual-app/components/icons/v1';
import { Menu } from '@actual-app/components/menu';
import { Popover } from '@actual-app/components/popover';
import { theme } from '@actual-app/components/theme';
@@ -15,8 +17,6 @@ import { View } from '@actual-app/components/view';
import { useContextMenu } from '../../hooks/useContextMenu';
import { useIsInViewport } from '../../hooks/useIsInViewport';
import { useNavigate } from '../../hooks/useNavigate';
-import { SvgDotsHorizontalTriple } from '../../icons/v1';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { NON_DRAGGABLE_AREA_CLASS_NAME } from './constants';
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
index 4d190dbd2e..79beb69c7b 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
@@ -5,7 +5,9 @@ import React, {
type CSSProperties,
} from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import {
@@ -22,8 +24,6 @@ import { type RuleConditionEntity } from 'loot-core/types/models/rule';
import { useAccounts } from '../../../../hooks/useAccounts';
import { useCategories } from '../../../../hooks/useCategories';
import { useNavigate } from '../../../../hooks/useNavigate';
-import { theme } from '../../../../style';
-import { useResponsive } from '../../../responsive/ResponsiveProvider';
import { Row, Cell } from '../../../table';
import { showActivity } from '../showActivity';
diff --git a/packages/desktop-client/src/components/reports/reports/Calendar.tsx b/packages/desktop-client/src/components/reports/reports/Calendar.tsx
index 5394a5efbd..3ac83ecf70 100644
--- a/packages/desktop-client/src/components/reports/reports/Calendar.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Calendar.tsx
@@ -11,7 +11,15 @@ import { useParams, useSearchParams } from 'react-router-dom';
import { useSpring, animated, config } from 'react-spring';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import {
+ SvgArrowThickDown,
+ SvgArrowThickUp,
+ SvgCheveronDown,
+ SvgCheveronUp,
+} from '@actual-app/components/icons/v1';
import { styles } from '@actual-app/components/styles';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
import { useDrag } from '@use-gesture/react';
@@ -45,20 +53,12 @@ import { useResizeObserver } from '../../../hooks/useResizeObserver';
import { SelectedProviderWithItems } from '../../../hooks/useSelected';
import { SplitsExpandedProvider } from '../../../hooks/useSplitsExpanded';
import { useSyncedPref } from '../../../hooks/useSyncedPref';
-import {
- SvgArrowThickDown,
- SvgArrowThickUp,
- SvgCheveronDown,
- SvgCheveronUp,
-} from '../../../icons/v1';
import { useDispatch } from '../../../redux';
-import { theme } from '../../../style';
import { EditablePageHeaderTitle } from '../../EditablePageHeaderTitle';
import { MobileBackButton } from '../../mobile/MobileBackButton';
import { TransactionList as TransactionListMobile } from '../../mobile/transactions/TransactionList';
import { MobilePageHeader, Page, PageHeader } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { TransactionList } from '../../transactions/TransactionList';
import { chartTheme } from '../chart-theme';
import { DateRange } from '../DateRange';
diff --git a/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx b/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx
index 04d8304f11..0cb3cf5c2a 100644
--- a/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx
@@ -12,6 +12,11 @@ import { Trans, useTranslation } from 'react-i18next';
import { Block } from '@actual-app/components/block';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import {
+ SvgArrowThickDown,
+ SvgArrowThickUp,
+} from '@actual-app/components/icons/v1';
import { styles } from '@actual-app/components/styles';
import { theme } from '@actual-app/components/theme';
import { Tooltip } from '@actual-app/components/tooltip';
@@ -27,9 +32,7 @@ import { type SyncedPrefs } from 'loot-core/types/prefs';
import { useMergedRefs } from '../../../hooks/useMergedRefs';
import { useNavigate } from '../../../hooks/useNavigate';
import { useResizeObserver } from '../../../hooks/useResizeObserver';
-import { SvgArrowThickDown, SvgArrowThickUp } from '../../../icons/v1';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { chartTheme } from '../chart-theme';
import { DateRange } from '../DateRange';
import { CalendarGraph } from '../graphs/CalendarGraph';
diff --git a/packages/desktop-client/src/components/reports/reports/CashFlow.tsx b/packages/desktop-client/src/components/reports/reports/CashFlow.tsx
index b49bbb8573..c3841feccd 100644
--- a/packages/desktop-client/src/components/reports/reports/CashFlow.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CashFlow.tsx
@@ -5,6 +5,7 @@ import { useParams } from 'react-router-dom';
import { AlignedText } from '@actual-app/components/aligned-text';
import { Block } from '@actual-app/components/block';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Paragraph } from '@actual-app/components/paragraph';
import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
@@ -31,7 +32,6 @@ import { EditablePageHeaderTitle } from '../../EditablePageHeaderTitle';
import { MobileBackButton } from '../../mobile/MobileBackButton';
import { MobilePageHeader, Page, PageHeader } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { Change } from '../Change';
import { CashFlowGraph } from '../graphs/CashFlowGraph';
import { Header } from '../Header';
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index 9d3ef1eade..905f937b8b 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
@@ -4,6 +4,7 @@ import { useLocation, useParams } from 'react-router-dom';
import { AlignedText } from '@actual-app/components/aligned-text';
import { Block } from '@actual-app/components/block';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
@@ -38,7 +39,6 @@ import { AppliedFilters } from '../../filters/AppliedFilters';
import { MobileBackButton } from '../../mobile/MobileBackButton';
import { MobilePageHeader, Page, PageHeader } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { ChooseGraph } from '../ChooseGraph';
import {
defaultsGraphList,
diff --git a/packages/desktop-client/src/components/reports/reports/GetCardData.tsx b/packages/desktop-client/src/components/reports/reports/GetCardData.tsx
index d4e8e54208..8f266b7797 100644
--- a/packages/desktop-client/src/components/reports/reports/GetCardData.tsx
+++ b/packages/desktop-client/src/components/reports/reports/GetCardData.tsx
@@ -2,8 +2,10 @@ import React, { useMemo } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { styles } from '@actual-app/components/styles';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import * as monthUtils from 'loot-core/shared/months';
import { type AccountEntity } from 'loot-core/types/models/account';
@@ -13,8 +15,6 @@ import { type PayeeEntity } from 'loot-core/types/models/payee';
import { type CustomReportEntity } from 'loot-core/types/models/reports';
import { type SyncedPrefs } from 'loot-core/types/prefs';
-import { theme } from '../../../style/theme';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { ChooseGraph } from '../ChooseGraph';
import { getLiveRange } from '../getLiveRange';
import { LoadingIndicator } from '../LoadingIndicator';
diff --git a/packages/desktop-client/src/components/reports/reports/NetWorth.tsx b/packages/desktop-client/src/components/reports/reports/NetWorth.tsx
index dbb36e73cc..7f11bbd38f 100644
--- a/packages/desktop-client/src/components/reports/reports/NetWorth.tsx
+++ b/packages/desktop-client/src/components/reports/reports/NetWorth.tsx
@@ -3,8 +3,10 @@ import { Trans, useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Paragraph } from '@actual-app/components/paragraph';
import { styles } from '@actual-app/components/styles';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import * as d from 'date-fns';
@@ -21,12 +23,10 @@ import { useLocale } from '../../../hooks/useLocale';
import { useNavigate } from '../../../hooks/useNavigate';
import { useSyncedPref } from '../../../hooks/useSyncedPref';
import { useDispatch } from '../../../redux';
-import { theme } from '../../../style';
import { EditablePageHeaderTitle } from '../../EditablePageHeaderTitle';
import { MobileBackButton } from '../../mobile/MobileBackButton';
import { MobilePageHeader, Page, PageHeader } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { Change } from '../Change';
import { NetWorthGraph } from '../graphs/NetWorthGraph';
import { Header } from '../Header';
diff --git a/packages/desktop-client/src/components/reports/reports/NetWorthCard.tsx b/packages/desktop-client/src/components/reports/reports/NetWorthCard.tsx
index 1f19870eb7..453ffa999e 100644
--- a/packages/desktop-client/src/components/reports/reports/NetWorthCard.tsx
+++ b/packages/desktop-client/src/components/reports/reports/NetWorthCard.tsx
@@ -2,6 +2,7 @@ import React, { useState, useMemo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { Block } from '@actual-app/components/block';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { styles } from '@actual-app/components/styles';
import { View } from '@actual-app/components/view';
@@ -13,7 +14,6 @@ import {
import { useLocale } from '../../../hooks/useLocale';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { Change } from '../Change';
import { DateRange } from '../DateRange';
import { NetWorthGraph } from '../graphs/NetWorthGraph';
diff --git a/packages/desktop-client/src/components/reports/reports/Spending.tsx b/packages/desktop-client/src/components/reports/reports/Spending.tsx
index 4b38d857a1..dab260a60e 100644
--- a/packages/desktop-client/src/components/reports/reports/Spending.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Spending.tsx
@@ -5,6 +5,7 @@ import { useParams } from 'react-router-dom';
import { AlignedText } from '@actual-app/components/aligned-text';
import { Block } from '@actual-app/components/block';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Paragraph } from '@actual-app/components/paragraph';
import { Select } from '@actual-app/components/select';
import { SpaceBetween } from '@actual-app/components/space-between';
@@ -33,7 +34,6 @@ import { FilterButton } from '../../filters/FiltersMenu';
import { MobileBackButton } from '../../mobile/MobileBackButton';
import { MobilePageHeader, Page, PageHeader } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { SpendingGraph } from '../graphs/SpendingGraph';
import { LegendItem } from '../LegendItem';
import { LoadingIndicator } from '../LoadingIndicator';
diff --git a/packages/desktop-client/src/components/reports/reports/Summary.tsx b/packages/desktop-client/src/components/reports/reports/Summary.tsx
index 781044375d..5a3093a0ad 100644
--- a/packages/desktop-client/src/components/reports/reports/Summary.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Summary.tsx
@@ -3,6 +3,7 @@ import { Trans, useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { SvgEquals } from '@actual-app/components/icons/v1';
import {
SvgCloseParenthesis,
@@ -38,7 +39,6 @@ import { MobileBackButton } from '../../mobile/MobileBackButton';
import { FieldSelect } from '../../modals/EditRuleModal';
import { MobilePageHeader, Page, PageHeader } from '../../Page';
import { PrivacyFilter } from '../../PrivacyFilter';
-import { useResponsive } from '../../responsive/ResponsiveProvider';
import { chartTheme } from '../chart-theme';
import { Header } from '../Header';
import { LoadingIndicator } from '../LoadingIndicator';
diff --git a/packages/desktop-client/src/components/responsive/ResponsiveProvider.tsx b/packages/desktop-client/src/components/responsive/ResponsiveProvider.tsx
deleted file mode 100644
index 38295d8f59..0000000000
--- a/packages/desktop-client/src/components/responsive/ResponsiveProvider.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { type ReactNode, createContext, useContext } from 'react';
-
-import { useWindowSize } from 'usehooks-ts';
-
-import { breakpoints } from '../../tokens';
-
-type TResponsiveContext = {
- atLeastMediumWidth: boolean;
- isNarrowWidth: boolean;
- isSmallWidth: boolean;
- isMediumWidth: boolean;
- isWideWidth: boolean;
- height: number;
- width: number;
-};
-
-const ResponsiveContext = createContext<TResponsiveContext | undefined>(
- undefined,
-);
-
-export function ResponsiveProvider(props: { children: ReactNode }) {
- const { height, width } = useWindowSize({
- debounceDelay: 250,
- });
-
- // Possible view modes: narrow, small, medium, wide
- // To check if we're at least small width, check !isNarrowWidth
- const viewportInfo = {
- // atLeastMediumWidth is provided to avoid checking (isMediumWidth || isWideWidth)
- atLeastMediumWidth: width >= breakpoints.medium,
- isNarrowWidth: width < breakpoints.small,
- isSmallWidth: width >= breakpoints.small && width < breakpoints.medium,
- isMediumWidth: width >= breakpoints.medium && width < breakpoints.wide,
- // No atLeastWideWidth because that's identical to isWideWidth
- isWideWidth: width >= breakpoints.wide,
- height,
- width,
- };
-
- return (
- <ResponsiveContext.Provider value={viewportInfo}>
- {props.children}
- </ResponsiveContext.Provider>
- );
-}
-
-export function useResponsive() {
- const context = useContext(ResponsiveContext);
- if (!context) {
- throw new Error('useResponsive must be used within a ResponsiveProvider');
- }
- return context;
-}
diff --git a/packages/desktop-client/src/components/responsive/index.tsx b/packages/desktop-client/src/components/responsive/index.tsx
index ef3ccde56b..f02bd3887f 100644
--- a/packages/desktop-client/src/components/responsive/index.tsx
+++ b/packages/desktop-client/src/components/responsive/index.tsx
@@ -1,7 +1,8 @@
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+
import { LoadComponent } from '../util/LoadComponent';
import type * as NarrowComponents from './narrow';
-import { useResponsive } from './ResponsiveProvider';
import type * as WideComponents from './wide';
const loadNarrow = () =>
diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsx
index 5163439078..e1b41f1452 100644
--- a/packages/desktop-client/src/components/settings/index.tsx
+++ b/packages/desktop-client/src/components/settings/index.tsx
@@ -2,7 +2,10 @@ import React, { type ReactNode, useEffect } from 'react';
import { useTranslation, Trans } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { Input } from '@actual-app/components/input';
import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
@@ -15,14 +18,11 @@ import { useGlobalPref } from '../../hooks/useGlobalPref';
import { useIsOutdated, useLatestVersion } from '../../hooks/useLatestVersion';
import { useMetadataPref } from '../../hooks/useMetadataPref';
import { useDispatch } from '../../redux';
-import { theme } from '../../style';
import { tokens } from '../../tokens';
-import { Input } from '../common/Input';
import { Link } from '../common/Link';
import { FormField, FormLabel } from '../forms';
import { MOBILE_NAV_HEIGHT } from '../mobile/MobileNavTabs';
import { Page } from '../Page';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { useServerVersion } from '../ServerContext';
import { AuthSettings } from './AuthSettings';
diff --git a/packages/desktop-client/src/components/sidebar/Sidebar.tsx b/packages/desktop-client/src/components/sidebar/Sidebar.tsx
index db4ce920ae..2b4b7fe26d 100644
--- a/packages/desktop-client/src/components/sidebar/Sidebar.tsx
+++ b/packages/desktop-client/src/components/sidebar/Sidebar.tsx
@@ -1,7 +1,10 @@
import React, { type CSSProperties, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+import { SvgAdd } from '@actual-app/components/icons/v1';
import { styles } from '@actual-app/components/styles';
+import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
import { Resizable } from 're-resizable';
@@ -12,10 +15,7 @@ import * as Platform from 'loot-core/client/platform';
import { useGlobalPref } from '../../hooks/useGlobalPref';
import { useLocalPref } from '../../hooks/useLocalPref';
import { useResizeObserver } from '../../hooks/useResizeObserver';
-import { SvgAdd } from '../../icons/v1';
import { useDispatch } from '../../redux';
-import { theme } from '../../style';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { Accounts } from './Accounts';
import { BudgetName } from './BudgetName';
diff --git a/packages/desktop-client/src/components/sidebar/SidebarProvider.tsx b/packages/desktop-client/src/components/sidebar/SidebarProvider.tsx
index b56efb551f..1d08f2b407 100644
--- a/packages/desktop-client/src/components/sidebar/SidebarProvider.tsx
+++ b/packages/desktop-client/src/components/sidebar/SidebarProvider.tsx
@@ -9,8 +9,9 @@ import React, {
type SetStateAction,
} from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+
import { useGlobalPref } from '../../hooks/useGlobalPref';
-import { useResponsive } from '../responsive/ResponsiveProvider';
type SidebarContextValue = {
hidden: boolean;
diff --git a/packages/desktop-client/src/components/sidebar/index.tsx b/packages/desktop-client/src/components/sidebar/index.tsx
index 16c74c5cd6..2c57ab39bd 100644
--- a/packages/desktop-client/src/components/sidebar/index.tsx
+++ b/packages/desktop-client/src/components/sidebar/index.tsx
@@ -1,10 +1,10 @@
import React from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { View } from '@actual-app/components/view';
import { useDebounceCallback } from 'usehooks-ts';
import { useGlobalPref } from '../../hooks/useGlobalPref';
-import { useResponsive } from '../responsive/ResponsiveProvider';
import { Sidebar } from './Sidebar';
import { useSidebar } from './SidebarProvider';
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx
index e631804a9b..adf06212f8 100644
--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx
+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx
@@ -32,7 +32,6 @@ import { AuthProvider } from '../../auth/AuthProvider';
import { SelectedProviderWithItems } from '../../hooks/useSelected';
import { SplitsExpandedProvider } from '../../hooks/useSplitsExpanded';
import { TestProvider } from '../../redux/mock';
-import { ResponsiveProvider } from '../responsive/ResponsiveProvider';
import { TransactionTable } from './TransactionsTable';
@@ -189,38 +188,36 @@ function LiveTransactionTable(props: LiveTransactionTableProps) {
// hook dependencies haven't changed
return (
<TestProvider>
- <ResponsiveProvider>
- <AuthProvider>
- <SpreadsheetProvider>
- <SchedulesProvider>
- <SelectedProviderWithItems
- name="transactions"
- items={transactions}
- fetchAllIds={() => Promise.resolve(transactions.map(t => t.id))}
- >
- <SplitsExpandedProvider>
- <TransactionTable
- {...props}
- // @ts-expect-error this will be auto-patched once TransactionTable is moved to TS
- transactions={transactions}
- loadMoreTransactions={() => {}}
- commonPayees={[]}
- payees={payees}
- addNotification={console.log}
- onSave={onSave}
- onSplit={onSplit}
- onAdd={onAdd}
- onAddSplit={onAddSplit}
- onCreatePayee={onCreatePayee}
- showSelection={true}
- allowSplitTransaction={true}
- />
- </SplitsExpandedProvider>
- </SelectedProviderWithItems>
- </SchedulesProvider>
- </SpreadsheetProvider>
- </AuthProvider>
- </ResponsiveProvider>
+ <AuthProvider>
+ <SpreadsheetProvider>
+ <SchedulesProvider>
+ <SelectedProviderWithItems
+ name="transactions"
+ items={transactions}
+ fetchAllIds={() => Promise.resolve(transactions.map(t => t.id))}
+ >
+ <SplitsExpandedProvider>
+ <TransactionTable
+ {...props}
+ // @ts-expect-error this will be auto-patched once TransactionTable is moved to TS
+ transactions={transactions}
+ loadMoreTransactions={() => {}}
+ commonPayees={[]}
+ payees={payees}
+ addNotification={console.log}
+ onSave={onSave}
+ onSplit={onSplit}
+ onAdd={onAdd}
+ onAddSplit={onAddSplit}
+ onCreatePayee={onCreatePayee}
+ showSelection={true}
+ allowSplitTransaction={true}
+ />
+ </SplitsExpandedProvider>
+ </SelectedProviderWithItems>
+ </SchedulesProvider>
+ </SpreadsheetProvider>
+ </AuthProvider>
</TestProvider>
);
}
diff --git a/packages/desktop-client/src/hooks/useUndo.ts b/packages/desktop-client/src/hooks/useUndo.ts
index a1abfb4820..cbad9db58a 100644
--- a/packages/desktop-client/src/hooks/useUndo.ts
+++ b/packages/desktop-client/src/hooks/useUndo.ts
@@ -1,12 +1,13 @@
import { useCallback } from 'react';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
+
import {
addNotification,
type Notification,
} from 'loot-core/client/notifications/notificationsSlice';
import { redo, undo } from 'loot-core/client/undo';
-import { useResponsive } from '../components/responsive/ResponsiveProvider';
import { useDispatch } from '../redux';
type UndoActions = {
diff --git a/upcoming-release-notes/4568.md b/upcoming-release-notes/4568.md
new file mode 100644
index 0000000000..7e24c26433
--- /dev/null
+++ b/upcoming-release-notes/4568.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Moving `useResponsive` hook to the component library and simplifying its logic.
diff --git a/yarn.lock b/yarn.lock
index fdf4f5b45c..27f25e5220 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -47,6 +47,7 @@ __metadata:
"@types/react": "npm:^18.2.0"
react: "npm:18.2.0"
react-aria-components: "npm:^1.7.0"
+ usehooks-ts: "npm:^3.0.1"
peerDependencies:
react: ">=18.2"
languageName: unknown