Skip to content

Commit 68c1b81

Browse files
authored
Merge pull request #2210 from pyth-network/cprussin/price-feed-chart
fix(component-library): fix prefetching react-aria links
2 parents c2f7225 + 7cd3f93 commit 68c1b81

File tree

56 files changed

+516
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+516
-658
lines changed

apps/insights/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"nuqs": "catalog:",
4242
"react": "catalog:",
4343
"react-aria": "catalog:",
44-
"react-aria-components": "catalog:",
4544
"react-dom": "catalog:",
4645
"recharts": "catalog:",
4746
"superjson": "catalog:",

apps/insights/src/components/PriceFeed/price-components-card.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import { Card } from "@pythnetwork/component-library/Card";
44
import { Paginator } from "@pythnetwork/component-library/Paginator";
5-
import { type RowConfig, Table } from "@pythnetwork/component-library/Table";
5+
import {
6+
type RowConfig,
7+
type SortDescriptor,
8+
Table,
9+
} from "@pythnetwork/component-library/Table";
610
import { type ReactNode, Suspense, useMemo } from "react";
711
import { useFilter, useCollator } from "react-aria";
8-
import type { SortDescriptor } from "react-aria-components";
912

1013
import { useQueryParamFilterPagination } from "../../use-query-param-filter-pagination";
1114
import { FormattedNumber } from "../FormattedNumber";

apps/insights/src/components/PriceFeed/price-feed-select.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
"use client";
22

33
import { DropdownCaretDown } from "@pythnetwork/component-library/DropdownCaretDown";
4-
import { type ReactNode, useMemo, useState } from "react";
5-
import { useCollator, useFilter } from "react-aria";
64
import {
7-
Select,
8-
Button,
9-
Popover,
10-
Dialog,
5+
Virtualizer,
6+
ListLayout,
7+
} from "@pythnetwork/component-library/Virtualizer";
8+
import { Button } from "@pythnetwork/component-library/unstyled/Button";
9+
import { Dialog } from "@pythnetwork/component-library/unstyled/Dialog";
10+
import {
1111
ListBox,
1212
ListBoxItem,
13-
UNSTABLE_Virtualizer as Virtualizer,
14-
UNSTABLE_ListLayout as ListLayout,
13+
} from "@pythnetwork/component-library/unstyled/ListBox";
14+
import { Popover } from "@pythnetwork/component-library/unstyled/Popover";
15+
import { Select } from "@pythnetwork/component-library/unstyled/Select";
16+
import {
1517
TextField,
1618
Input,
17-
} from "react-aria-components";
19+
} from "@pythnetwork/component-library/unstyled/TextField";
20+
import { type ReactNode, useMemo, useState } from "react";
21+
import { useCollator, useFilter } from "react-aria";
1822

1923
import styles from "./price-feed-select.module.scss";
2024

apps/insights/src/components/PriceFeed/tabs.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use client";
22

3-
import { Tabs as TabsComponent } from "@pythnetwork/component-library/Tabs";
3+
import { TabList } from "@pythnetwork/component-library/TabList";
44
import {
5-
UnstyledTabPanel,
6-
UnstyledTabs,
7-
} from "@pythnetwork/component-library/UnstyledTabs";
5+
TabPanel as UnstyledTabPanel,
6+
Tabs as UnstyledTabs,
7+
} from "@pythnetwork/component-library/unstyled/Tabs";
88
import { useSelectedLayoutSegment, usePathname } from "next/navigation";
99
import { useMemo, type ComponentProps } from "react";
1010

@@ -18,13 +18,10 @@ export const TabRoot = (
1818
return <UnstyledTabs selectedKey={tabId} {...props} />;
1919
};
2020

21-
type TabsProps = Omit<
22-
ComponentProps<typeof TabsComponent>,
23-
"pathname" | "items"
24-
> & {
21+
type TabsProps = Omit<ComponentProps<typeof TabList>, "pathname" | "items"> & {
2522
slug: string;
2623
items: (Omit<
27-
ComponentProps<typeof TabsComponent>["items"],
24+
ComponentProps<typeof TabList>["items"],
2825
"href" | "id"
2926
>[number] & {
3027
segment: string | undefined;
@@ -42,7 +39,7 @@ export const Tabs = ({ slug, items, ...props }: TabsProps) => {
4239
}));
4340
}, [items, slug]);
4441

