Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 7807d20

Browse files
committed
Update @tanstack/router and fix links
1 parent 04fb8fe commit 7807d20

File tree

5 files changed

+63
-67
lines changed

5 files changed

+63
-67
lines changed

frontend/package-lock.json

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@radix-ui/react-alert-dialog": "^1.0.5",
2222
"@radix-ui/react-dialog": "^1.0.5",
2323
"@radix-ui/react-form": "^0.0.3",
24-
"@tanstack/react-router": "^1.20.1",
24+
"@tanstack/react-router": "^1.24.0",
2525
"@types/ua-parser-js": "^0.7.39",
2626
"@urql/core": "^4.3.0",
2727
"@urql/devtools": "^2.0.3",
@@ -54,8 +54,8 @@
5454
"@storybook/addon-essentials": "^8.0.5",
5555
"@storybook/react": "^8.0.5",
5656
"@storybook/react-vite": "^8.0.5",
57-
"@tanstack/router-devtools": "^1.20.1",
58-
"@tanstack/router-vite-plugin": "^1.20.2",
57+
"@tanstack/router-devtools": "^1.24.0",
58+
"@tanstack/router-vite-plugin": "^1.25.0",
5959
"@testing-library/react": "^14.2.2",
6060
"@types/node": "^20.11.30",
6161
"@types/react": "^18.2.73",

frontend/src/components/ButtonLink.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {
16-
UseLinkPropsOptions,
17-
createLink,
18-
useLinkProps,
19-
} from "@tanstack/react-router";
15+
import { createLink } from "@tanstack/react-router";
2016
import { Button } from "@vector-im/compound-web";
21-
import { forwardRef } from "react";
17+
import { PropsWithChildren, forwardRef } from "react";
2218

2319
type Props = {
2420
kind?: "primary" | "secondary" | "tertiary";
@@ -27,15 +23,14 @@ type Props = {
2723
destructive?: boolean;
2824
};
2925

30-
// XXX: createLink is broken, so we work around it by using useLinkProps directly
31-
export const ButtonLink = forwardRef<
32-
HTMLAnchorElement,
33-
Props & UseLinkPropsOptions
34-
>(({ children, ...props }, ref) => {
35-
const linkProps = useLinkProps(props);
36-
return (
37-
<Button as="a" {...linkProps} ref={ref}>
38-
{children}
39-
</Button>
40-
);
41-
}) as ReturnType<typeof createLink<typeof Button>>;
26+
export const ButtonLink = createLink(
27+
forwardRef<HTMLAnchorElement, PropsWithChildren<Props>>(
28+
({ children, ...props }, ref) => {
29+
return (
30+
<Button as="a" {...props} ref={ref}>
31+
{children}
32+
</Button>
33+
);
34+
},
35+
),
36+
);

frontend/src/components/Link.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { createLink, useLinkProps } from "@tanstack/react-router";
15+
import { createLink } from "@tanstack/react-router";
1616
import { Link as CompoundLink } from "@vector-im/compound-web";
1717

18-
export const Link: ReturnType<typeof createLink<typeof CompoundLink>> = ({
19-
children,
20-
...props
21-
}: Parameters<typeof useLinkProps>[0]) => {
22-
const linkProps = useLinkProps(props);
23-
return <CompoundLink {...linkProps}>{children}</CompoundLink>;
24-
};
18+
export const Link = createLink(CompoundLink);

frontend/src/components/SessionCard/SessionCard.tsx

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {
16-
UseLinkPropsOptions,
17-
createLink,
18-
useLinkProps,
19-
} from "@tanstack/react-router";
15+
import { createLink } from "@tanstack/react-router";
2016
import cx from "classnames";
21-
import { AnchorHTMLAttributes, forwardRef } from "react";
17+
import { forwardRef } from "react";
2218

2319
import { DeviceType } from "../../gql/graphql";
2420
import ClientAvatar from "../Session/ClientAvatar";
@@ -30,35 +26,31 @@ export const Root: React.FC<React.PropsWithChildren> = ({ children }) => (
3026
<section className={styles.sessionCardRoot}>{children}</section>
3127
);
3228

33-
// XXX: createLink is broken, so we work around it by using useLinkProps directly
3429
type BodyProps = React.PropsWithChildren<{
3530
disabled?: boolean;
3631
compact?: boolean;
32+
className?: string;
3733
}>;
38-
export const LinkBody = forwardRef<
39-
HTMLAnchorElement,
40-
BodyProps & UseLinkPropsOptions
41-
>(({ children, disabled, compact, ...props }, ref) => {
42-
const { className, ...linkProps } = useLinkProps({ disabled, ...props });
43-
return (
44-
<a
45-
className={cx(
46-
className,
47-
styles.sessionCard,
48-
compact && styles.compact,
49-
disabled && styles.disabled,
50-
)}
51-
{...linkProps}
52-
ref={ref}
53-
>
54-
{children}
55-
</a>
56-
);
57-
}) as ReturnType<
58-
typeof createLink<
59-
React.FC<BodyProps & AnchorHTMLAttributes<HTMLAnchorElement>>
60-
>
61-
>;
34+
export const LinkBody = createLink(
35+
forwardRef<HTMLAnchorElement, BodyProps>(
36+
({ children, disabled, compact, className, ...props }, ref) => {
37+
return (
38+
<a
39+
className={cx(
40+
className,
41+
styles.sessionCard,
42+
compact && styles.compact,
43+
disabled && styles.disabled,
44+
)}
45+
{...props}
46+
ref={ref}
47+
>
48+
{children}
49+
</a>
50+
);
51+
},
52+
),
53+
);
6254

6355
export const Body: React.FC<BodyProps> = ({ children, compact, disabled }) => (
6456
<div

0 commit comments

Comments
 (0)