-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into noticeColorConsolidation
- Loading branch information
Showing
46 changed files
with
788 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
packages/desktop-client/src/components/budget/BudgetMonthCountContext.js
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/desktop-client/src/components/budget/BudgetMonthCountContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { | ||
createContext, | ||
type Dispatch, | ||
type ReactNode, | ||
type SetStateAction, | ||
useContext, | ||
useState, | ||
} from 'react'; | ||
|
||
type BudgetMonthCountContextValue = { | ||
displayMax: number; | ||
setDisplayMax: Dispatch<SetStateAction<number>>; | ||
}; | ||
|
||
let BudgetMonthCountContext = createContext<BudgetMonthCountContextValue>(null); | ||
|
||
type BudgetMonthCountProviderProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
export function BudgetMonthCountProvider({ | ||
children, | ||
}: BudgetMonthCountProviderProps) { | ||
let [displayMax, setDisplayMax] = useState(1); | ||
|
||
return ( | ||
<BudgetMonthCountContext.Provider value={{ displayMax, setDisplayMax }}> | ||
{children} | ||
</BudgetMonthCountContext.Provider> | ||
); | ||
} | ||
|
||
export function useBudgetMonthCount() { | ||
return useContext(BudgetMonthCountContext); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React, { type ReactNode, type ComponentProps } from 'react'; | ||
import { NavLink, useMatch, useNavigate } from 'react-router-dom'; | ||
|
||
import { css } from 'glamor'; | ||
|
||
import { type CSSProperties, styles } from '../../style'; | ||
|
||
import Button from './Button'; | ||
|
||
type ButtonLinkProps = ComponentProps<typeof Button> & { | ||
to: string; | ||
activeStyle?: CSSProperties; | ||
}; | ||
|
||
type AnchorLinkProps = { | ||
to: string; | ||
style?: CSSProperties; | ||
activeStyle?: CSSProperties; | ||
children?: ReactNode; | ||
}; | ||
|
||
const ButtonLink = ({ | ||
to, | ||
style, | ||
activeStyle, | ||
onClick, | ||
...props | ||
}: ButtonLinkProps) => { | ||
const navigate = useNavigate(); | ||
const match = useMatch({ path: to }); | ||
|
||
const handleClick = e => { | ||
onClick?.(e); | ||
navigate(to); | ||
}; | ||
|
||
return ( | ||
<Button | ||
style={{ | ||
...style, | ||
...(match ? activeStyle : {}), | ||
}} | ||
activeStyle={activeStyle} | ||
{...props} | ||
onClick={handleClick} | ||
/> | ||
); | ||
}; | ||
|
||
const AnchorLink = ({ to, style, activeStyle, children }: AnchorLinkProps) => { | ||
const match = useMatch({ path: to }); | ||
|
||
return ( | ||
<NavLink | ||
to={to} | ||
className={`${css([ | ||
styles.smallText, | ||
style, | ||
match ? activeStyle : null, | ||
])}`} | ||
> | ||
{children} | ||
</NavLink> | ||
); | ||
}; | ||
|
||
type LinkProps = | ||
| ({ | ||
variant: 'button'; | ||
} & ButtonLinkProps) | ||
| ({ variant?: 'anchor' } & AnchorLinkProps); | ||
|
||
export default function Link({ variant = 'anchor', ...props }: LinkProps) { | ||
switch (variant) { | ||
case 'anchor': | ||
return <AnchorLink {...props} />; | ||
|
||
case 'button': | ||
return <ButtonLink {...props} />; | ||
|
||
default: | ||
throw new Error(`Unrecognised link type: ${variant}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/desktop-client/src/components/responsive/PullToRefresh.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { type ComponentProps } from 'react'; | ||
import BasePullToRefresh from 'react-simple-pull-to-refresh'; | ||
|
||
import { css } from 'glamor'; | ||
|
||
type PullToRefreshProps = ComponentProps<typeof BasePullToRefresh>; | ||
|
||
export default function PullToRefresh(props: PullToRefreshProps) { | ||
return ( | ||
<div style={{ overflow: 'auto' }}> | ||
<BasePullToRefresh | ||
pullDownThreshold={80} | ||
resistance={2} | ||
className={String( | ||
css({ | ||
'& .ptr__pull-down': { | ||
textAlign: 'center', | ||
}, | ||
'& .ptr__children': { | ||
overflow: 'hidden auto', | ||
}, | ||
}), | ||
)} | ||
{...props} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.