forked from actualbudget/actual
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ moving P, useStableCallback, AnchorLink common components (actualb…
…udget#1413) Moving the code to separate files. Functionally should be no differences.
- Loading branch information
1 parent
8a11f5b
commit 086b595
Showing
26 changed files
with
207 additions
and
188 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
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
31 changes: 31 additions & 0 deletions
31
packages/desktop-client/src/components/common/AnchorLink.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,31 @@ | ||
import { type ReactNode } from 'react'; | ||
import { NavLink, useMatch } from 'react-router-dom'; | ||
|
||
import { type CSSProperties, css } from 'glamor'; | ||
|
||
import { styles } from '../../style'; | ||
|
||
type AnchorLinkProps = { | ||
to: string; | ||
style?: CSSProperties; | ||
activeStyle?: CSSProperties; | ||
children?: ReactNode; | ||
}; | ||
|
||
export default function AnchorLink({ | ||
to, | ||
style, | ||
activeStyle, | ||
children, | ||
}: AnchorLinkProps) { | ||
let match = useMatch({ path: to }); | ||
|
||
return ( | ||
<NavLink | ||
to={to} | ||
{...css([styles.smallText, style, match ? activeStyle : null])} | ||
> | ||
{children} | ||
</NavLink> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/desktop-client/src/components/common/Paragraph.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,23 @@ | ||
import { css } from 'glamor'; | ||
|
||
import { type HTMLPropsWithStyle } from '../../types/utils'; | ||
|
||
type ParagraphProps = HTMLPropsWithStyle<HTMLDivElement> & { | ||
isLast?: boolean; | ||
}; | ||
|
||
export default function Paragraph({ | ||
style, | ||
isLast, | ||
children, | ||
...props | ||
}: ParagraphProps) { | ||
return ( | ||
<div | ||
{...props} | ||
{...css(!isLast && { marginBottom: 15 }, style, { lineHeight: '1.5em' })} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.