Skip to content

Commit

Permalink
Some typescript migration (#1532)
Browse files Browse the repository at this point in the history
* Typescript migration

* Release notes

* Update error boundary

* Breakup sidebar components

* Account and Sidebar props

* Remove button in Item component + exports cleanup

* Put accountNameStyle to Account

* Revert component ports (separated to another PR)

* Export cleanup

* Remove ErrorBoundary (separated to another PR)

* Sidebar budgetName as ReactNode
  • Loading branch information
joel-jeremy authored Aug 17, 2023
1 parent f8ce38f commit 6fae795
Show file tree
Hide file tree
Showing 28 changed files with 1,007 additions and 684 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import React from 'react';
import React, { type CSSProperties } from 'react';

import { css } from 'glamor';
import { keyframes } from 'glamor';

import Refresh from '../icons/v1/Refresh';

import View from './common/View';

let spin = css.keyframes({
let spin = keyframes({
'0%': { transform: 'rotateZ(0deg)' },
'100%': { transform: 'rotateZ(360deg)' },
});

export default function AnimatedRefresh({ animating, iconStyle }) {
type AnimatedRefreshProps = {
animating: boolean;
iconStyle?: CSSProperties;
};

export default function AnimatedRefresh({
animating,
iconStyle,
}: AnimatedRefreshProps) {
return (
<View
style={[{ animation: animating ? `${spin} 1s infinite linear` : null }]}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { getIsOutdated, getLatestVersion } from '../util/versions';
import BankSyncStatus from './BankSyncStatus';
import { BudgetMonthCountProvider } from './budget/BudgetMonthCountContext';
import View from './common/View';
import FloatableSidebar, { SidebarProvider } from './FloatableSidebar';
import GlobalKeys from './GlobalKeys';
import { ManageRulesPage } from './ManageRulesPage';
import Modals from './Modals';
Expand All @@ -41,6 +40,7 @@ import { ManagePayeesPage } from './payees/ManagePayeesPage';
import Reports from './reports';
import { NarrowAlternate, WideComponent } from './responsive';
import Settings from './settings';
import FloatableSidebar, { SidebarProvider } from './sidebar';
import Titlebar, { TitlebarProvider } from './Titlebar';
import { TransactionEdit } from './transactions/MobileTransaction';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, type CSSProperties } from 'react';
import { useSelector } from 'react-redux';

import { useActions } from '../hooks/useActions';
Expand All @@ -11,7 +11,16 @@ import View from './common/View';
import { useServerURL } from './ServerContext';
import { Tooltip } from './tooltips';

export default function LoggedInUser({ hideIfNoServer, style, color }) {
type LoggedInUserProps = {
hideIfNoServer?: boolean;
style?: CSSProperties;
color?: string;
};
export default function LoggedInUser({
hideIfNoServer,
style,
color,
}: LoggedInUserProps) {
let userData = useSelector(state => state.user.data);
let { getUserData, signOut, closeBudget } = useActions();
let [loading, setLoading] = useState(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Page } from './Page';
export function ManageRulesPage() {
return (
<Page title="Rules">
<ManageRules />
<ManageRules isModal={false} payeeId={null} />
</Page>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function MobileWebMessage() {
let d = new Date();
d.setTime(d.getTime() + 1000 * 60 * 5);
document.cookie =
'hideMobileMessage=true;path=/;expires=' + d.toGMTString();
'hideMobileMessage=true;path=/;expires=' + d.toUTCString();
}
}

Expand Down
13 changes: 0 additions & 13 deletions packages/desktop-client/src/components/SyncRefresh.js

This file was deleted.

21 changes: 21 additions & 0 deletions packages/desktop-client/src/components/SyncRefresh.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { type ReactNode, useState } from 'react';

type ChildrenProps = {
refreshing: boolean;
onRefresh: () => Promise<void>;
};
type SyncRefreshProps = {
onSync: () => Promise<void>;
children: (props: ChildrenProps) => ReactNode;
};
export default function SyncRefresh({ onSync, children }: SyncRefreshProps) {
let [syncing, setSyncing] = useState(false);

async function onSync_() {
setSyncing(true);
await onSync();
setSyncing(false);
}

return children({ refreshing: syncing, onRefresh: onSync_ });
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React, {
useEffect,
useRef,
useContext,
type ReactNode,
type CSSProperties,
} from 'react';
import { useSelector } from 'react-redux';
import { Routes, Route, useLocation, useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -34,16 +36,19 @@ import ExternalLink from './common/ExternalLink';
import Paragraph from './common/Paragraph';
import Text from './common/Text';
import View from './common/View';
import { useSidebar } from './FloatableSidebar';
import LoggedInUser from './LoggedInUser';
import { useServerURL } from './ServerContext';
import { useSidebar } from './sidebar';
import useSheetValue from './spreadsheet/useSheetValue';
import { ThemeSelector } from './ThemeSelector';
import { Tooltip } from './tooltips';

export let TitlebarContext = createContext();
export let TitlebarContext = createContext(null);

export function TitlebarProvider({ children }) {
type TitlebarProviderProps = {
children?: ReactNode;
};
export function TitlebarProvider({ children }: TitlebarProviderProps) {
let listeners = useRef([]);

function sendEvent(msg) {
Expand Down Expand Up @@ -101,7 +106,10 @@ function PrivacyButton() {
);
}

export function SyncButton({ style }) {
type SyncButtonProps = {
style?: CSSProperties;
};
export function SyncButton({ style }: SyncButtonProps) {
let cloudFileId = useSelector(state => state.prefs.local.cloudFileId);
let { sync } = useActions();

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/settings/Format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Button from '../common/Button';
import Select from '../common/Select';
import Text from '../common/Text';
import View from '../common/View';
import { useSidebar } from '../FloatableSidebar';
import { Checkbox } from '../forms';
import { useSidebar } from '../sidebar';

import { Setting } from './UI';

Expand Down
Loading

0 comments on commit 6fae795

Please sign in to comment.