45-
return <TabsComponent pathname={pathname} items={mappedItems} {...props} />;
42+
return <TabList pathname={pathname} items={mappedItems} {...props} />;
4643
};
4744

4845
export const TabPanel = ({

apps/insights/src/components/PriceFeeds/price-feeds-card.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import { Card } from "@pythnetwork/component-library/Card";
77
import { Paginator } from "@pythnetwork/component-library/Paginator";
88
import { SearchInput } from "@pythnetwork/component-library/SearchInput";
99
import { Select } from "@pythnetwork/component-library/Select";
10-
import { type RowConfig, Table } from "@pythnetwork/component-library/Table";
10+
import {
11+
type RowConfig,
12+
type SortDescriptor,
13+
Table,
14+
} from "@pythnetwork/component-library/Table";
1115
import { useQueryState, parseAsString } from "nuqs";
1216
import { type ReactNode, Suspense, useCallback, useMemo } from "react";
1317
import { useFilter, useCollator } from "react-aria";
14-
import type { SortDescriptor } from "react-aria-components";
1518

1619
import { useQueryParamFilterPagination } from "../../use-query-param-filter-pagination";
1720
import { SKELETON_WIDTH } from "../LivePrices";

apps/insights/src/components/Publishers/publishers-card.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import { Badge } from "@pythnetwork/component-library/Badge";
55
import { Card } from "@pythnetwork/component-library/Card";
66
import { Paginator } from "@pythnetwork/component-library/Paginator";
77
import { SearchInput } from "@pythnetwork/component-library/SearchInput";
8-
import { type RowConfig, Table } from "@pythnetwork/component-library/Table";
8+
import {
9+
type RowConfig,
10+
type SortDescriptor,
11+
Table,
12+
} from "@pythnetwork/component-library/Table";
913
import { type ReactNode, Suspense, useMemo } from "react";
1014
import { useFilter, useCollator } from "react-aria";
11-
import type { SortDescriptor } from "react-aria-components";
1215

1316
import { useQueryParamFilterPagination } from "../../use-query-param-filter-pagination";
1417
import { NoResults } from "../NoResults";

apps/insights/src/components/Publishers/semicircle-meter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use client";
22

3+
import { Meter } from "@pythnetwork/component-library/unstyled/Meter";
34
import dynamic from "next/dynamic";
45
import { type ComponentProps, Suspense } from "react";
5-
import { Meter } from "react-aria-components";
66
import { PolarAngleAxis, RadialBar } from "recharts";
77

8-
export { Label } from "react-aria-components";
8+
export { Label } from "@pythnetwork/component-library/unstyled/Label";
99

1010
const RadialBarChart = dynamic(
1111
() => import("recharts").then((recharts) => recharts.RadialBarChart),

apps/insights/src/components/Root/nav-link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use client";
22

3+
import { Link } from "@pythnetwork/component-library/unstyled/Link";
34
import { useSelectedLayoutSegment } from "next/navigation";
45
import type { ReactNode } from "react";
5-
import { Link } from "react-aria-components";
66

77
type Props = {
88
href: string;

apps/insights/src/components/Root/tabs.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
import { MainNavTabs as MainNavTabsComponent } from "@pythnetwork/component-library/MainNavTabs";
44
import {
5-
UnstyledTabPanel,
6-
UnstyledTabs,
7-
} from "@pythnetwork/component-library/UnstyledTabs";
5+
TabPanel as UnstyledTabPanel,
6+
Tabs,
7+
} from "@pythnetwork/component-library/unstyled/Tabs";
88
import { useSelectedLayoutSegment, usePathname } from "next/navigation";
99
import { type ComponentProps } from "react";
1010

1111
import { type VariantArg, LayoutTransition } from "../LayoutTransition";
1212

1313
export const TabRoot = (
14-
props: Omit<ComponentProps<typeof UnstyledTabs>, "selectedKey">,
14+
props: Omit<ComponentProps<typeof Tabs>, "selectedKey">,
1515
) => {
1616
const tabId = useSelectedLayoutSegment() ?? "";
1717

18-
return <UnstyledTabs selectedKey={tabId} {...props} />;
18+
return <Tabs selectedKey={tabId} {...props} />;
1919
};
2020

2121
export const MainNavTabs = (

apps/insights/src/components/Score/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use client";
22

33
import { Skeleton } from "@pythnetwork/component-library/Skeleton";
4+
import { Meter } from "@pythnetwork/component-library/unstyled/Meter";
45
import type { CSSProperties } from "react";
5-
import { Meter } from "react-aria-components";
66

77
import styles from "./index.module.scss";
88

apps/insights/src/use-query-param-filter-pagination.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useLogger } from "@pythnetwork/app-logger";
4+
import type { SortDescriptor } from "@pythnetwork/component-library/unstyled/Table";
45
import { usePathname } from "next/navigation";
56
import {
67
parseAsString,
@@ -10,7 +11,6 @@ import {
1011
createSerializer,
1112
} from "nuqs";
1213
import { useCallback, useMemo } from "react";
13-
import type { SortDescriptor } from "react-aria-components";
1414

1515
export const useQueryParamFilterPagination = <T>(
1616
items: T[],

packages/component-library/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"test:types": "tsc"
2323
},
2424
"peerDependencies": {
25+
"next": "catalog:",
2526
"react": "catalog:"
2627
},
2728
"dependencies": {
@@ -51,6 +52,7 @@
5152
"css-loader": "catalog:",
5253
"eslint": "catalog:",
5354
"jest": "catalog:",
55+
"next": "catalog:",
5456
"postcss": "catalog:",
5557
"postcss-loader": "catalog:",
5658
"prettier": "catalog:",

packages/component-library/src/Breadcrumbs/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import styles from "./index.module.scss";
99
import { Button } from "../Button/index.js";
1010
import { Link } from "../Link/index.js";
1111
import {
12-
UnstyledBreadcrumbs,
13-
UnstyledBreadcrumb,
14-
} from "../UnstyledBreadcrumbs/index.js";
12+
Breadcrumbs as UnstyledBreadcrumbs,
13+
Breadcrumb,
14+
} from "../unstyled/Breadcrumbs/index.js";
1515

1616
type OwnProps = {
1717
label: string;
@@ -37,7 +37,7 @@ export const Breadcrumbs = ({ label, className, items, ...props }: Props) => (
3737
{...props}
3838
>
3939
{(item) => (
40-
<UnstyledBreadcrumb className={styles.breadcrumb ?? ""}>
40+
<Breadcrumb className={styles.breadcrumb ?? ""}>
4141
{"href" in item ? (
4242
<>
4343
{item.href === "/" ? (
@@ -65,7 +65,7 @@ export const Breadcrumbs = ({ label, className, items, ...props }: Props) => (
6565
) : (
6666
<div className={styles.current}>{item.label}</div>
6767
)}
68-
</UnstyledBreadcrumb>
68+
</Breadcrumb>
6969
)}
7070
</UnstyledBreadcrumbs>
7171
</nav>

packages/component-library/src/Button/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {
77
} from "react";
88

99
import styles from "./index.module.scss";
10-
import { UnstyledButton } from "../UnstyledButton/index.js";
11-
import { UnstyledLink } from "../UnstyledLink/index.js";
10+
import { Button as UnstyledButton } from "../unstyled/Button/index.js";
11+
import { Link } from "../unstyled/Link/index.js";
1212

1313
export const VARIANTS = [
1414
"primary",
@@ -38,10 +38,10 @@ export type Props<T extends ElementType> = Omit<
3838
OwnProps;
3939

4040
export const Button = (
41-
props: Props<typeof UnstyledButton> | Props<typeof UnstyledLink>,
41+
props: Props<typeof UnstyledButton> | Props<typeof Link>,
4242
) =>
4343
"href" in props ? (
44-
<UnstyledLink {...buttonProps(props)} />
44+
<Link {...buttonProps(props)} />
4545
) : (
4646
<UnstyledButton {...buttonProps(props)} />
4747
);

packages/component-library/src/Card/index.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {
1010
import { OverlayTriggerStateContext } from "react-aria-components";
1111

1212
import styles from "./index.module.scss";
13-
import { UnstyledButton } from "../UnstyledButton/index.js";
14-
import { UnstyledLink } from "../UnstyledLink/index.js";
13+
import { Button } from "../unstyled/Button/index.js";
14+
import { Link } from "../unstyled/Link/index.js";
1515

1616
export const VARIANTS = ["primary", "secondary", "tertiary"] as const;
1717

@@ -30,17 +30,14 @@ export type Props<T extends ElementType> = Omit<
3030
OwnProps;
3131

3232
export const Card = (
33-
props:
34-
| Props<"div">
35-
| Props<typeof UnstyledLink>
36-
| Props<typeof UnstyledButton>,
33+
props: Props<"div"> | Props<typeof Link> | Props<typeof Button>,
3734
) => {
3835
const overlayState = use(OverlayTriggerStateContext);
3936

4037
if (overlayState !== null || "onPress" in props) {
41-
return <UnstyledButton {...cardProps(props)} />;
38+
return <Button {...cardProps(props)} />;
4239
} else if ("href" in props) {
43-
return <UnstyledLink {...cardProps(props)} />;
40+
return <Link {...cardProps(props)} />;
4441
} else {
4542
return <div {...cardProps(props)} />;
4643
}

packages/component-library/src/Link/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import clsx from "clsx";
22
import type { ComponentProps } from "react";
33

44
import styles from "./index.module.scss";
5-
import { UnstyledLink } from "../UnstyledLink/index.js";
5+
import { Link as UnstyledLink } from "../unstyled/Link/index.js";
66

77
type OwnProps = {
88
invert?: boolean | undefined;

packages/component-library/src/MainNavTabs/index.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22

33
import { MainNavTabs as MainNavTabsComponent } from "./index.js";
4-
import { UnstyledTabs } from "../UnstyledTabs/index.js";
4+
import { Tabs } from "../unstyled/Tabs/index.js";
55

66
const meta = {
77
component: MainNavTabsComponent,
@@ -18,9 +18,9 @@ export default meta;
1818
export const MainNavTabs = {
1919
decorators: [
2020
(Story) => (
21-
<UnstyledTabs>
21+
<Tabs>
2222
<Story />
23-
</UnstyledTabs>
23+
</Tabs>
2424
),
2525
],
2626
args: {

packages/component-library/src/MainNavTabs/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@ import type { ComponentProps } from "react";
66

77
import styles from "./index.module.scss";
88
import buttonStyles from "../Button/index.module.scss";
9-
import { UnstyledTab, UnstyledTabList } from "../UnstyledTabs/index.js";
9+
import { Tab, TabList } from "../unstyled/Tabs/index.js";
1010

1111
type OwnProps = {
1212
pathname?: string | undefined;
13-
items: ComponentProps<typeof UnstyledTab>[];
13+
items: ComponentProps<typeof Tab>[];
1414
};
15-
type Props = Omit<ComponentProps<typeof UnstyledTabList>, keyof OwnProps> &
16-
OwnProps;
15+
type Props = Omit<ComponentProps<typeof TabList>, keyof OwnProps> & OwnProps;
1716

1817
export const MainNavTabs = ({ className, pathname, ...props }: Props) => (
19-
<UnstyledTabList
18+
<TabList
2019
aria-label="Main Navigation"
2120
className={clsx(styles.mainNavTabs, className)}
2221
dependencies={[pathname]}
2322
{...props}
2423
>
2524
{({ className: tabClassName, children, ...tab }) => (
26-
<UnstyledTab
25+
<Tab
2726
className={clsx(styles.tab, buttonStyles.button, tabClassName)}
2827
data-size="sm"
2928
data-variant="ghost"
@@ -46,7 +45,7 @@ export const MainNavTabs = ({ className, pathname, ...props }: Props) => (
4645
</span>
4746
</>
4847
)}
49-
</UnstyledTab>
48+
</Tab>
5049
)}
51-
</UnstyledTabList>
50+
</TabList>
5251
);

0 commit comments

Comments
 (0)