Skip to content

Commit 72dc293

Browse files
Fix href types (#1082)
1 parent 49f5da2 commit 72dc293

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

.changeset/lazy-ducks-roll.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@obosbbl/grunnmuren-react': patch
3+
---
4+
5+
Base `href` prop on `<Backlink>`, `<Breadcrumb>` and `<Button>` to enable type safe routes.

packages/react/src/backlink/backlink.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import { ChevronLeft } from '@obosbbl/grunnmuren-icons-react';
22
import { cx } from 'cva';
33
import { type Ref, forwardRef } from 'react';
4-
import { Button, type ButtonProps, Link } from 'react-aria-components';
4+
import {
5+
Button,
6+
type ButtonProps,
7+
Link,
8+
type LinkProps as RACLinkProps,
9+
} from 'react-aria-components';
510

611
type ButtonOrLinkProps = {
712
children?: React.ReactNode;
813
/** Additional CSS className for the element. */
914
className?: string;
1015
/** Determines whether to use an anchor or a button for the Backlink */
11-
href?: string;
16+
href?: RACLinkProps['href'];
1217
/** To add a permanent underline on the link (not only on hover)
1318
* @default false
1419
*/

packages/react/src/breadcrumbs/breadcrumb.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Link,
66
Breadcrumb as RACBreadcrumb,
77
type BreadcrumbProps as RACBreadcrumbProps,
8+
type LinkProps as RACLinkProps,
89
} from 'react-aria-components';
910

1011
type BreadcrumbProps = {
@@ -16,7 +17,7 @@ type BreadcrumbProps = {
1617
style?: React.CSSProperties;
1718

1819
/** The URL to navigate to when clicking the breadcrumb. */
19-
href?: string;
20+
href?: RACLinkProps['href'];
2021
} & Omit<RACBreadcrumbProps, 'className' | 'style'>;
2122

2223
function Breadcrumb(props: BreadcrumbProps, ref: Ref<HTMLLIElement>) {

packages/react/src/button/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const buttonVariants = cva({
115115

116116
type ButtonOrLinkProps = VariantProps<typeof buttonVariants> & {
117117
children?: React.ReactNode;
118-
href?: string;
118+
href?: RACLinkProps['href'];
119119
/**
120120
* Display the button in a loading state
121121
* @deprecated Use isPending instead.

0 commit comments

Comments
 (0)